babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289
  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/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @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)
  7392. * @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)
  7393. * @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)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * 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.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * 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
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * 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)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * 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)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * 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).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @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
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * 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.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @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
  7840. * @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
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the parent skeleton
  7943. * @returns a skeleton
  7944. */
  7945. getSkeleton(): Skeleton;
  7946. /**
  7947. * Gets parent bone
  7948. * @returns a bone or null if the bone is the root of the bone hierarchy
  7949. */
  7950. getParent(): Nullable<Bone>;
  7951. /**
  7952. * Sets the parent bone
  7953. * @param parent defines the parent (can be null if the bone is the root)
  7954. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7955. */
  7956. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7957. /**
  7958. * Gets the local matrix
  7959. * @returns a matrix
  7960. */
  7961. getLocalMatrix(): Matrix;
  7962. /**
  7963. * Gets the base matrix (initial matrix which remains unchanged)
  7964. * @returns a matrix
  7965. */
  7966. getBaseMatrix(): Matrix;
  7967. /**
  7968. * Gets the rest pose matrix
  7969. * @returns a matrix
  7970. */
  7971. getRestPose(): Matrix;
  7972. /**
  7973. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7974. */
  7975. getWorldMatrix(): Matrix;
  7976. /**
  7977. * Sets the local matrix to rest pose matrix
  7978. */
  7979. returnToRest(): void;
  7980. /**
  7981. * Gets the inverse of the absolute transform matrix.
  7982. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7983. * @returns a matrix
  7984. */
  7985. getInvertedAbsoluteTransform(): Matrix;
  7986. /**
  7987. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7988. * @returns a matrix
  7989. */
  7990. getAbsoluteTransform(): Matrix;
  7991. /**
  7992. * Links with the given transform node.
  7993. * The local matrix of this bone is copied from the transform node every frame.
  7994. * @param transformNode defines the transform node to link to
  7995. */
  7996. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7997. /** Gets or sets current position (in local space) */
  7998. position: Vector3;
  7999. /** Gets or sets current rotation (in local space) */
  8000. rotation: Vector3;
  8001. /** Gets or sets current rotation quaternion (in local space) */
  8002. rotationQuaternion: Quaternion;
  8003. /** Gets or sets current scaling (in local space) */
  8004. scaling: Vector3;
  8005. /**
  8006. * Gets the animation properties override
  8007. */
  8008. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8009. private _decompose;
  8010. private _compose;
  8011. /**
  8012. * Update the base and local matrices
  8013. * @param matrix defines the new base or local matrix
  8014. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8015. * @param updateLocalMatrix defines if the local matrix should be updated
  8016. */
  8017. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8018. /** @hidden */
  8019. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8020. /**
  8021. * Flag the bone as dirty (Forcing it to update everything)
  8022. */
  8023. markAsDirty(): void;
  8024. private _markAsDirtyAndCompose;
  8025. private _markAsDirtyAndDecompose;
  8026. /**
  8027. * Translate the bone in local or world space
  8028. * @param vec The amount to translate the bone
  8029. * @param space The space that the translation is in
  8030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8031. */
  8032. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8033. /**
  8034. * Set the postion of the bone in local or world space
  8035. * @param position The position to set the bone
  8036. * @param space The space that the position is in
  8037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8038. */
  8039. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8040. /**
  8041. * Set the absolute position of the bone (world space)
  8042. * @param position The position to set the bone
  8043. * @param mesh The mesh that this bone is attached to
  8044. */
  8045. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8046. /**
  8047. * Scale the bone on the x, y and z axes (in local space)
  8048. * @param x The amount to scale the bone on the x axis
  8049. * @param y The amount to scale the bone on the y axis
  8050. * @param z The amount to scale the bone on the z axis
  8051. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8052. */
  8053. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8054. /**
  8055. * Set the bone scaling in local space
  8056. * @param scale defines the scaling vector
  8057. */
  8058. setScale(scale: Vector3): void;
  8059. /**
  8060. * Gets the current scaling in local space
  8061. * @returns the current scaling vector
  8062. */
  8063. getScale(): Vector3;
  8064. /**
  8065. * Gets the current scaling in local space and stores it in a target vector
  8066. * @param result defines the target vector
  8067. */
  8068. getScaleToRef(result: Vector3): void;
  8069. /**
  8070. * Set the yaw, pitch, and roll of the bone in local or world space
  8071. * @param yaw The rotation of the bone on the y axis
  8072. * @param pitch The rotation of the bone on the x axis
  8073. * @param roll The rotation of the bone on the z axis
  8074. * @param space The space that the axes of rotation are in
  8075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8076. */
  8077. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Add a rotation to the bone on an axis in local or world space
  8080. * @param axis The axis to rotate the bone on
  8081. * @param amount The amount to rotate the bone
  8082. * @param space The space that the axis is in
  8083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8084. */
  8085. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8086. /**
  8087. * Set the rotation of the bone to a particular axis angle in local or world space
  8088. * @param axis The axis to rotate the bone on
  8089. * @param angle The angle that the bone should be rotated to
  8090. * @param space The space that the axis is in
  8091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8092. */
  8093. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8094. /**
  8095. * Set the euler rotation of the bone in local of world space
  8096. * @param rotation The euler rotation that the bone should be set to
  8097. * @param space The space that the rotation is in
  8098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8099. */
  8100. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8101. /**
  8102. * Set the quaternion rotation of the bone in local of world space
  8103. * @param quat The quaternion rotation that the bone should be set to
  8104. * @param space The space that the rotation is in
  8105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8106. */
  8107. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8108. /**
  8109. * Set the rotation matrix of the bone in local of world space
  8110. * @param rotMat The rotation matrix that the bone should be set to
  8111. * @param space The space that the rotation is in
  8112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8113. */
  8114. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8115. private _rotateWithMatrix;
  8116. private _getNegativeRotationToRef;
  8117. /**
  8118. * Get the position of the bone in local or world space
  8119. * @param space The space that the returned position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. * @returns The position of the bone
  8122. */
  8123. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8124. /**
  8125. * Copy the position of the bone to a vector3 in local or world space
  8126. * @param space The space that the returned position is in
  8127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8128. * @param result The vector3 to copy the position to
  8129. */
  8130. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8131. /**
  8132. * Get the absolute position of the bone (world space)
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @returns The absolute position of the bone
  8135. */
  8136. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8137. /**
  8138. * Copy the absolute position of the bone (world space) to the result param
  8139. * @param mesh The mesh that this bone is attached to
  8140. * @param result The vector3 to copy the absolute position to
  8141. */
  8142. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8143. /**
  8144. * Compute the absolute transforms of this bone and its children
  8145. */
  8146. computeAbsoluteTransforms(): void;
  8147. /**
  8148. * Get the world direction from an axis that is in the local space of the bone
  8149. * @param localAxis The local direction that is used to compute the world direction
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @returns The world direction
  8152. */
  8153. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8154. /**
  8155. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8156. * @param localAxis The local direction that is used to compute the world direction
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @param result The vector3 that the world direction will be copied to
  8159. */
  8160. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8161. /**
  8162. * Get the euler rotation of the bone in local or world space
  8163. * @param space The space that the rotation should be in
  8164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8165. * @returns The euler rotation
  8166. */
  8167. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8168. /**
  8169. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8170. * @param space The space that the rotation should be in
  8171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8172. * @param result The vector3 that the rotation should be copied to
  8173. */
  8174. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8175. /**
  8176. * Get the quaternion rotation of the bone in either local or world space
  8177. * @param space The space that the rotation should be in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. * @returns The quaternion rotation
  8180. */
  8181. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8182. /**
  8183. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8184. * @param space The space that the rotation should be in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. * @param result The quaternion that the rotation should be copied to
  8187. */
  8188. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8189. /**
  8190. * Get the rotation matrix of the bone in local or world space
  8191. * @param space The space that the rotation should be in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. * @returns The rotation matrix
  8194. */
  8195. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8196. /**
  8197. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8198. * @param space The space that the rotation should be in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @param result The quaternion that the rotation should be copied to
  8201. */
  8202. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8203. /**
  8204. * Get the world position of a point that is in the local space of the bone
  8205. * @param position The local position
  8206. * @param mesh The mesh that this bone is attached to
  8207. * @returns The world position
  8208. */
  8209. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8210. /**
  8211. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8212. * @param position The local position
  8213. * @param mesh The mesh that this bone is attached to
  8214. * @param result The vector3 that the world position should be copied to
  8215. */
  8216. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8217. /**
  8218. * Get the local position of a point that is in world space
  8219. * @param position The world position
  8220. * @param mesh The mesh that this bone is attached to
  8221. * @returns The local position
  8222. */
  8223. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8224. /**
  8225. * Get the local position of a point that is in world space and copy it to the result param
  8226. * @param position The world position
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @param result The vector3 that the local position should be copied to
  8229. */
  8230. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8231. }
  8232. }
  8233. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8234. import { Nullable } from "babylonjs/types";
  8235. import { Scene } from "babylonjs/scene";
  8236. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8238. /**
  8239. * Class for creating a cube texture
  8240. */
  8241. export class CubeTexture extends BaseTexture {
  8242. private _delayedOnLoad;
  8243. /**
  8244. * The url of the texture
  8245. */
  8246. url: string;
  8247. /**
  8248. * Gets or sets the center of the bounding box associated with the cube texture.
  8249. * It must define where the camera used to render the texture was set
  8250. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8251. */
  8252. boundingBoxPosition: Vector3;
  8253. private _boundingBoxSize;
  8254. /**
  8255. * Gets or sets the size of the bounding box associated with the cube texture
  8256. * When defined, the cubemap will switch to local mode
  8257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8258. * @example https://www.babylonjs-playground.com/#RNASML
  8259. */
  8260. /**
  8261. * Returns the bounding box size
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxSize: Vector3;
  8265. protected _rotationY: number;
  8266. /**
  8267. * Sets texture matrix rotation angle around Y axis in radians.
  8268. */
  8269. /**
  8270. * Gets texture matrix rotation angle around Y axis radians.
  8271. */
  8272. rotationY: number;
  8273. /**
  8274. * Are mip maps generated for this texture or not.
  8275. */
  8276. readonly noMipmap: boolean;
  8277. private _noMipmap;
  8278. private _files;
  8279. private _extensions;
  8280. private _textureMatrix;
  8281. private _format;
  8282. private _createPolynomials;
  8283. /** @hidden */
  8284. _prefiltered: boolean;
  8285. /**
  8286. * Creates a cube texture from an array of image urls
  8287. * @param files defines an array of image urls
  8288. * @param scene defines the hosting scene
  8289. * @param noMipmap specifies if mip maps are not used
  8290. * @returns a cube texture
  8291. */
  8292. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8293. /**
  8294. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8295. * @param url defines the url of the prefiltered texture
  8296. * @param scene defines the scene the texture is attached to
  8297. * @param forcedExtension defines the extension of the file if different from the url
  8298. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8299. * @return the prefiltered texture
  8300. */
  8301. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8302. /**
  8303. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8304. * as prefiltered data.
  8305. * @param rootUrl defines the url of the texture or the root name of the six images
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8308. * @param noMipmap defines if mipmaps should be created or not
  8309. * @param files defines the six files to load for the different faces
  8310. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8311. * @param onError defines a callback triggered in case of error during load
  8312. * @param format defines the internal format to use for the texture once loaded
  8313. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8314. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8315. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8316. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8317. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8318. * @return the cube texture
  8319. */
  8320. 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);
  8321. /**
  8322. * Get the current class name of the texture useful for serialization or dynamic coding.
  8323. * @returns "CubeTexture"
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Update the url (and optional buffer) of this texture if url was null during construction.
  8328. * @param url the url of the texture
  8329. * @param forcedExtension defines the extension to use
  8330. * @param onLoad callback called when the texture is loaded (defaults to null)
  8331. */
  8332. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8333. /**
  8334. * Delays loading of the cube texture
  8335. * @param forcedExtension defines the extension to use
  8336. */
  8337. delayLoad(forcedExtension?: string): void;
  8338. /**
  8339. * Returns the reflection texture matrix
  8340. * @returns the reflection texture matrix
  8341. */
  8342. getReflectionTextureMatrix(): Matrix;
  8343. /**
  8344. * Sets the reflection texture matrix
  8345. * @param value Reflection texture matrix
  8346. */
  8347. setReflectionTextureMatrix(value: Matrix): void;
  8348. /**
  8349. * Parses text to create a cube texture
  8350. * @param parsedTexture define the serialized text to read from
  8351. * @param scene defines the hosting scene
  8352. * @param rootUrl defines the root url of the cube texture
  8353. * @returns a cube texture
  8354. */
  8355. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8356. /**
  8357. * Makes a clone, or deep copy, of the cube texture
  8358. * @returns a new cube texture
  8359. */
  8360. clone(): CubeTexture;
  8361. }
  8362. }
  8363. declare module "babylonjs/Shaders/postprocess.vertex" {
  8364. /** @hidden */
  8365. export var postprocessVertexShader: {
  8366. name: string;
  8367. shader: string;
  8368. };
  8369. }
  8370. declare module "babylonjs/Cameras/targetCamera" {
  8371. import { Nullable } from "babylonjs/types";
  8372. import { Camera } from "babylonjs/Cameras/camera";
  8373. import { Scene } from "babylonjs/scene";
  8374. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8375. /**
  8376. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8377. * This is the base of the follow, arc rotate cameras and Free camera
  8378. * @see http://doc.babylonjs.com/features/cameras
  8379. */
  8380. export class TargetCamera extends Camera {
  8381. private static _RigCamTransformMatrix;
  8382. private static _TargetTransformMatrix;
  8383. private static _TargetFocalPoint;
  8384. /**
  8385. * Define the current direction the camera is moving to
  8386. */
  8387. cameraDirection: Vector3;
  8388. /**
  8389. * Define the current rotation the camera is rotating to
  8390. */
  8391. cameraRotation: Vector2;
  8392. /**
  8393. * When set, the up vector of the camera will be updated by the rotation of the camera
  8394. */
  8395. updateUpVectorFromRotation: boolean;
  8396. private _tmpQuaternion;
  8397. /**
  8398. * Define the current rotation of the camera
  8399. */
  8400. rotation: Vector3;
  8401. /**
  8402. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8403. */
  8404. rotationQuaternion: Quaternion;
  8405. /**
  8406. * Define the current speed of the camera
  8407. */
  8408. speed: number;
  8409. /**
  8410. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8411. * around all axis.
  8412. */
  8413. noRotationConstraint: boolean;
  8414. /**
  8415. * Define the current target of the camera as an object or a position.
  8416. */
  8417. lockedTarget: any;
  8418. /** @hidden */
  8419. _currentTarget: Vector3;
  8420. /** @hidden */
  8421. _initialFocalDistance: number;
  8422. /** @hidden */
  8423. _viewMatrix: Matrix;
  8424. /** @hidden */
  8425. _camMatrix: Matrix;
  8426. /** @hidden */
  8427. _cameraTransformMatrix: Matrix;
  8428. /** @hidden */
  8429. _cameraRotationMatrix: Matrix;
  8430. /** @hidden */
  8431. _referencePoint: Vector3;
  8432. /** @hidden */
  8433. _transformedReferencePoint: Vector3;
  8434. protected _globalCurrentTarget: Vector3;
  8435. protected _globalCurrentUpVector: Vector3;
  8436. /** @hidden */
  8437. _reset: () => void;
  8438. private _defaultUp;
  8439. /**
  8440. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8441. * This is the base of the follow, arc rotate cameras and Free camera
  8442. * @see http://doc.babylonjs.com/features/cameras
  8443. * @param name Defines the name of the camera in the scene
  8444. * @param position Defines the start position of the camera in the scene
  8445. * @param scene Defines the scene the camera belongs to
  8446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8447. */
  8448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8449. /**
  8450. * Gets the position in front of the camera at a given distance.
  8451. * @param distance The distance from the camera we want the position to be
  8452. * @returns the position
  8453. */
  8454. getFrontPosition(distance: number): Vector3;
  8455. /** @hidden */
  8456. _getLockedTargetPosition(): Nullable<Vector3>;
  8457. private _storedPosition;
  8458. private _storedRotation;
  8459. private _storedRotationQuaternion;
  8460. /**
  8461. * Store current camera state of the camera (fov, position, rotation, etc..)
  8462. * @returns the camera
  8463. */
  8464. storeState(): Camera;
  8465. /**
  8466. * Restored camera state. You must call storeState() first
  8467. * @returns whether it was successful or not
  8468. * @hidden
  8469. */
  8470. _restoreStateValues(): boolean;
  8471. /** @hidden */
  8472. _initCache(): void;
  8473. /** @hidden */
  8474. _updateCache(ignoreParentClass?: boolean): void;
  8475. /** @hidden */
  8476. _isSynchronizedViewMatrix(): boolean;
  8477. /** @hidden */
  8478. _computeLocalCameraSpeed(): number;
  8479. /** @hidden */
  8480. setTarget(target: Vector3): void;
  8481. /**
  8482. * Return the current target position of the camera. This value is expressed in local space.
  8483. * @returns the target position
  8484. */
  8485. getTarget(): Vector3;
  8486. /** @hidden */
  8487. _decideIfNeedsToMove(): boolean;
  8488. /** @hidden */
  8489. _updatePosition(): void;
  8490. /** @hidden */
  8491. _checkInputs(): void;
  8492. protected _updateCameraRotationMatrix(): void;
  8493. /**
  8494. * 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)
  8495. * @returns the current camera
  8496. */
  8497. private _rotateUpVectorWithCameraRotationMatrix;
  8498. private _cachedRotationZ;
  8499. private _cachedQuaternionRotationZ;
  8500. /** @hidden */
  8501. _getViewMatrix(): Matrix;
  8502. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8503. /**
  8504. * @hidden
  8505. */
  8506. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8507. /**
  8508. * @hidden
  8509. */
  8510. _updateRigCameras(): void;
  8511. private _getRigCamPositionAndTarget;
  8512. /**
  8513. * Gets the current object class name.
  8514. * @return the class name
  8515. */
  8516. getClassName(): string;
  8517. }
  8518. }
  8519. declare module "babylonjs/Cameras/cameraInputsManager" {
  8520. import { Nullable } from "babylonjs/types";
  8521. import { Camera } from "babylonjs/Cameras/camera";
  8522. /**
  8523. * @ignore
  8524. * This is a list of all the different input types that are available in the application.
  8525. * Fo instance: ArcRotateCameraGamepadInput...
  8526. */
  8527. export var CameraInputTypes: {};
  8528. /**
  8529. * This is the contract to implement in order to create a new input class.
  8530. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8531. */
  8532. export interface ICameraInput<TCamera extends Camera> {
  8533. /**
  8534. * Defines the camera the input is attached to.
  8535. */
  8536. camera: Nullable<TCamera>;
  8537. /**
  8538. * Gets the class name of the current intput.
  8539. * @returns the class name
  8540. */
  8541. getClassName(): string;
  8542. /**
  8543. * Get the friendly name associated with the input class.
  8544. * @returns the input friendly name
  8545. */
  8546. getSimpleName(): string;
  8547. /**
  8548. * Attach the input controls to a specific dom element to get the input from.
  8549. * @param element Defines the element the controls should be listened from
  8550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8551. */
  8552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8553. /**
  8554. * Detach the current controls from the specified dom element.
  8555. * @param element Defines the element to stop listening the inputs from
  8556. */
  8557. detachControl(element: Nullable<HTMLElement>): void;
  8558. /**
  8559. * Update the current camera state depending on the inputs that have been used this frame.
  8560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8561. */
  8562. checkInputs?: () => void;
  8563. }
  8564. /**
  8565. * Represents a map of input types to input instance or input index to input instance.
  8566. */
  8567. export interface CameraInputsMap<TCamera extends Camera> {
  8568. /**
  8569. * Accessor to the input by input type.
  8570. */
  8571. [name: string]: ICameraInput<TCamera>;
  8572. /**
  8573. * Accessor to the input by input index.
  8574. */
  8575. [idx: number]: ICameraInput<TCamera>;
  8576. }
  8577. /**
  8578. * This represents the input manager used within a camera.
  8579. * It helps dealing with all the different kind of input attached to a camera.
  8580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8581. */
  8582. export class CameraInputsManager<TCamera extends Camera> {
  8583. /**
  8584. * Defines the list of inputs attahed to the camera.
  8585. */
  8586. attached: CameraInputsMap<TCamera>;
  8587. /**
  8588. * Defines the dom element the camera is collecting inputs from.
  8589. * This is null if the controls have not been attached.
  8590. */
  8591. attachedElement: Nullable<HTMLElement>;
  8592. /**
  8593. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8594. */
  8595. noPreventDefault: boolean;
  8596. /**
  8597. * Defined the camera the input manager belongs to.
  8598. */
  8599. camera: TCamera;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs: () => void;
  8605. /**
  8606. * Instantiate a new Camera Input Manager.
  8607. * @param camera Defines the camera the input manager blongs to
  8608. */
  8609. constructor(camera: TCamera);
  8610. /**
  8611. * Add an input method to a camera
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. * @param input camera input method
  8614. */
  8615. add(input: ICameraInput<TCamera>): void;
  8616. /**
  8617. * Remove a specific input method from a camera
  8618. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8619. * @param inputToRemove camera input method
  8620. */
  8621. remove(inputToRemove: ICameraInput<TCamera>): void;
  8622. /**
  8623. * Remove a specific input type from a camera
  8624. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8625. * @param inputType the type of the input to remove
  8626. */
  8627. removeByType(inputType: string): void;
  8628. private _addCheckInputs;
  8629. /**
  8630. * Attach the input controls to the currently attached dom element to listen the events from.
  8631. * @param input Defines the input to attach
  8632. */
  8633. attachInput(input: ICameraInput<TCamera>): void;
  8634. /**
  8635. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8636. * @param element Defines the dom element to collect the events from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current manager inputs controls from a specific dom element.
  8642. * @param element Defines the dom element to collect the events from
  8643. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8644. */
  8645. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8646. /**
  8647. * Rebuild the dynamic inputCheck function from the current list of
  8648. * defined inputs in the manager.
  8649. */
  8650. rebuildInputCheck(): void;
  8651. /**
  8652. * Remove all attached input methods from a camera
  8653. */
  8654. clear(): void;
  8655. /**
  8656. * Serialize the current input manager attached to a camera.
  8657. * This ensures than once parsed,
  8658. * the input associated to the camera will be identical to the current ones
  8659. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8660. */
  8661. serialize(serializedCamera: any): void;
  8662. /**
  8663. * Parses an input manager serialized JSON to restore the previous list of inputs
  8664. * and states associated to a camera.
  8665. * @param parsedCamera Defines the JSON to parse
  8666. */
  8667. parse(parsedCamera: any): void;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  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. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/materialHelper" {
  9052. import { Nullable } from "babylonjs/types";
  9053. import { Scene } from "babylonjs/scene";
  9054. import { Engine } from "babylonjs/Engines/engine";
  9055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9056. import { Light } from "babylonjs/Lights/light";
  9057. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9058. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9060. /**
  9061. * "Static Class" containing the most commonly used helper while dealing with material for
  9062. * rendering purpose.
  9063. *
  9064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9065. *
  9066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9067. */
  9068. export class MaterialHelper {
  9069. /**
  9070. * Bind the current view position to an effect.
  9071. * @param effect The effect to be bound
  9072. * @param scene The scene the eyes position is used from
  9073. */
  9074. static BindEyePosition(effect: Effect, scene: Scene): void;
  9075. /**
  9076. * Helps preparing the defines values about the UVs in used in the effect.
  9077. * UVs are shared as much as we can accross channels in the shaders.
  9078. * @param texture The texture we are preparing the UVs for
  9079. * @param defines The defines to update
  9080. * @param key The channel key "diffuse", "specular"... used in the shader
  9081. */
  9082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9083. /**
  9084. * Binds a texture matrix value to its corrsponding uniform
  9085. * @param texture The texture to bind the matrix for
  9086. * @param uniformBuffer The uniform buffer receivin the data
  9087. * @param key The channel key "diffuse", "specular"... used in the shader
  9088. */
  9089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9090. /**
  9091. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9092. * @param mesh defines the current mesh
  9093. * @param scene defines the current scene
  9094. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9095. * @param pointsCloud defines if point cloud rendering has to be turned on
  9096. * @param fogEnabled defines if fog has to be turned on
  9097. * @param alphaTest defines if alpha testing has to be turned on
  9098. * @param defines defines the current list of defines
  9099. */
  9100. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9101. /**
  9102. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9103. * @param scene defines the current scene
  9104. * @param engine defines the current engine
  9105. * @param defines specifies the list of active defines
  9106. * @param useInstances defines if instances have to be turned on
  9107. * @param useClipPlane defines if clip plane have to be turned on
  9108. */
  9109. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9110. /**
  9111. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9112. * @param mesh The mesh containing the geometry data we will draw
  9113. * @param defines The defines to update
  9114. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9115. * @param useBones Precise whether bones should be used or not (override mesh info)
  9116. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9117. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9118. * @returns false if defines are considered not dirty and have not been checked
  9119. */
  9120. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9121. /**
  9122. * Prepares the defines related to the light information passed in parameter
  9123. * @param scene The scene we are intending to draw
  9124. * @param mesh The mesh the effect is compiling for
  9125. * @param defines The defines to update
  9126. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9127. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9128. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9129. * @returns true if normals will be required for the rest of the effect
  9130. */
  9131. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9132. /**
  9133. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9134. * that won t be acctive due to defines being turned off.
  9135. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9136. * @param samplersList The samplers list
  9137. * @param defines The defines helping in the list generation
  9138. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9139. */
  9140. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9141. /**
  9142. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9143. * @param defines The defines to update while falling back
  9144. * @param fallbacks The authorized effect fallbacks
  9145. * @param maxSimultaneousLights The maximum number of lights allowed
  9146. * @param rank the current rank of the Effect
  9147. * @returns The newly affected rank
  9148. */
  9149. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9150. /**
  9151. * Prepares the list of attributes required for morph targets according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the morph targets attributes for
  9154. * @param defines The current Defines of the effect
  9155. */
  9156. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9157. /**
  9158. * Prepares the list of attributes required for bones according to the effect defines.
  9159. * @param attribs The current list of supported attribs
  9160. * @param mesh The mesh to prepare the bones attributes for
  9161. * @param defines The current Defines of the effect
  9162. * @param fallbacks The current efffect fallback strategy
  9163. */
  9164. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9165. /**
  9166. * Prepares the list of attributes required for instances according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param defines The current Defines of the effect
  9169. */
  9170. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9171. /**
  9172. * Binds the light shadow information to the effect for the given mesh.
  9173. * @param light The light containing the generator
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param lightIndex The light index in the effect used to render the mesh
  9177. * @param effect The effect we are binding the data to
  9178. */
  9179. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9180. /**
  9181. * Binds the light information to the effect.
  9182. * @param light The light containing the generator
  9183. * @param effect The effect we are binding the data to
  9184. * @param lightIndex The light index in the effect used to render
  9185. */
  9186. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. */
  9196. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9197. private static _tempFogColor;
  9198. /**
  9199. * Binds the fog information from the scene to the effect for the given mesh.
  9200. * @param scene The scene the lights belongs to
  9201. * @param mesh The mesh we are binding the information to render
  9202. * @param effect The effect we are binding the data to
  9203. * @param linearSpace Defines if the fog effect is applied in linear space
  9204. */
  9205. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9206. /**
  9207. * Binds the bones information from the mesh to the effect.
  9208. * @param mesh The mesh we are binding the information to render
  9209. * @param effect The effect we are binding the data to
  9210. */
  9211. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9212. /**
  9213. * Binds the morph targets information from the mesh to the effect.
  9214. * @param abstractMesh The mesh we are binding the information to render
  9215. * @param effect The effect we are binding the data to
  9216. */
  9217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9218. /**
  9219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9220. * @param defines The generated defines used in the effect
  9221. * @param effect The effect we are binding the data to
  9222. * @param scene The scene we are willing to render with logarithmic scale for
  9223. */
  9224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9225. /**
  9226. * Binds the clip plane information from the scene to the effect.
  9227. * @param scene The scene the clip plane information are extracted from
  9228. * @param effect The effect we are binding the data to
  9229. */
  9230. static BindClipPlane(effect: Effect, scene: Scene): void;
  9231. }
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9234. /** @hidden */
  9235. export var kernelBlurVaryingDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9241. /** @hidden */
  9242. export var kernelBlurFragment: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9248. /** @hidden */
  9249. export var kernelBlurFragment2: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9255. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9256. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9257. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9258. /** @hidden */
  9259. export var kernelBlurPixelShader: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9265. /** @hidden */
  9266. export var kernelBlurVertex: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9274. /** @hidden */
  9275. export var kernelBlurVertexShader: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9281. import { Vector2 } from "babylonjs/Maths/math";
  9282. import { Nullable } from "babylonjs/types";
  9283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9284. import { Camera } from "babylonjs/Cameras/camera";
  9285. import { Effect } from "babylonjs/Materials/effect";
  9286. import { Engine } from "babylonjs/Engines/engine";
  9287. import "babylonjs/Shaders/kernelBlur.fragment";
  9288. import "babylonjs/Shaders/kernelBlur.vertex";
  9289. /**
  9290. * The Blur Post Process which blurs an image based on a kernel and direction.
  9291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9292. */
  9293. export class BlurPostProcess extends PostProcess {
  9294. /** The direction in which to blur the image. */
  9295. direction: Vector2;
  9296. private blockCompilation;
  9297. protected _kernel: number;
  9298. protected _idealKernel: number;
  9299. protected _packedFloat: boolean;
  9300. private _staticDefines;
  9301. /**
  9302. * Sets the length in pixels of the blur sample region
  9303. */
  9304. /**
  9305. * Gets the length in pixels of the blur sample region
  9306. */
  9307. kernel: number;
  9308. /**
  9309. * Sets wether or not the blur needs to unpack/repack floats
  9310. */
  9311. /**
  9312. * Gets wether or not the blur is unpacking/repacking floats
  9313. */
  9314. packedFloat: boolean;
  9315. /**
  9316. * Creates a new instance BlurPostProcess
  9317. * @param name The name of the effect.
  9318. * @param direction The direction in which to blur the image.
  9319. * @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.
  9320. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9321. * @param camera The camera to apply the render pass to.
  9322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9323. * @param engine The engine which the post process will be applied. (default: current engine)
  9324. * @param reusable If the post process can be reused on the same frame. (default: false)
  9325. * @param textureType Type of textures used when performing the post process. (default: 0)
  9326. * @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)
  9327. */
  9328. constructor(name: string,
  9329. /** The direction in which to blur the image. */
  9330. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9331. /**
  9332. * Updates the effect with the current post process compile time values and recompiles the shader.
  9333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9336. * @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
  9337. * @param onCompiled Called when the shader has been compiled.
  9338. * @param onError Called if there is an error when compiling a shader.
  9339. */
  9340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9341. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9342. /**
  9343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9347. * The gaps between physical kernels are compensated for in the weighting of the samples
  9348. * @param idealKernel Ideal blur kernel.
  9349. * @return Nearest best kernel.
  9350. */
  9351. protected _nearestBestKernel(idealKernel: number): number;
  9352. /**
  9353. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9354. * @param x The point on the Gaussian distribution to sample.
  9355. * @return the value of the Gaussian function at x.
  9356. */
  9357. protected _gaussianWeight(x: number): number;
  9358. /**
  9359. * Generates a string that can be used as a floating point number in GLSL.
  9360. * @param x Value to print.
  9361. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9362. * @return GLSL float string.
  9363. */
  9364. protected _glslFloat(x: number, decimalFigures?: number): string;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9368. /** @hidden */
  9369. export var shadowMapPixelShader: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9375. /** @hidden */
  9376. export var bonesDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9382. /** @hidden */
  9383. export var morphTargetsVertexGlobalDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9389. /** @hidden */
  9390. export var morphTargetsVertexDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9396. /** @hidden */
  9397. export var instancesDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9403. /** @hidden */
  9404. export var helperFunctions: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9410. /** @hidden */
  9411. export var morphTargetsVertex: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9417. /** @hidden */
  9418. export var instancesVertex: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9424. /** @hidden */
  9425. export var bonesVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9431. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9439. /** @hidden */
  9440. export var shadowMapVertexShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9446. /** @hidden */
  9447. export var depthBoxBlurPixelShader: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9453. import { Nullable } from "babylonjs/types";
  9454. import { Scene } from "babylonjs/scene";
  9455. import { Matrix } from "babylonjs/Maths/math";
  9456. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9458. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9459. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9460. import { Effect } from "babylonjs/Materials/effect";
  9461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9462. import "babylonjs/Shaders/shadowMap.fragment";
  9463. import "babylonjs/Shaders/shadowMap.vertex";
  9464. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9465. import { Observable } from "babylonjs/Misc/observable";
  9466. /**
  9467. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9468. */
  9469. export interface ICustomShaderOptions {
  9470. /**
  9471. * Gets or sets the custom shader name to use
  9472. */
  9473. shaderName: string;
  9474. /**
  9475. * The list of attribute names used in the shader
  9476. */
  9477. attributes?: string[];
  9478. /**
  9479. * The list of unifrom names used in the shader
  9480. */
  9481. uniforms?: string[];
  9482. /**
  9483. * The list of sampler names used in the shader
  9484. */
  9485. samplers?: string[];
  9486. /**
  9487. * The list of defines used in the shader
  9488. */
  9489. defines?: string[];
  9490. }
  9491. /**
  9492. * Interface to implement to create a shadow generator compatible with BJS.
  9493. */
  9494. export interface IShadowGenerator {
  9495. /**
  9496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9497. * @returns The render target texture if present otherwise, null
  9498. */
  9499. getShadowMap(): Nullable<RenderTargetTexture>;
  9500. /**
  9501. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9502. * @returns The render target texture if the shadow map is present otherwise, null
  9503. */
  9504. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9505. /**
  9506. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9507. * @param subMesh The submesh we want to render in the shadow map
  9508. * @param useInstances Defines wether will draw in the map using instances
  9509. * @returns true if ready otherwise, false
  9510. */
  9511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9512. /**
  9513. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9514. * @param defines Defines of the material we want to update
  9515. * @param lightIndex Index of the light in the enabled light list of the material
  9516. */
  9517. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9518. /**
  9519. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9520. * defined in the generator but impacting the effect).
  9521. * It implies the unifroms available on the materials are the standard BJS ones.
  9522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9523. * @param effect The effect we are binfing the information for
  9524. */
  9525. bindShadowLight(lightIndex: string, effect: Effect): void;
  9526. /**
  9527. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9528. * (eq to shadow prjection matrix * light transform matrix)
  9529. * @returns The transform matrix used to create the shadow map
  9530. */
  9531. getTransformMatrix(): Matrix;
  9532. /**
  9533. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9534. * Cube and 2D textures for instance.
  9535. */
  9536. recreateShadowMap(): void;
  9537. /**
  9538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9539. * @param onCompiled Callback triggered at the and of the effects compilation
  9540. * @param options Sets of optional options forcing the compilation with different modes
  9541. */
  9542. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9543. useInstances: boolean;
  9544. }>): void;
  9545. /**
  9546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9547. * @param options Sets of optional options forcing the compilation with different modes
  9548. * @returns A promise that resolves when the compilation completes
  9549. */
  9550. forceCompilationAsync(options?: Partial<{
  9551. useInstances: boolean;
  9552. }>): Promise<void>;
  9553. /**
  9554. * Serializes the shadow generator setup to a json object.
  9555. * @returns The serialized JSON object
  9556. */
  9557. serialize(): any;
  9558. /**
  9559. * Disposes the Shadow map and related Textures and effects.
  9560. */
  9561. dispose(): void;
  9562. }
  9563. /**
  9564. * Default implementation IShadowGenerator.
  9565. * This is the main object responsible of generating shadows in the framework.
  9566. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9567. */
  9568. export class ShadowGenerator implements IShadowGenerator {
  9569. /**
  9570. * Shadow generator mode None: no filtering applied.
  9571. */
  9572. static readonly FILTER_NONE: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9576. */
  9577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9578. /**
  9579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9581. */
  9582. static readonly FILTER_POISSONSAMPLING: number;
  9583. /**
  9584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9590. * edge artifacts on steep falloff.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9596. * edge artifacts on steep falloff.
  9597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9598. */
  9599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9600. /**
  9601. * Shadow generator mode PCF: Percentage Closer Filtering
  9602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9604. */
  9605. static readonly FILTER_PCF: number;
  9606. /**
  9607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9609. * Contact Hardening
  9610. */
  9611. static readonly FILTER_PCSS: number;
  9612. /**
  9613. * Reserved for PCF and PCSS
  9614. * Highest Quality.
  9615. *
  9616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9617. *
  9618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9619. */
  9620. static readonly QUALITY_HIGH: number;
  9621. /**
  9622. * Reserved for PCF and PCSS
  9623. * Good tradeoff for quality/perf cross devices
  9624. *
  9625. * Execute PCF on a 3*3 kernel.
  9626. *
  9627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9628. */
  9629. static readonly QUALITY_MEDIUM: number;
  9630. /**
  9631. * Reserved for PCF and PCSS
  9632. * The lowest quality but the fastest.
  9633. *
  9634. * Execute PCF on a 1*1 kernel.
  9635. *
  9636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9637. */
  9638. static readonly QUALITY_LOW: number;
  9639. /** Gets or sets the custom shader name to use */
  9640. customShaderOptions: ICustomShaderOptions;
  9641. /**
  9642. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9643. */
  9644. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9645. private _bias;
  9646. /**
  9647. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9648. */
  9649. /**
  9650. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9651. */
  9652. bias: number;
  9653. private _normalBias;
  9654. /**
  9655. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9656. */
  9657. /**
  9658. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9659. */
  9660. normalBias: number;
  9661. private _blurBoxOffset;
  9662. /**
  9663. * Gets the blur box offset: offset applied during the blur pass.
  9664. * Only useful if useKernelBlur = false
  9665. */
  9666. /**
  9667. * Sets the blur box offset: offset applied during the blur pass.
  9668. * Only useful if useKernelBlur = false
  9669. */
  9670. blurBoxOffset: number;
  9671. private _blurScale;
  9672. /**
  9673. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9674. * 2 means half of the size.
  9675. */
  9676. /**
  9677. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9678. * 2 means half of the size.
  9679. */
  9680. blurScale: number;
  9681. private _blurKernel;
  9682. /**
  9683. * Gets the blur kernel: kernel size of the blur pass.
  9684. * Only useful if useKernelBlur = true
  9685. */
  9686. /**
  9687. * Sets the blur kernel: kernel size of the blur pass.
  9688. * Only useful if useKernelBlur = true
  9689. */
  9690. blurKernel: number;
  9691. private _useKernelBlur;
  9692. /**
  9693. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9694. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9695. */
  9696. /**
  9697. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9699. */
  9700. useKernelBlur: boolean;
  9701. private _depthScale;
  9702. /**
  9703. * Gets the depth scale used in ESM mode.
  9704. */
  9705. /**
  9706. * Sets the depth scale used in ESM mode.
  9707. * This can override the scale stored on the light.
  9708. */
  9709. depthScale: number;
  9710. private _filter;
  9711. /**
  9712. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9713. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9714. */
  9715. /**
  9716. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9717. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9718. */
  9719. filter: number;
  9720. /**
  9721. * Gets if the current filter is set to Poisson Sampling.
  9722. */
  9723. /**
  9724. * Sets the current filter to Poisson Sampling.
  9725. */
  9726. usePoissonSampling: boolean;
  9727. /**
  9728. * Gets if the current filter is set to ESM.
  9729. */
  9730. /**
  9731. * Sets the current filter is to ESM.
  9732. */
  9733. useExponentialShadowMap: boolean;
  9734. /**
  9735. * Gets if the current filter is set to filtered ESM.
  9736. */
  9737. /**
  9738. * Gets if the current filter is set to filtered ESM.
  9739. */
  9740. useBlurExponentialShadowMap: boolean;
  9741. /**
  9742. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9743. * exponential to prevent steep falloff artifacts).
  9744. */
  9745. /**
  9746. * Sets the current filter to "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. useCloseExponentialShadowMap: boolean;
  9750. /**
  9751. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9752. * exponential to prevent steep falloff artifacts).
  9753. */
  9754. /**
  9755. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9756. * exponential to prevent steep falloff artifacts).
  9757. */
  9758. useBlurCloseExponentialShadowMap: boolean;
  9759. /**
  9760. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9761. */
  9762. /**
  9763. * Sets the current filter to "PCF" (percentage closer filtering).
  9764. */
  9765. usePercentageCloserFiltering: boolean;
  9766. private _filteringQuality;
  9767. /**
  9768. * Gets the PCF or PCSS Quality.
  9769. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9770. */
  9771. /**
  9772. * Sets the PCF or PCSS Quality.
  9773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9774. */
  9775. filteringQuality: number;
  9776. /**
  9777. * Gets if the current filter is set to "PCSS" (contact hardening).
  9778. */
  9779. /**
  9780. * Sets the current filter to "PCSS" (contact hardening).
  9781. */
  9782. useContactHardeningShadow: boolean;
  9783. private _contactHardeningLightSizeUVRatio;
  9784. /**
  9785. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9786. * Using a ratio helps keeping shape stability independently of the map size.
  9787. *
  9788. * It does not account for the light projection as it was having too much
  9789. * instability during the light setup or during light position changes.
  9790. *
  9791. * Only valid if useContactHardeningShadow is true.
  9792. */
  9793. /**
  9794. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9795. * Using a ratio helps keeping shape stability independently of the map size.
  9796. *
  9797. * It does not account for the light projection as it was having too much
  9798. * instability during the light setup or during light position changes.
  9799. *
  9800. * Only valid if useContactHardeningShadow is true.
  9801. */
  9802. contactHardeningLightSizeUVRatio: number;
  9803. private _darkness;
  9804. /**
  9805. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9806. * 0 means strongest and 1 would means no shadow.
  9807. * @returns the darkness.
  9808. */
  9809. getDarkness(): number;
  9810. /**
  9811. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9812. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9813. * @returns the shadow generator allowing fluent coding.
  9814. */
  9815. setDarkness(darkness: number): ShadowGenerator;
  9816. private _transparencyShadow;
  9817. /**
  9818. * Sets the ability to have transparent shadow (boolean).
  9819. * @param transparent True if transparent else False
  9820. * @returns the shadow generator allowing fluent coding
  9821. */
  9822. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9823. private _shadowMap;
  9824. private _shadowMap2;
  9825. /**
  9826. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9827. * @returns The render target texture if present otherwise, null
  9828. */
  9829. getShadowMap(): Nullable<RenderTargetTexture>;
  9830. /**
  9831. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9832. * @returns The render target texture if the shadow map is present otherwise, null
  9833. */
  9834. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9835. /**
  9836. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9837. * @param mesh Mesh to add
  9838. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9839. * @returns the Shadow Generator itself
  9840. */
  9841. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9842. /**
  9843. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9844. * @param mesh Mesh to remove
  9845. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9846. * @returns the Shadow Generator itself
  9847. */
  9848. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9849. /**
  9850. * Controls the extent to which the shadows fade out at the edge of the frustum
  9851. * Used only by directionals and spots
  9852. */
  9853. frustumEdgeFalloff: number;
  9854. private _light;
  9855. /**
  9856. * Returns the associated light object.
  9857. * @returns the light generating the shadow
  9858. */
  9859. getLight(): IShadowLight;
  9860. /**
  9861. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9862. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9863. * It might on the other hand introduce peter panning.
  9864. */
  9865. forceBackFacesOnly: boolean;
  9866. private _scene;
  9867. private _lightDirection;
  9868. private _effect;
  9869. private _viewMatrix;
  9870. private _projectionMatrix;
  9871. private _transformMatrix;
  9872. private _cachedPosition;
  9873. private _cachedDirection;
  9874. private _cachedDefines;
  9875. private _currentRenderID;
  9876. private _boxBlurPostprocess;
  9877. private _kernelBlurXPostprocess;
  9878. private _kernelBlurYPostprocess;
  9879. private _blurPostProcesses;
  9880. private _mapSize;
  9881. private _currentFaceIndex;
  9882. private _currentFaceIndexCache;
  9883. private _textureType;
  9884. private _defaultTextureMatrix;
  9885. /** @hidden */
  9886. static _SceneComponentInitialization: (scene: Scene) => void;
  9887. /**
  9888. * Creates a ShadowGenerator object.
  9889. * A ShadowGenerator is the required tool to use the shadows.
  9890. * Each light casting shadows needs to use its own ShadowGenerator.
  9891. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9892. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9893. * @param light The light object generating the shadows.
  9894. * @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.
  9895. */
  9896. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9897. private _initializeGenerator;
  9898. private _initializeShadowMap;
  9899. private _initializeBlurRTTAndPostProcesses;
  9900. private _renderForShadowMap;
  9901. private _renderSubMeshForShadowMap;
  9902. private _applyFilterValues;
  9903. /**
  9904. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9905. * @param onCompiled Callback triggered at the and of the effects compilation
  9906. * @param options Sets of optional options forcing the compilation with different modes
  9907. */
  9908. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9909. useInstances: boolean;
  9910. }>): void;
  9911. /**
  9912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9913. * @param options Sets of optional options forcing the compilation with different modes
  9914. * @returns A promise that resolves when the compilation completes
  9915. */
  9916. forceCompilationAsync(options?: Partial<{
  9917. useInstances: boolean;
  9918. }>): Promise<void>;
  9919. /**
  9920. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9921. * @param subMesh The submesh we want to render in the shadow map
  9922. * @param useInstances Defines wether will draw in the map using instances
  9923. * @returns true if ready otherwise, false
  9924. */
  9925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9926. /**
  9927. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9928. * @param defines Defines of the material we want to update
  9929. * @param lightIndex Index of the light in the enabled light list of the material
  9930. */
  9931. prepareDefines(defines: any, lightIndex: number): void;
  9932. /**
  9933. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9934. * defined in the generator but impacting the effect).
  9935. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9936. * @param effect The effect we are binfing the information for
  9937. */
  9938. bindShadowLight(lightIndex: string, effect: Effect): void;
  9939. /**
  9940. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9941. * (eq to shadow prjection matrix * light transform matrix)
  9942. * @returns The transform matrix used to create the shadow map
  9943. */
  9944. getTransformMatrix(): Matrix;
  9945. /**
  9946. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9947. * Cube and 2D textures for instance.
  9948. */
  9949. recreateShadowMap(): void;
  9950. private _disposeBlurPostProcesses;
  9951. private _disposeRTTandPostProcesses;
  9952. /**
  9953. * Disposes the ShadowGenerator.
  9954. * Returns nothing.
  9955. */
  9956. dispose(): void;
  9957. /**
  9958. * Serializes the shadow generator setup to a json object.
  9959. * @returns The serialized JSON object
  9960. */
  9961. serialize(): any;
  9962. /**
  9963. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9964. * @param parsedShadowGenerator The JSON object to parse
  9965. * @param scene The scene to create the shadow map for
  9966. * @returns The parsed shadow generator
  9967. */
  9968. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9969. }
  9970. }
  9971. declare module "babylonjs/Lights/light" {
  9972. import { Nullable } from "babylonjs/types";
  9973. import { Scene } from "babylonjs/scene";
  9974. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9975. import { Node } from "babylonjs/node";
  9976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9977. import { Effect } from "babylonjs/Materials/effect";
  9978. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9979. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9980. /**
  9981. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9982. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9983. * 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.
  9984. */
  9985. export abstract class Light extends Node {
  9986. /**
  9987. * Falloff Default: light is falling off following the material specification:
  9988. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9989. */
  9990. static readonly FALLOFF_DEFAULT: number;
  9991. /**
  9992. * Falloff Physical: light is falling off following the inverse squared distance law.
  9993. */
  9994. static readonly FALLOFF_PHYSICAL: number;
  9995. /**
  9996. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9997. * to enhance interoperability with other engines.
  9998. */
  9999. static readonly FALLOFF_GLTF: number;
  10000. /**
  10001. * Falloff Standard: light is falling off like in the standard material
  10002. * to enhance interoperability with other materials.
  10003. */
  10004. static readonly FALLOFF_STANDARD: number;
  10005. /**
  10006. * If every light affecting the material is in this lightmapMode,
  10007. * material.lightmapTexture adds or multiplies
  10008. * (depends on material.useLightmapAsShadowmap)
  10009. * after every other light calculations.
  10010. */
  10011. static readonly LIGHTMAP_DEFAULT: number;
  10012. /**
  10013. * material.lightmapTexture as only diffuse lighting from this light
  10014. * adds only specular lighting from this light
  10015. * adds dynamic shadows
  10016. */
  10017. static readonly LIGHTMAP_SPECULAR: number;
  10018. /**
  10019. * material.lightmapTexture as only lighting
  10020. * no light calculation from this light
  10021. * only adds dynamic shadows from this light
  10022. */
  10023. static readonly LIGHTMAP_SHADOWSONLY: number;
  10024. /**
  10025. * Each light type uses the default quantity according to its type:
  10026. * point/spot lights use luminous intensity
  10027. * directional lights use illuminance
  10028. */
  10029. static readonly INTENSITYMODE_AUTOMATIC: number;
  10030. /**
  10031. * lumen (lm)
  10032. */
  10033. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10034. /**
  10035. * candela (lm/sr)
  10036. */
  10037. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10038. /**
  10039. * lux (lm/m^2)
  10040. */
  10041. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10042. /**
  10043. * nit (cd/m^2)
  10044. */
  10045. static readonly INTENSITYMODE_LUMINANCE: number;
  10046. /**
  10047. * Light type const id of the point light.
  10048. */
  10049. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10050. /**
  10051. * Light type const id of the directional light.
  10052. */
  10053. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10054. /**
  10055. * Light type const id of the spot light.
  10056. */
  10057. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10058. /**
  10059. * Light type const id of the hemispheric light.
  10060. */
  10061. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10062. /**
  10063. * Diffuse gives the basic color to an object.
  10064. */
  10065. diffuse: Color3;
  10066. /**
  10067. * Specular produces a highlight color on an object.
  10068. * Note: This is note affecting PBR materials.
  10069. */
  10070. specular: Color3;
  10071. /**
  10072. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10073. * falling off base on range or angle.
  10074. * This can be set to any values in Light.FALLOFF_x.
  10075. *
  10076. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10077. * other types of materials.
  10078. */
  10079. falloffType: number;
  10080. /**
  10081. * Strength of the light.
  10082. * Note: By default it is define in the framework own unit.
  10083. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10084. */
  10085. intensity: number;
  10086. private _range;
  10087. protected _inverseSquaredRange: number;
  10088. /**
  10089. * Defines how far from the source the light is impacting in scene units.
  10090. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10091. */
  10092. /**
  10093. * Defines how far from the source the light is impacting in scene units.
  10094. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10095. */
  10096. range: number;
  10097. /**
  10098. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10099. * of light.
  10100. */
  10101. private _photometricScale;
  10102. private _intensityMode;
  10103. /**
  10104. * Gets the photometric scale used to interpret the intensity.
  10105. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10106. */
  10107. /**
  10108. * Sets the photometric scale used to interpret the intensity.
  10109. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10110. */
  10111. intensityMode: number;
  10112. private _radius;
  10113. /**
  10114. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10115. */
  10116. /**
  10117. * sets the light radius used by PBR Materials to simulate soft area lights.
  10118. */
  10119. radius: number;
  10120. private _renderPriority;
  10121. /**
  10122. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10123. * exceeding the number allowed of the materials.
  10124. */
  10125. renderPriority: number;
  10126. private _shadowEnabled;
  10127. /**
  10128. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10129. * the current shadow generator.
  10130. */
  10131. /**
  10132. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10133. * the current shadow generator.
  10134. */
  10135. shadowEnabled: boolean;
  10136. private _includedOnlyMeshes;
  10137. /**
  10138. * Gets the only meshes impacted by this light.
  10139. */
  10140. /**
  10141. * Sets the only meshes impacted by this light.
  10142. */
  10143. includedOnlyMeshes: AbstractMesh[];
  10144. private _excludedMeshes;
  10145. /**
  10146. * Gets the meshes not impacted by this light.
  10147. */
  10148. /**
  10149. * Sets the meshes not impacted by this light.
  10150. */
  10151. excludedMeshes: AbstractMesh[];
  10152. private _excludeWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are not impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are not impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. excludeWithLayerMask: number;
  10162. private _includeOnlyWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. includeOnlyWithLayerMask: number;
  10172. private _lightmapMode;
  10173. /**
  10174. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10175. */
  10176. /**
  10177. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10178. */
  10179. lightmapMode: number;
  10180. /**
  10181. * Shadow generator associted to the light.
  10182. * @hidden Internal use only.
  10183. */
  10184. _shadowGenerator: Nullable<IShadowGenerator>;
  10185. /**
  10186. * @hidden Internal use only.
  10187. */
  10188. _excludedMeshesIds: string[];
  10189. /**
  10190. * @hidden Internal use only.
  10191. */
  10192. _includedOnlyMeshesIds: string[];
  10193. /**
  10194. * The current light unifom buffer.
  10195. * @hidden Internal use only.
  10196. */
  10197. _uniformBuffer: UniformBuffer;
  10198. /**
  10199. * Creates a Light object in the scene.
  10200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10201. * @param name The firendly name of the light
  10202. * @param scene The scene the light belongs too
  10203. */
  10204. constructor(name: string, scene: Scene);
  10205. protected abstract _buildUniformLayout(): void;
  10206. /**
  10207. * Sets the passed Effect "effect" with the Light information.
  10208. * @param effect The effect to update
  10209. * @param lightIndex The index of the light in the effect to update
  10210. * @returns The light
  10211. */
  10212. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10213. /**
  10214. * Returns the string "Light".
  10215. * @returns the class name
  10216. */
  10217. getClassName(): string;
  10218. /** @hidden */
  10219. readonly _isLight: boolean;
  10220. /**
  10221. * Converts the light information to a readable string for debug purpose.
  10222. * @param fullDetails Supports for multiple levels of logging within scene loading
  10223. * @returns the human readable light info
  10224. */
  10225. toString(fullDetails?: boolean): string;
  10226. /** @hidden */
  10227. protected _syncParentEnabledState(): void;
  10228. /**
  10229. * Set the enabled state of this node.
  10230. * @param value - the new enabled state
  10231. */
  10232. setEnabled(value: boolean): void;
  10233. /**
  10234. * Returns the Light associated shadow generator if any.
  10235. * @return the associated shadow generator.
  10236. */
  10237. getShadowGenerator(): Nullable<IShadowGenerator>;
  10238. /**
  10239. * Returns a Vector3, the absolute light position in the World.
  10240. * @returns the world space position of the light
  10241. */
  10242. getAbsolutePosition(): Vector3;
  10243. /**
  10244. * Specifies if the light will affect the passed mesh.
  10245. * @param mesh The mesh to test against the light
  10246. * @return true the mesh is affected otherwise, false.
  10247. */
  10248. canAffectMesh(mesh: AbstractMesh): boolean;
  10249. /**
  10250. * Sort function to order lights for rendering.
  10251. * @param a First Light object to compare to second.
  10252. * @param b Second Light object to compare first.
  10253. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10254. */
  10255. static CompareLightsPriority(a: Light, b: Light): number;
  10256. /**
  10257. * Releases resources associated with this node.
  10258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10260. */
  10261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10262. /**
  10263. * Returns the light type ID (integer).
  10264. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10265. */
  10266. getTypeID(): number;
  10267. /**
  10268. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10269. * @returns the scaled intensity in intensity mode unit
  10270. */
  10271. getScaledIntensity(): number;
  10272. /**
  10273. * Returns a new Light object, named "name", from the current one.
  10274. * @param name The name of the cloned light
  10275. * @returns the new created light
  10276. */
  10277. clone(name: string): Nullable<Light>;
  10278. /**
  10279. * Serializes the current light into a Serialization object.
  10280. * @returns the serialized object.
  10281. */
  10282. serialize(): any;
  10283. /**
  10284. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10285. * This new light is named "name" and added to the passed scene.
  10286. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10287. * @param name The friendly name of the light
  10288. * @param scene The scene the new light will belong to
  10289. * @returns the constructor function
  10290. */
  10291. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10292. /**
  10293. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10294. * @param parsedLight The JSON representation of the light
  10295. * @param scene The scene to create the parsed light in
  10296. * @returns the created light after parsing
  10297. */
  10298. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10299. private _hookArrayForExcluded;
  10300. private _hookArrayForIncludedOnly;
  10301. private _resyncMeshes;
  10302. /**
  10303. * Forces the meshes to update their light related information in their rendering used effects
  10304. * @hidden Internal Use Only
  10305. */
  10306. _markMeshesAsLightDirty(): void;
  10307. /**
  10308. * Recomputes the cached photometric scale if needed.
  10309. */
  10310. private _computePhotometricScale;
  10311. /**
  10312. * Returns the Photometric Scale according to the light type and intensity mode.
  10313. */
  10314. private _getPhotometricScale;
  10315. /**
  10316. * Reorder the light in the scene according to their defined priority.
  10317. * @hidden Internal Use Only
  10318. */
  10319. _reorderLightsInScene(): void;
  10320. /**
  10321. * Prepares the list of defines specific to the light type.
  10322. * @param defines the list of defines
  10323. * @param lightIndex defines the index of the light for the effect
  10324. */
  10325. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10326. }
  10327. }
  10328. declare module "babylonjs/Actions/action" {
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Condition } from "babylonjs/Actions/condition";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. }
  10360. /**
  10361. * The action to be carried out following a trigger
  10362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10363. */
  10364. export class Action implements IAction {
  10365. /** the trigger, with or without parameters, for the action */
  10366. triggerOptions: any;
  10367. /**
  10368. * Trigger for the action
  10369. */
  10370. trigger: number;
  10371. /**
  10372. * Internal only - manager for action
  10373. * @hidden
  10374. */
  10375. _actionManager: ActionManager;
  10376. private _nextActiveAction;
  10377. private _child;
  10378. private _condition?;
  10379. private _triggerParameter;
  10380. /**
  10381. * An event triggered prior to action being executed.
  10382. */
  10383. onBeforeExecuteObservable: Observable<Action>;
  10384. /**
  10385. * Creates a new Action
  10386. * @param triggerOptions the trigger, with or without parameters, for the action
  10387. * @param condition an optional determinant of action
  10388. */
  10389. constructor(
  10390. /** the trigger, with or without parameters, for the action */
  10391. triggerOptions: any, condition?: Condition);
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _prepare(): void;
  10397. /**
  10398. * Gets the trigger parameters
  10399. * @returns the trigger parameters
  10400. */
  10401. getTriggerParameter(): any;
  10402. /**
  10403. * Internal only - executes current action event
  10404. * @hidden
  10405. */
  10406. _executeCurrent(evt?: ActionEvent): void;
  10407. /**
  10408. * Execute placeholder for child classes
  10409. * @param evt optional action event
  10410. */
  10411. execute(evt?: ActionEvent): void;
  10412. /**
  10413. * Skips to next active action
  10414. */
  10415. skipToNextActiveAction(): void;
  10416. /**
  10417. * Adds action to chain of actions, may be a DoNothingAction
  10418. * @param action defines the next action to execute
  10419. * @returns The action passed in
  10420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10421. */
  10422. then(action: Action): Action;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. _getProperty(propertyPath: string): string;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. _getEffectiveTarget(target: any, propertyPath: string): any;
  10433. /**
  10434. * Serialize placeholder for child classes
  10435. * @param parent of child
  10436. * @returns the serialized object
  10437. */
  10438. serialize(parent: any): any;
  10439. /**
  10440. * Internal only called by serialize
  10441. * @hidden
  10442. */
  10443. protected _serialize(serializedAction: any, parent?: any): any;
  10444. /**
  10445. * Internal only
  10446. * @hidden
  10447. */
  10448. static _SerializeValueAsString: (value: any) => string;
  10449. /**
  10450. * Internal only
  10451. * @hidden
  10452. */
  10453. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10454. name: string;
  10455. targetType: string;
  10456. value: string;
  10457. };
  10458. }
  10459. }
  10460. declare module "babylonjs/Actions/condition" {
  10461. import { ActionManager } from "babylonjs/Actions/actionManager";
  10462. /**
  10463. * A Condition applied to an Action
  10464. */
  10465. export class Condition {
  10466. /**
  10467. * Internal only - manager for action
  10468. * @hidden
  10469. */
  10470. _actionManager: ActionManager;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _evaluationId: number;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. _currentResult: boolean;
  10481. /**
  10482. * Creates a new Condition
  10483. * @param actionManager the manager of the action the condition is applied to
  10484. */
  10485. constructor(actionManager: ActionManager);
  10486. /**
  10487. * Check if the current condition is valid
  10488. * @returns a boolean
  10489. */
  10490. isValid(): boolean;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _getProperty(propertyPath: string): string;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _getEffectiveTarget(target: any, propertyPath: string): any;
  10501. /**
  10502. * Serialize placeholder for child classes
  10503. * @returns the serialized object
  10504. */
  10505. serialize(): any;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. protected _serialize(serializedCondition: any): any;
  10511. }
  10512. /**
  10513. * Defines specific conditional operators as extensions of Condition
  10514. */
  10515. export class ValueCondition extends Condition {
  10516. /** path to specify the property of the target the conditional operator uses */
  10517. propertyPath: string;
  10518. /** the value compared by the conditional operator against the current value of the property */
  10519. value: any;
  10520. /** the conditional operator, default ValueCondition.IsEqual */
  10521. operator: number;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. private static _IsEqual;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private static _IsDifferent;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsGreater;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private static _IsLesser;
  10542. /**
  10543. * returns the number for IsEqual
  10544. */
  10545. static readonly IsEqual: number;
  10546. /**
  10547. * Returns the number for IsDifferent
  10548. */
  10549. static readonly IsDifferent: number;
  10550. /**
  10551. * Returns the number for IsGreater
  10552. */
  10553. static readonly IsGreater: number;
  10554. /**
  10555. * Returns the number for IsLesser
  10556. */
  10557. static readonly IsLesser: number;
  10558. /**
  10559. * Internal only The action manager for the condition
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. /**
  10564. * Internal only
  10565. * @hidden
  10566. */
  10567. private _target;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */
  10572. private _effectiveTarget;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _property;
  10578. /**
  10579. * Creates a new ValueCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target for the action
  10582. * @param propertyPath path to specify the property of the target the conditional operator uses
  10583. * @param value the value compared by the conditional operator against the current value of the property
  10584. * @param operator the conditional operator, default ValueCondition.IsEqual
  10585. */
  10586. constructor(actionManager: ActionManager, target: any,
  10587. /** path to specify the property of the target the conditional operator uses */
  10588. propertyPath: string,
  10589. /** the value compared by the conditional operator against the current value of the property */
  10590. value: any,
  10591. /** the conditional operator, default ValueCondition.IsEqual */
  10592. operator?: number);
  10593. /**
  10594. * Compares the given value with the property value for the specified conditional operator
  10595. * @returns the result of the comparison
  10596. */
  10597. isValid(): boolean;
  10598. /**
  10599. * Serialize the ValueCondition into a JSON compatible object
  10600. * @returns serialization object
  10601. */
  10602. serialize(): any;
  10603. /**
  10604. * Gets the name of the conditional operator for the ValueCondition
  10605. * @param operator the conditional operator
  10606. * @returns the name
  10607. */
  10608. static GetOperatorName(operator: number): string;
  10609. }
  10610. /**
  10611. * Defines a predicate condition as an extension of Condition
  10612. */
  10613. export class PredicateCondition extends Condition {
  10614. /** defines the predicate function used to validate the condition */
  10615. predicate: () => boolean;
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */
  10620. _actionManager: ActionManager;
  10621. /**
  10622. * Creates a new PredicateCondition
  10623. * @param actionManager manager for the action the condition applies to
  10624. * @param predicate defines the predicate function used to validate the condition
  10625. */
  10626. constructor(actionManager: ActionManager,
  10627. /** defines the predicate function used to validate the condition */
  10628. predicate: () => boolean);
  10629. /**
  10630. * @returns the validity of the predicate condition
  10631. */
  10632. isValid(): boolean;
  10633. }
  10634. /**
  10635. * Defines a state condition as an extension of Condition
  10636. */
  10637. export class StateCondition extends Condition {
  10638. /** Value to compare with target state */
  10639. value: string;
  10640. /**
  10641. * Internal only - manager for action
  10642. * @hidden
  10643. */
  10644. _actionManager: ActionManager;
  10645. /**
  10646. * Internal only
  10647. * @hidden
  10648. */
  10649. private _target;
  10650. /**
  10651. * Creates a new StateCondition
  10652. * @param actionManager manager for the action the condition applies to
  10653. * @param target of the condition
  10654. * @param value to compare with target state
  10655. */
  10656. constructor(actionManager: ActionManager, target: any,
  10657. /** Value to compare with target state */
  10658. value: string);
  10659. /**
  10660. * Gets a boolean indicating if the current condition is met
  10661. * @returns the validity of the state
  10662. */
  10663. isValid(): boolean;
  10664. /**
  10665. * Serialize the StateCondition into a JSON compatible object
  10666. * @returns serialization object
  10667. */
  10668. serialize(): any;
  10669. }
  10670. }
  10671. declare module "babylonjs/Actions/directActions" {
  10672. import { Action } from "babylonjs/Actions/action";
  10673. import { Condition } from "babylonjs/Actions/condition";
  10674. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10675. /**
  10676. * This defines an action responsible to toggle a boolean once triggered.
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10678. */
  10679. export class SwitchBooleanAction extends Action {
  10680. /**
  10681. * The path to the boolean property in the target object
  10682. */
  10683. propertyPath: string;
  10684. private _target;
  10685. private _effectiveTarget;
  10686. private _property;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the object containing the boolean
  10691. * @param propertyPath defines the path to the boolean property in the target object
  10692. * @param condition defines the trigger related conditions
  10693. */
  10694. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10695. /** @hidden */
  10696. _prepare(): void;
  10697. /**
  10698. * Execute the action toggle the boolean value.
  10699. */
  10700. execute(): void;
  10701. /**
  10702. * Serializes the actions and its related information.
  10703. * @param parent defines the object to serialize in
  10704. * @returns the serialized object
  10705. */
  10706. serialize(parent: any): any;
  10707. }
  10708. /**
  10709. * This defines an action responsible to set a the state field of the target
  10710. * to a desired value once triggered.
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10712. */
  10713. export class SetStateAction extends Action {
  10714. /**
  10715. * The value to store in the state field.
  10716. */
  10717. value: string;
  10718. private _target;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the state property
  10723. * @param value defines the value to store in the state field
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10727. /**
  10728. * Execute the action and store the value on the target state property.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to set a property of the target
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class SetValueAction extends Action {
  10744. /**
  10745. * The path of the property to set in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value to set in the property
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to set in the target
  10760. * @param value defines the value to set in the property
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and set the targetted property to the desired value.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to increment the target value
  10779. * to a desired value once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class IncrementValueAction extends Action {
  10783. /**
  10784. * The path of the property to increment in the target.
  10785. */
  10786. propertyPath: string;
  10787. /**
  10788. * The value we should increment the property by.
  10789. */
  10790. value: any;
  10791. private _target;
  10792. private _effectiveTarget;
  10793. private _property;
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param target defines the object containing the property
  10798. * @param propertyPath defines the path of the property to increment in the target
  10799. * @param value defines the value value we should increment the property by
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10803. /** @hidden */
  10804. _prepare(): void;
  10805. /**
  10806. * Execute the action and increment the target of the value amount.
  10807. */
  10808. execute(): void;
  10809. /**
  10810. * Serializes the actions and its related information.
  10811. * @param parent defines the object to serialize in
  10812. * @returns the serialized object
  10813. */
  10814. serialize(parent: any): any;
  10815. }
  10816. /**
  10817. * This defines an action responsible to start an animation once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class PlayAnimationAction extends Action {
  10821. /**
  10822. * Where the animation should start (animation frame)
  10823. */
  10824. from: number;
  10825. /**
  10826. * Where the animation should stop (animation frame)
  10827. */
  10828. to: number;
  10829. /**
  10830. * Define if the animation should loop or stop after the first play.
  10831. */
  10832. loop?: boolean;
  10833. private _target;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the target animation or animation name
  10838. * @param from defines from where the animation should start (animation frame)
  10839. * @param end defines where the animation should stop (animation frame)
  10840. * @param loop defines if the animation should loop or stop after the first play
  10841. * @param condition defines the trigger related conditions
  10842. */
  10843. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10844. /** @hidden */
  10845. _prepare(): void;
  10846. /**
  10847. * Execute the action and play the animation.
  10848. */
  10849. execute(): void;
  10850. /**
  10851. * Serializes the actions and its related information.
  10852. * @param parent defines the object to serialize in
  10853. * @returns the serialized object
  10854. */
  10855. serialize(parent: any): any;
  10856. }
  10857. /**
  10858. * This defines an action responsible to stop an animation once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class StopAnimationAction extends Action {
  10862. private _target;
  10863. /**
  10864. * Instantiate the action
  10865. * @param triggerOptions defines the trigger options
  10866. * @param target defines the target animation or animation name
  10867. * @param condition defines the trigger related conditions
  10868. */
  10869. constructor(triggerOptions: any, target: any, condition?: Condition);
  10870. /** @hidden */
  10871. _prepare(): void;
  10872. /**
  10873. * Execute the action and stop the animation.
  10874. */
  10875. execute(): void;
  10876. /**
  10877. * Serializes the actions and its related information.
  10878. * @param parent defines the object to serialize in
  10879. * @returns the serialized object
  10880. */
  10881. serialize(parent: any): any;
  10882. }
  10883. /**
  10884. * This defines an action responsible that does nothing once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class DoNothingAction extends Action {
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param condition defines the trigger related conditions
  10892. */
  10893. constructor(triggerOptions?: any, condition?: Condition);
  10894. /**
  10895. * Execute the action and do nothing.
  10896. */
  10897. execute(): void;
  10898. /**
  10899. * Serializes the actions and its related information.
  10900. * @param parent defines the object to serialize in
  10901. * @returns the serialized object
  10902. */
  10903. serialize(parent: any): any;
  10904. }
  10905. /**
  10906. * This defines an action responsible to trigger several actions once triggered.
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10908. */
  10909. export class CombineAction extends Action {
  10910. /**
  10911. * The list of aggregated animations to run.
  10912. */
  10913. children: Action[];
  10914. /**
  10915. * Instantiate the action
  10916. * @param triggerOptions defines the trigger options
  10917. * @param children defines the list of aggregated animations to run
  10918. * @param condition defines the trigger related conditions
  10919. */
  10920. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10921. /** @hidden */
  10922. _prepare(): void;
  10923. /**
  10924. * Execute the action and executes all the aggregated actions.
  10925. */
  10926. execute(evt: ActionEvent): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to run code (external event) once triggered.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class ExecuteCodeAction extends Action {
  10939. /**
  10940. * The callback function to run.
  10941. */
  10942. func: (evt: ActionEvent) => void;
  10943. /**
  10944. * Instantiate the action
  10945. * @param triggerOptions defines the trigger options
  10946. * @param func defines the callback function to run
  10947. * @param condition defines the trigger related conditions
  10948. */
  10949. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10950. /**
  10951. * Execute the action and run the attached code.
  10952. */
  10953. execute(evt: ActionEvent): void;
  10954. }
  10955. /**
  10956. * This defines an action responsible to set the parent property of the target once triggered.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10958. */
  10959. export class SetParentAction extends Action {
  10960. private _parent;
  10961. private _target;
  10962. /**
  10963. * Instantiate the action
  10964. * @param triggerOptions defines the trigger options
  10965. * @param target defines the target containing the parent property
  10966. * @param parent defines from where the animation should start (animation frame)
  10967. * @param condition defines the trigger related conditions
  10968. */
  10969. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10970. /** @hidden */
  10971. _prepare(): void;
  10972. /**
  10973. * Execute the action and set the parent property.
  10974. */
  10975. execute(): void;
  10976. /**
  10977. * Serializes the actions and its related information.
  10978. * @param parent defines the object to serialize in
  10979. * @returns the serialized object
  10980. */
  10981. serialize(parent: any): any;
  10982. }
  10983. }
  10984. declare module "babylonjs/Actions/actionManager" {
  10985. import { Nullable } from "babylonjs/types";
  10986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10987. import { Scene } from "babylonjs/scene";
  10988. import { Action } from "babylonjs/Actions/action";
  10989. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10990. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10991. /**
  10992. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10993. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class ActionManager extends AbstractActionManager {
  10997. /**
  10998. * Nothing
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly NothingTrigger: number;
  11002. /**
  11003. * On pick
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnPickTrigger: number;
  11007. /**
  11008. * On left pick
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnLeftPickTrigger: number;
  11012. /**
  11013. * On right pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnRightPickTrigger: number;
  11017. /**
  11018. * On center pick
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnCenterPickTrigger: number;
  11022. /**
  11023. * On pick down
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickDownTrigger: number;
  11027. /**
  11028. * On double pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnDoublePickTrigger: number;
  11032. /**
  11033. * On pick up
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPickUpTrigger: number;
  11037. /**
  11038. * On pick out.
  11039. * This trigger will only be raised if you also declared a OnPickDown
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnPickOutTrigger: number;
  11043. /**
  11044. * On long press
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnLongPressTrigger: number;
  11048. /**
  11049. * On pointer over
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPointerOverTrigger: number;
  11053. /**
  11054. * On pointer out
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnPointerOutTrigger: number;
  11058. /**
  11059. * On every frame
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnEveryFrameTrigger: number;
  11063. /**
  11064. * On intersection enter
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnIntersectionEnterTrigger: number;
  11068. /**
  11069. * On intersection exit
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnIntersectionExitTrigger: number;
  11073. /**
  11074. * On key down
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnKeyDownTrigger: number;
  11078. /**
  11079. * On key up
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnKeyUpTrigger: number;
  11083. private _scene;
  11084. /**
  11085. * Creates a new action manager
  11086. * @param scene defines the hosting scene
  11087. */
  11088. constructor(scene: Scene);
  11089. /**
  11090. * Releases all associated resources
  11091. */
  11092. dispose(): void;
  11093. /**
  11094. * Gets hosting scene
  11095. * @returns the hosting scene
  11096. */
  11097. getScene(): Scene;
  11098. /**
  11099. * Does this action manager handles actions of any of the given triggers
  11100. * @param triggers defines the triggers to be tested
  11101. * @return a boolean indicating whether one (or more) of the triggers is handled
  11102. */
  11103. hasSpecificTriggers(triggers: number[]): boolean;
  11104. /**
  11105. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11106. * speed.
  11107. * @param triggerA defines the trigger to be tested
  11108. * @param triggerB defines the trigger to be tested
  11109. * @return a boolean indicating whether one (or more) of the triggers is handled
  11110. */
  11111. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11112. /**
  11113. * Does this action manager handles actions of a given trigger
  11114. * @param trigger defines the trigger to be tested
  11115. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11116. * @return whether the trigger is handled
  11117. */
  11118. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11119. /**
  11120. * Does this action manager has pointer triggers
  11121. */
  11122. readonly hasPointerTriggers: boolean;
  11123. /**
  11124. * Does this action manager has pick triggers
  11125. */
  11126. readonly hasPickTriggers: boolean;
  11127. /**
  11128. * Registers an action to this action manager
  11129. * @param action defines the action to be registered
  11130. * @return the action amended (prepared) after registration
  11131. */
  11132. registerAction(action: Action): Nullable<Action>;
  11133. /**
  11134. * Unregisters an action to this action manager
  11135. * @param action defines the action to be unregistered
  11136. * @return a boolean indicating whether the action has been unregistered
  11137. */
  11138. unregisterAction(action: Action): Boolean;
  11139. /**
  11140. * Process a specific trigger
  11141. * @param trigger defines the trigger to process
  11142. * @param evt defines the event details to be processed
  11143. */
  11144. processTrigger(trigger: number, evt?: IActionEvent): void;
  11145. /** @hidden */
  11146. _getEffectiveTarget(target: any, propertyPath: string): any;
  11147. /** @hidden */
  11148. _getProperty(propertyPath: string): string;
  11149. /**
  11150. * Serialize this manager to a JSON object
  11151. * @param name defines the property name to store this manager
  11152. * @returns a JSON representation of this manager
  11153. */
  11154. serialize(name: string): any;
  11155. /**
  11156. * Creates a new ActionManager from a JSON data
  11157. * @param parsedActions defines the JSON data to read from
  11158. * @param object defines the hosting mesh
  11159. * @param scene defines the hosting scene
  11160. */
  11161. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11162. /**
  11163. * Get a trigger name by index
  11164. * @param trigger defines the trigger index
  11165. * @returns a trigger name
  11166. */
  11167. static GetTriggerName(trigger: number): string;
  11168. }
  11169. }
  11170. declare module "babylonjs/Culling/ray" {
  11171. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11172. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11175. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11178. /**
  11179. * Class representing a ray with position and direction
  11180. */
  11181. export class Ray {
  11182. /** origin point */
  11183. origin: Vector3;
  11184. /** direction */
  11185. direction: Vector3;
  11186. /** length of the ray */
  11187. length: number;
  11188. private static readonly TmpVector3;
  11189. private _tmpRay;
  11190. /**
  11191. * Creates a new ray
  11192. * @param origin origin point
  11193. * @param direction direction
  11194. * @param length length of the ray
  11195. */
  11196. constructor(
  11197. /** origin point */
  11198. origin: Vector3,
  11199. /** direction */
  11200. direction: Vector3,
  11201. /** length of the ray */
  11202. length?: number);
  11203. /**
  11204. * Checks if the ray intersects a box
  11205. * @param minimum bound of the box
  11206. * @param maximum bound of the box
  11207. * @param intersectionTreshold extra extend to be added to the box in all direction
  11208. * @returns if the box was hit
  11209. */
  11210. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11211. /**
  11212. * Checks if the ray intersects a box
  11213. * @param box the bounding box to check
  11214. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11215. * @returns if the box was hit
  11216. */
  11217. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11218. /**
  11219. * If the ray hits a sphere
  11220. * @param sphere the bounding sphere to check
  11221. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11222. * @returns true if it hits the sphere
  11223. */
  11224. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11225. /**
  11226. * If the ray hits a triange
  11227. * @param vertex0 triangle vertex
  11228. * @param vertex1 triangle vertex
  11229. * @param vertex2 triangle vertex
  11230. * @returns intersection information if hit
  11231. */
  11232. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11233. /**
  11234. * Checks if ray intersects a plane
  11235. * @param plane the plane to check
  11236. * @returns the distance away it was hit
  11237. */
  11238. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11239. /**
  11240. * Checks if ray intersects a mesh
  11241. * @param mesh the mesh to check
  11242. * @param fastCheck if only the bounding box should checked
  11243. * @returns picking info of the intersecton
  11244. */
  11245. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11246. /**
  11247. * Checks if ray intersects a mesh
  11248. * @param meshes the meshes to check
  11249. * @param fastCheck if only the bounding box should checked
  11250. * @param results array to store result in
  11251. * @returns Array of picking infos
  11252. */
  11253. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11254. private _comparePickingInfo;
  11255. private static smallnum;
  11256. private static rayl;
  11257. /**
  11258. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11259. * @param sega the first point of the segment to test the intersection against
  11260. * @param segb the second point of the segment to test the intersection against
  11261. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11262. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11263. */
  11264. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11265. /**
  11266. * Update the ray from viewport position
  11267. * @param x position
  11268. * @param y y position
  11269. * @param viewportWidth viewport width
  11270. * @param viewportHeight viewport height
  11271. * @param world world matrix
  11272. * @param view view matrix
  11273. * @param projection projection matrix
  11274. * @returns this ray updated
  11275. */
  11276. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11277. /**
  11278. * Creates a ray with origin and direction of 0,0,0
  11279. * @returns the new ray
  11280. */
  11281. static Zero(): Ray;
  11282. /**
  11283. * Creates a new ray from screen space and viewport
  11284. * @param x position
  11285. * @param y y position
  11286. * @param viewportWidth viewport width
  11287. * @param viewportHeight viewport height
  11288. * @param world world matrix
  11289. * @param view view matrix
  11290. * @param projection projection matrix
  11291. * @returns new ray
  11292. */
  11293. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11294. /**
  11295. * 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
  11296. * transformed to the given world matrix.
  11297. * @param origin The origin point
  11298. * @param end The end point
  11299. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11300. * @returns the new ray
  11301. */
  11302. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Transforms a ray by a matrix
  11305. * @param ray ray to transform
  11306. * @param matrix matrix to apply
  11307. * @returns the resulting new ray
  11308. */
  11309. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Transforms a ray by a matrix
  11312. * @param ray ray to transform
  11313. * @param matrix matrix to apply
  11314. * @param result ray to store result in
  11315. */
  11316. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11317. /**
  11318. * Unproject a ray from screen space to object space
  11319. * @param sourceX defines the screen space x coordinate to use
  11320. * @param sourceY defines the screen space y coordinate to use
  11321. * @param viewportWidth defines the current width of the viewport
  11322. * @param viewportHeight defines the current height of the viewport
  11323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11324. * @param view defines the view matrix to use
  11325. * @param projection defines the projection matrix to use
  11326. */
  11327. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11328. }
  11329. module "babylonjs/scene" {
  11330. interface Scene {
  11331. /** @hidden */
  11332. _tempPickingRay: Nullable<Ray>;
  11333. /** @hidden */
  11334. _cachedRayForTransform: Ray;
  11335. /** @hidden */
  11336. _pickWithRayInverseMatrix: Matrix;
  11337. /** @hidden */
  11338. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /** @hidden */
  11340. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11341. }
  11342. }
  11343. }
  11344. declare module "babylonjs/sceneComponent" {
  11345. import { Scene } from "babylonjs/scene";
  11346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11348. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11349. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Camera } from "babylonjs/Cameras/camera";
  11352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11354. import { AbstractScene } from "babylonjs/abstractScene";
  11355. /**
  11356. * Groups all the scene component constants in one place to ease maintenance.
  11357. * @hidden
  11358. */
  11359. export class SceneComponentConstants {
  11360. static readonly NAME_EFFECTLAYER: string;
  11361. static readonly NAME_LAYER: string;
  11362. static readonly NAME_LENSFLARESYSTEM: string;
  11363. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11364. static readonly NAME_PARTICLESYSTEM: string;
  11365. static readonly NAME_GAMEPAD: string;
  11366. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11367. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11368. static readonly NAME_DEPTHRENDERER: string;
  11369. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11370. static readonly NAME_SPRITE: string;
  11371. static readonly NAME_OUTLINERENDERER: string;
  11372. static readonly NAME_PROCEDURALTEXTURE: string;
  11373. static readonly NAME_SHADOWGENERATOR: string;
  11374. static readonly NAME_OCTREE: string;
  11375. static readonly NAME_PHYSICSENGINE: string;
  11376. static readonly NAME_AUDIO: string;
  11377. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11378. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11379. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11380. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11381. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11382. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11383. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11384. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11385. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11386. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11387. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11388. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11389. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11390. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11391. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11392. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11393. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11394. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11395. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11396. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11397. static readonly STEP_AFTERRENDER_AUDIO: number;
  11398. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11399. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11400. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11401. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11402. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11403. static readonly STEP_POINTERMOVE_SPRITE: number;
  11404. static readonly STEP_POINTERDOWN_SPRITE: number;
  11405. static readonly STEP_POINTERUP_SPRITE: number;
  11406. }
  11407. /**
  11408. * This represents a scene component.
  11409. *
  11410. * This is used to decouple the dependency the scene is having on the different workloads like
  11411. * layers, post processes...
  11412. */
  11413. export interface ISceneComponent {
  11414. /**
  11415. * The name of the component. Each component must have a unique name.
  11416. */
  11417. name: string;
  11418. /**
  11419. * The scene the component belongs to.
  11420. */
  11421. scene: Scene;
  11422. /**
  11423. * Register the component to one instance of a scene.
  11424. */
  11425. register(): void;
  11426. /**
  11427. * Rebuilds the elements related to this component in case of
  11428. * context lost for instance.
  11429. */
  11430. rebuild(): void;
  11431. /**
  11432. * Disposes the component and the associated ressources.
  11433. */
  11434. dispose(): void;
  11435. }
  11436. /**
  11437. * This represents a SERIALIZABLE scene component.
  11438. *
  11439. * This extends Scene Component to add Serialization methods on top.
  11440. */
  11441. export interface ISceneSerializableComponent extends ISceneComponent {
  11442. /**
  11443. * Adds all the element from the container to the scene
  11444. * @param container the container holding the elements
  11445. */
  11446. addFromContainer(container: AbstractScene): void;
  11447. /**
  11448. * Removes all the elements in the container from the scene
  11449. * @param container contains the elements to remove
  11450. */
  11451. removeFromContainer(container: AbstractScene): void;
  11452. /**
  11453. * Serializes the component data to the specified json object
  11454. * @param serializationObject The object to serialize to
  11455. */
  11456. serialize(serializationObject: any): void;
  11457. }
  11458. /**
  11459. * Strong typing of a Mesh related stage step action
  11460. */
  11461. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11462. /**
  11463. * Strong typing of a Evaluate Sub Mesh related stage step action
  11464. */
  11465. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11466. /**
  11467. * Strong typing of a Active Mesh related stage step action
  11468. */
  11469. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11470. /**
  11471. * Strong typing of a Camera related stage step action
  11472. */
  11473. export type CameraStageAction = (camera: Camera) => void;
  11474. /**
  11475. * Strong typing of a Render Target related stage step action
  11476. */
  11477. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11478. /**
  11479. * Strong typing of a RenderingGroup related stage step action
  11480. */
  11481. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11482. /**
  11483. * Strong typing of a Mesh Render related stage step action
  11484. */
  11485. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11486. /**
  11487. * Strong typing of a simple stage step action
  11488. */
  11489. export type SimpleStageAction = () => void;
  11490. /**
  11491. * Strong typing of a render target action.
  11492. */
  11493. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11494. /**
  11495. * Strong typing of a pointer move action.
  11496. */
  11497. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11498. /**
  11499. * Strong typing of a pointer up/down action.
  11500. */
  11501. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11502. /**
  11503. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11504. * @hidden
  11505. */
  11506. export class Stage<T extends Function> extends Array<{
  11507. index: number;
  11508. component: ISceneComponent;
  11509. action: T;
  11510. }> {
  11511. /**
  11512. * Hide ctor from the rest of the world.
  11513. * @param items The items to add.
  11514. */
  11515. private constructor();
  11516. /**
  11517. * Creates a new Stage.
  11518. * @returns A new instance of a Stage
  11519. */
  11520. static Create<T extends Function>(): Stage<T>;
  11521. /**
  11522. * Registers a step in an ordered way in the targeted stage.
  11523. * @param index Defines the position to register the step in
  11524. * @param component Defines the component attached to the step
  11525. * @param action Defines the action to launch during the step
  11526. */
  11527. registerStep(index: number, component: ISceneComponent, action: T): void;
  11528. /**
  11529. * Clears all the steps from the stage.
  11530. */
  11531. clear(): void;
  11532. }
  11533. }
  11534. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11535. import { Nullable } from "babylonjs/types";
  11536. import { Observable } from "babylonjs/Misc/observable";
  11537. import { Scene } from "babylonjs/scene";
  11538. import { Sprite } from "babylonjs/Sprites/sprite";
  11539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11540. import { Ray } from "babylonjs/Culling/ray";
  11541. import { Camera } from "babylonjs/Cameras/camera";
  11542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11543. import { ISceneComponent } from "babylonjs/sceneComponent";
  11544. module "babylonjs/scene" {
  11545. interface Scene {
  11546. /** @hidden */
  11547. _pointerOverSprite: Nullable<Sprite>;
  11548. /** @hidden */
  11549. _pickedDownSprite: Nullable<Sprite>;
  11550. /** @hidden */
  11551. _tempSpritePickingRay: Nullable<Ray>;
  11552. /**
  11553. * All of the sprite managers added to this scene
  11554. * @see http://doc.babylonjs.com/babylon101/sprites
  11555. */
  11556. spriteManagers: Array<ISpriteManager>;
  11557. /**
  11558. * An event triggered when sprites rendering is about to start
  11559. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11560. */
  11561. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11562. /**
  11563. * An event triggered when sprites rendering is done
  11564. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11565. */
  11566. onAfterSpritesRenderingObservable: Observable<Scene>;
  11567. /** @hidden */
  11568. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11569. /** Launch a ray to try to pick a sprite in the scene
  11570. * @param x position on screen
  11571. * @param y position on screen
  11572. * @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
  11573. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11575. * @returns a PickingInfo
  11576. */
  11577. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11578. /** Use the given ray to pick a sprite in the scene
  11579. * @param ray The ray (in world space) to use to pick meshes
  11580. * @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
  11581. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11582. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11583. * @returns a PickingInfo
  11584. */
  11585. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11586. /**
  11587. * Force the sprite under the pointer
  11588. * @param sprite defines the sprite to use
  11589. */
  11590. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11591. /**
  11592. * Gets the sprite under the pointer
  11593. * @returns a Sprite or null if no sprite is under the pointer
  11594. */
  11595. getPointerOverSprite(): Nullable<Sprite>;
  11596. }
  11597. }
  11598. /**
  11599. * Defines the sprite scene component responsible to manage sprites
  11600. * in a given scene.
  11601. */
  11602. export class SpriteSceneComponent implements ISceneComponent {
  11603. /**
  11604. * The component name helpfull to identify the component in the list of scene components.
  11605. */
  11606. readonly name: string;
  11607. /**
  11608. * The scene the component belongs to.
  11609. */
  11610. scene: Scene;
  11611. /** @hidden */
  11612. private _spritePredicate;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _pickSpriteButKeepRay;
  11632. private _pointerMove;
  11633. private _pointerDown;
  11634. private _pointerUp;
  11635. }
  11636. }
  11637. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11638. /** @hidden */
  11639. export var fogFragmentDeclaration: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11645. /** @hidden */
  11646. export var fogFragment: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module "babylonjs/Shaders/sprites.fragment" {
  11652. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11653. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11654. /** @hidden */
  11655. export var spritesPixelShader: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11661. /** @hidden */
  11662. export var fogVertexDeclaration: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module "babylonjs/Shaders/sprites.vertex" {
  11668. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11669. /** @hidden */
  11670. export var spritesVertexShader: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module "babylonjs/Sprites/spriteManager" {
  11676. import { IDisposable, Scene } from "babylonjs/scene";
  11677. import { Nullable } from "babylonjs/types";
  11678. import { Observable } from "babylonjs/Misc/observable";
  11679. import { Sprite } from "babylonjs/Sprites/sprite";
  11680. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11681. import { Camera } from "babylonjs/Cameras/camera";
  11682. import { Texture } from "babylonjs/Materials/Textures/texture";
  11683. import "babylonjs/Shaders/sprites.fragment";
  11684. import "babylonjs/Shaders/sprites.vertex";
  11685. import { Ray } from "babylonjs/Culling/ray";
  11686. /**
  11687. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11688. */
  11689. export interface ISpriteManager extends IDisposable {
  11690. /**
  11691. * Restricts the camera to viewing objects with the same layerMask.
  11692. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11693. */
  11694. layerMask: number;
  11695. /**
  11696. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11697. */
  11698. isPickable: boolean;
  11699. /**
  11700. * Specifies the rendering group id for this mesh (0 by default)
  11701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11702. */
  11703. renderingGroupId: number;
  11704. /**
  11705. * Defines the list of sprites managed by the manager.
  11706. */
  11707. sprites: Array<Sprite>;
  11708. /**
  11709. * Tests the intersection of a sprite with a specific ray.
  11710. * @param ray The ray we are sending to test the collision
  11711. * @param camera The camera space we are sending rays in
  11712. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11713. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11714. * @returns picking info or null.
  11715. */
  11716. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11717. /**
  11718. * Renders the list of sprites on screen.
  11719. */
  11720. render(): void;
  11721. }
  11722. /**
  11723. * Class used to manage multiple sprites on the same spritesheet
  11724. * @see http://doc.babylonjs.com/babylon101/sprites
  11725. */
  11726. export class SpriteManager implements ISpriteManager {
  11727. /** defines the manager's name */
  11728. name: string;
  11729. /** Gets the list of sprites */
  11730. sprites: Sprite[];
  11731. /** Gets or sets the rendering group id (0 by default) */
  11732. renderingGroupId: number;
  11733. /** Gets or sets camera layer mask */
  11734. layerMask: number;
  11735. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11736. fogEnabled: boolean;
  11737. /** Gets or sets a boolean indicating if the sprites are pickable */
  11738. isPickable: boolean;
  11739. /** Defines the default width of a cell in the spritesheet */
  11740. cellWidth: number;
  11741. /** Defines the default height of a cell in the spritesheet */
  11742. cellHeight: number;
  11743. /**
  11744. * An event triggered when the manager is disposed.
  11745. */
  11746. onDisposeObservable: Observable<SpriteManager>;
  11747. private _onDisposeObserver;
  11748. /**
  11749. * Callback called when the manager is disposed
  11750. */
  11751. onDispose: () => void;
  11752. private _capacity;
  11753. private _spriteTexture;
  11754. private _epsilon;
  11755. private _scene;
  11756. private _vertexData;
  11757. private _buffer;
  11758. private _vertexBuffers;
  11759. private _indexBuffer;
  11760. private _effectBase;
  11761. private _effectFog;
  11762. /**
  11763. * Gets or sets the spritesheet texture
  11764. */
  11765. texture: Texture;
  11766. /**
  11767. * Creates a new sprite manager
  11768. * @param name defines the manager's name
  11769. * @param imgUrl defines the sprite sheet url
  11770. * @param capacity defines the maximum allowed number of sprites
  11771. * @param cellSize defines the size of a sprite cell
  11772. * @param scene defines the hosting scene
  11773. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11774. * @param samplingMode defines the smapling mode to use with spritesheet
  11775. */
  11776. constructor(
  11777. /** defines the manager's name */
  11778. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11779. private _appendSpriteVertex;
  11780. /**
  11781. * Intersects the sprites with a ray
  11782. * @param ray defines the ray to intersect with
  11783. * @param camera defines the current active camera
  11784. * @param predicate defines a predicate used to select candidate sprites
  11785. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11786. * @returns null if no hit or a PickingInfo
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Render all child sprites
  11791. */
  11792. render(): void;
  11793. /**
  11794. * Release associated resources
  11795. */
  11796. dispose(): void;
  11797. }
  11798. }
  11799. declare module "babylonjs/Sprites/sprite" {
  11800. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11801. import { Nullable } from "babylonjs/types";
  11802. import { ActionManager } from "babylonjs/Actions/actionManager";
  11803. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11804. /**
  11805. * Class used to represent a sprite
  11806. * @see http://doc.babylonjs.com/babylon101/sprites
  11807. */
  11808. export class Sprite {
  11809. /** defines the name */
  11810. name: string;
  11811. /** Gets or sets the current world position */
  11812. position: Vector3;
  11813. /** Gets or sets the main color */
  11814. color: Color4;
  11815. /** Gets or sets the width */
  11816. width: number;
  11817. /** Gets or sets the height */
  11818. height: number;
  11819. /** Gets or sets rotation angle */
  11820. angle: number;
  11821. /** Gets or sets the cell index in the sprite sheet */
  11822. cellIndex: number;
  11823. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11824. invertU: number;
  11825. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11826. invertV: number;
  11827. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11828. disposeWhenFinishedAnimating: boolean;
  11829. /** Gets the list of attached animations */
  11830. animations: Animation[];
  11831. /** Gets or sets a boolean indicating if the sprite can be picked */
  11832. isPickable: boolean;
  11833. /**
  11834. * Gets or sets the associated action manager
  11835. */
  11836. actionManager: Nullable<ActionManager>;
  11837. private _animationStarted;
  11838. private _loopAnimation;
  11839. private _fromIndex;
  11840. private _toIndex;
  11841. private _delay;
  11842. private _direction;
  11843. private _manager;
  11844. private _time;
  11845. private _onAnimationEnd;
  11846. /**
  11847. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11848. */
  11849. isVisible: boolean;
  11850. /**
  11851. * Gets or sets the sprite size
  11852. */
  11853. size: number;
  11854. /**
  11855. * Creates a new Sprite
  11856. * @param name defines the name
  11857. * @param manager defines the manager
  11858. */
  11859. constructor(
  11860. /** defines the name */
  11861. name: string, manager: ISpriteManager);
  11862. /**
  11863. * Starts an animation
  11864. * @param from defines the initial key
  11865. * @param to defines the end key
  11866. * @param loop defines if the animation must loop
  11867. * @param delay defines the start delay (in ms)
  11868. * @param onAnimationEnd defines a callback to call when animation ends
  11869. */
  11870. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11871. /** Stops current animation (if any) */
  11872. stopAnimation(): void;
  11873. /** @hidden */
  11874. _animate(deltaTime: number): void;
  11875. /** Release associated resources */
  11876. dispose(): void;
  11877. }
  11878. }
  11879. declare module "babylonjs/Collisions/pickingInfo" {
  11880. import { Nullable } from "babylonjs/types";
  11881. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11883. import { Sprite } from "babylonjs/Sprites/sprite";
  11884. import { Ray } from "babylonjs/Culling/ray";
  11885. /**
  11886. * Information about the result of picking within a scene
  11887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11888. */
  11889. export class PickingInfo {
  11890. /** @hidden */
  11891. _pickingUnavailable: boolean;
  11892. /**
  11893. * If the pick collided with an object
  11894. */
  11895. hit: boolean;
  11896. /**
  11897. * Distance away where the pick collided
  11898. */
  11899. distance: number;
  11900. /**
  11901. * The location of pick collision
  11902. */
  11903. pickedPoint: Nullable<Vector3>;
  11904. /**
  11905. * The mesh corresponding the the pick collision
  11906. */
  11907. pickedMesh: Nullable<AbstractMesh>;
  11908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11909. bu: number;
  11910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bv: number;
  11912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11913. faceId: number;
  11914. /** Id of the the submesh that was picked */
  11915. subMeshId: number;
  11916. /** If a sprite was picked, this will be the sprite the pick collided with */
  11917. pickedSprite: Nullable<Sprite>;
  11918. /**
  11919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11920. */
  11921. originMesh: Nullable<AbstractMesh>;
  11922. /**
  11923. * The ray that was used to perform the picking.
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Gets the normal correspodning to the face the pick collided with
  11928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11930. * @returns The normal correspodning to the face the pick collided with
  11931. */
  11932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11933. /**
  11934. * Gets the texture coordinates of where the pick occured
  11935. * @returns the vector containing the coordnates of the texture
  11936. */
  11937. getTextureCoordinates(): Nullable<Vector2>;
  11938. }
  11939. }
  11940. declare module "babylonjs/Events/pointerEvents" {
  11941. import { Nullable } from "babylonjs/types";
  11942. import { Vector2 } from "babylonjs/Maths/math";
  11943. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11944. import { Ray } from "babylonjs/Culling/ray";
  11945. /**
  11946. * Gather the list of pointer event types as constants.
  11947. */
  11948. export class PointerEventTypes {
  11949. /**
  11950. * 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.
  11951. */
  11952. static readonly POINTERDOWN: number;
  11953. /**
  11954. * The pointerup event is fired when a pointer is no longer active.
  11955. */
  11956. static readonly POINTERUP: number;
  11957. /**
  11958. * The pointermove event is fired when a pointer changes coordinates.
  11959. */
  11960. static readonly POINTERMOVE: number;
  11961. /**
  11962. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11963. */
  11964. static readonly POINTERWHEEL: number;
  11965. /**
  11966. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11967. */
  11968. static readonly POINTERPICK: number;
  11969. /**
  11970. * The pointertap event is fired when a the object has been touched and released without drag.
  11971. */
  11972. static readonly POINTERTAP: number;
  11973. /**
  11974. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11975. */
  11976. static readonly POINTERDOUBLETAP: number;
  11977. }
  11978. /**
  11979. * Base class of pointer info types.
  11980. */
  11981. export class PointerInfoBase {
  11982. /**
  11983. * Defines the type of event (PointerEventTypes)
  11984. */
  11985. type: number;
  11986. /**
  11987. * Defines the related dom event
  11988. */
  11989. event: PointerEvent | MouseWheelEvent;
  11990. /**
  11991. * Instantiates the base class of pointers info.
  11992. * @param type Defines the type of event (PointerEventTypes)
  11993. * @param event Defines the related dom event
  11994. */
  11995. constructor(
  11996. /**
  11997. * Defines the type of event (PointerEventTypes)
  11998. */
  11999. type: number,
  12000. /**
  12001. * Defines the related dom event
  12002. */
  12003. event: PointerEvent | MouseWheelEvent);
  12004. }
  12005. /**
  12006. * This class is used to store pointer related info for the onPrePointerObservable event.
  12007. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12008. */
  12009. export class PointerInfoPre extends PointerInfoBase {
  12010. /**
  12011. * Ray from a pointer if availible (eg. 6dof controller)
  12012. */
  12013. ray: Nullable<Ray>;
  12014. /**
  12015. * Defines the local position of the pointer on the canvas.
  12016. */
  12017. localPosition: Vector2;
  12018. /**
  12019. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12020. */
  12021. skipOnPointerObservable: boolean;
  12022. /**
  12023. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12024. * @param type Defines the type of event (PointerEventTypes)
  12025. * @param event Defines the related dom event
  12026. * @param localX Defines the local x coordinates of the pointer when the event occured
  12027. * @param localY Defines the local y coordinates of the pointer when the event occured
  12028. */
  12029. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12030. }
  12031. /**
  12032. * This type contains all the data related to a pointer event in Babylon.js.
  12033. * 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.
  12034. */
  12035. export class PointerInfo extends PointerInfoBase {
  12036. /**
  12037. * Defines the picking info associated to the info (if any)\
  12038. */
  12039. pickInfo: Nullable<PickingInfo>;
  12040. /**
  12041. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12042. * @param type Defines the type of event (PointerEventTypes)
  12043. * @param event Defines the related dom event
  12044. * @param pickInfo Defines the picking info associated to the info (if any)\
  12045. */
  12046. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12047. /**
  12048. * Defines the picking info associated to the info (if any)\
  12049. */
  12050. pickInfo: Nullable<PickingInfo>);
  12051. }
  12052. }
  12053. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12054. import { Nullable } from "babylonjs/types";
  12055. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12057. /**
  12058. * Manage the mouse inputs to control the movement of a free camera.
  12059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12060. */
  12061. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12062. /**
  12063. * Define if touch is enabled in the mouse input
  12064. */
  12065. touchEnabled: boolean;
  12066. /**
  12067. * Defines the camera the input is attached to.
  12068. */
  12069. camera: FreeCamera;
  12070. /**
  12071. * Defines the buttons associated with the input to handle camera move.
  12072. */
  12073. buttons: number[];
  12074. /**
  12075. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12076. */
  12077. angularSensibility: number;
  12078. private _pointerInput;
  12079. private _onMouseMove;
  12080. private _observer;
  12081. private previousPosition;
  12082. /**
  12083. * Manage the mouse inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. * @param touchEnabled Defines if touch is enabled or not
  12086. */
  12087. constructor(
  12088. /**
  12089. * Define if touch is enabled in the mouse input
  12090. */
  12091. touchEnabled?: boolean);
  12092. /**
  12093. * Attach the input controls to a specific dom element to get the input from.
  12094. * @param element Defines the element the controls should be listened from
  12095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12096. */
  12097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12098. /**
  12099. * Detach the current controls from the specified dom element.
  12100. * @param element Defines the element to stop listening the inputs from
  12101. */
  12102. detachControl(element: Nullable<HTMLElement>): void;
  12103. /**
  12104. * Gets the class name of the current intput.
  12105. * @returns the class name
  12106. */
  12107. getClassName(): string;
  12108. /**
  12109. * Get the friendly name associated with the input class.
  12110. * @returns the input friendly name
  12111. */
  12112. getSimpleName(): string;
  12113. }
  12114. }
  12115. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12116. import { Nullable } from "babylonjs/types";
  12117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12119. /**
  12120. * Manage the touch inputs to control the movement of a free camera.
  12121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12122. */
  12123. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12124. /**
  12125. * Defines the camera the input is attached to.
  12126. */
  12127. camera: FreeCamera;
  12128. /**
  12129. * Defines the touch sensibility for rotation.
  12130. * The higher the faster.
  12131. */
  12132. touchAngularSensibility: number;
  12133. /**
  12134. * Defines the touch sensibility for move.
  12135. * The higher the faster.
  12136. */
  12137. touchMoveSensibility: number;
  12138. private _offsetX;
  12139. private _offsetY;
  12140. private _pointerPressed;
  12141. private _pointerInput;
  12142. private _observer;
  12143. private _onLostFocus;
  12144. /**
  12145. * Attach the input controls to a specific dom element to get the input from.
  12146. * @param element Defines the element the controls should be listened from
  12147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12148. */
  12149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12150. /**
  12151. * Detach the current controls from the specified dom element.
  12152. * @param element Defines the element to stop listening the inputs from
  12153. */
  12154. detachControl(element: Nullable<HTMLElement>): void;
  12155. /**
  12156. * Update the current camera state depending on the inputs that have been used this frame.
  12157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12158. */
  12159. checkInputs(): void;
  12160. /**
  12161. * Gets the class name of the current intput.
  12162. * @returns the class name
  12163. */
  12164. getClassName(): string;
  12165. /**
  12166. * Get the friendly name associated with the input class.
  12167. * @returns the input friendly name
  12168. */
  12169. getSimpleName(): string;
  12170. }
  12171. }
  12172. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12174. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12175. /**
  12176. * Default Inputs manager for the FreeCamera.
  12177. * It groups all the default supported inputs for ease of use.
  12178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12179. */
  12180. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12181. /**
  12182. * Instantiates a new FreeCameraInputsManager.
  12183. * @param camera Defines the camera the inputs belong to
  12184. */
  12185. constructor(camera: FreeCamera);
  12186. /**
  12187. * Add keyboard input support to the input manager.
  12188. * @returns the current input manager
  12189. */
  12190. addKeyboard(): FreeCameraInputsManager;
  12191. /**
  12192. * Add mouse input support to the input manager.
  12193. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12194. * @returns the current input manager
  12195. */
  12196. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12197. /**
  12198. * Add touch input support to the input manager.
  12199. * @returns the current input manager
  12200. */
  12201. addTouch(): FreeCameraInputsManager;
  12202. }
  12203. }
  12204. declare module "babylonjs/Cameras/freeCamera" {
  12205. import { Vector3 } from "babylonjs/Maths/math";
  12206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12207. import { Scene } from "babylonjs/scene";
  12208. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12209. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. /**
  12245. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12246. * Higher values reduce sensitivity.
  12247. */
  12248. angularSensibility: number;
  12249. /**
  12250. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12251. */
  12252. keysUp: number[];
  12253. /**
  12254. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12255. */
  12256. keysDown: number[];
  12257. /**
  12258. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12259. */
  12260. keysLeft: number[];
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12263. */
  12264. keysRight: number[];
  12265. /**
  12266. * Event raised when the camera collide with a mesh in the scene.
  12267. */
  12268. onCollide: (collidedMesh: AbstractMesh) => void;
  12269. private _collider;
  12270. private _needMoveForGravity;
  12271. private _oldPosition;
  12272. private _diffPosition;
  12273. private _newPosition;
  12274. /** @hidden */
  12275. _localDirection: Vector3;
  12276. /** @hidden */
  12277. _transformedDirection: Vector3;
  12278. /**
  12279. * Instantiates a Free Camera.
  12280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12281. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12283. * @param name Define the name of the camera in the scene
  12284. * @param position Define the start position of the camera in the scene
  12285. * @param scene Define the scene the camera belongs to
  12286. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12287. */
  12288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12289. /**
  12290. * Attached controls to the current camera.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Detach the current controls from the camera.
  12297. * The camera will stop reacting to inputs.
  12298. * @param element Defines the element to stop listening the inputs from
  12299. */
  12300. detachControl(element: HTMLElement): void;
  12301. private _collisionMask;
  12302. /**
  12303. * Define a collision mask to limit the list of object the camera can collide with
  12304. */
  12305. collisionMask: number;
  12306. /** @hidden */
  12307. _collideWithWorld(displacement: Vector3): void;
  12308. private _onCollisionPositionChange;
  12309. /** @hidden */
  12310. _checkInputs(): void;
  12311. /** @hidden */
  12312. _decideIfNeedsToMove(): boolean;
  12313. /** @hidden */
  12314. _updatePosition(): void;
  12315. /**
  12316. * Destroy the camera and release the current resources hold by it.
  12317. */
  12318. dispose(): void;
  12319. /**
  12320. * Gets the current object class name.
  12321. * @return the class name
  12322. */
  12323. getClassName(): string;
  12324. }
  12325. }
  12326. declare module "babylonjs/Gamepads/gamepad" {
  12327. import { Observable } from "babylonjs/Misc/observable";
  12328. /**
  12329. * Represents a gamepad control stick position
  12330. */
  12331. export class StickValues {
  12332. /**
  12333. * The x component of the control stick
  12334. */
  12335. x: number;
  12336. /**
  12337. * The y component of the control stick
  12338. */
  12339. y: number;
  12340. /**
  12341. * Initializes the gamepad x and y control stick values
  12342. * @param x The x component of the gamepad control stick value
  12343. * @param y The y component of the gamepad control stick value
  12344. */
  12345. constructor(
  12346. /**
  12347. * The x component of the control stick
  12348. */
  12349. x: number,
  12350. /**
  12351. * The y component of the control stick
  12352. */
  12353. y: number);
  12354. }
  12355. /**
  12356. * An interface which manages callbacks for gamepad button changes
  12357. */
  12358. export interface GamepadButtonChanges {
  12359. /**
  12360. * Called when a gamepad has been changed
  12361. */
  12362. changed: boolean;
  12363. /**
  12364. * Called when a gamepad press event has been triggered
  12365. */
  12366. pressChanged: boolean;
  12367. /**
  12368. * Called when a touch event has been triggered
  12369. */
  12370. touchChanged: boolean;
  12371. /**
  12372. * Called when a value has changed
  12373. */
  12374. valueChanged: boolean;
  12375. }
  12376. /**
  12377. * Represents a gamepad
  12378. */
  12379. export class Gamepad {
  12380. /**
  12381. * The id of the gamepad
  12382. */
  12383. id: string;
  12384. /**
  12385. * The index of the gamepad
  12386. */
  12387. index: number;
  12388. /**
  12389. * The browser gamepad
  12390. */
  12391. browserGamepad: any;
  12392. /**
  12393. * Specifies what type of gamepad this represents
  12394. */
  12395. type: number;
  12396. private _leftStick;
  12397. private _rightStick;
  12398. /** @hidden */
  12399. _isConnected: boolean;
  12400. private _leftStickAxisX;
  12401. private _leftStickAxisY;
  12402. private _rightStickAxisX;
  12403. private _rightStickAxisY;
  12404. /**
  12405. * Triggered when the left control stick has been changed
  12406. */
  12407. private _onleftstickchanged;
  12408. /**
  12409. * Triggered when the right control stick has been changed
  12410. */
  12411. private _onrightstickchanged;
  12412. /**
  12413. * Represents a gamepad controller
  12414. */
  12415. static GAMEPAD: number;
  12416. /**
  12417. * Represents a generic controller
  12418. */
  12419. static GENERIC: number;
  12420. /**
  12421. * Represents an XBox controller
  12422. */
  12423. static XBOX: number;
  12424. /**
  12425. * Represents a pose-enabled controller
  12426. */
  12427. static POSE_ENABLED: number;
  12428. /**
  12429. * Specifies whether the left control stick should be Y-inverted
  12430. */
  12431. protected _invertLeftStickY: boolean;
  12432. /**
  12433. * Specifies if the gamepad has been connected
  12434. */
  12435. readonly isConnected: boolean;
  12436. /**
  12437. * Initializes the gamepad
  12438. * @param id The id of the gamepad
  12439. * @param index The index of the gamepad
  12440. * @param browserGamepad The browser gamepad
  12441. * @param leftStickX The x component of the left joystick
  12442. * @param leftStickY The y component of the left joystick
  12443. * @param rightStickX The x component of the right joystick
  12444. * @param rightStickY The y component of the right joystick
  12445. */
  12446. constructor(
  12447. /**
  12448. * The id of the gamepad
  12449. */
  12450. id: string,
  12451. /**
  12452. * The index of the gamepad
  12453. */
  12454. index: number,
  12455. /**
  12456. * The browser gamepad
  12457. */
  12458. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12459. /**
  12460. * Callback triggered when the left joystick has changed
  12461. * @param callback
  12462. */
  12463. onleftstickchanged(callback: (values: StickValues) => void): void;
  12464. /**
  12465. * Callback triggered when the right joystick has changed
  12466. * @param callback
  12467. */
  12468. onrightstickchanged(callback: (values: StickValues) => void): void;
  12469. /**
  12470. * Gets the left joystick
  12471. */
  12472. /**
  12473. * Sets the left joystick values
  12474. */
  12475. leftStick: StickValues;
  12476. /**
  12477. * Gets the right joystick
  12478. */
  12479. /**
  12480. * Sets the right joystick value
  12481. */
  12482. rightStick: StickValues;
  12483. /**
  12484. * Updates the gamepad joystick positions
  12485. */
  12486. update(): void;
  12487. /**
  12488. * Disposes the gamepad
  12489. */
  12490. dispose(): void;
  12491. }
  12492. /**
  12493. * Represents a generic gamepad
  12494. */
  12495. export class GenericPad extends Gamepad {
  12496. private _buttons;
  12497. private _onbuttondown;
  12498. private _onbuttonup;
  12499. /**
  12500. * Observable triggered when a button has been pressed
  12501. */
  12502. onButtonDownObservable: Observable<number>;
  12503. /**
  12504. * Observable triggered when a button has been released
  12505. */
  12506. onButtonUpObservable: Observable<number>;
  12507. /**
  12508. * Callback triggered when a button has been pressed
  12509. * @param callback Called when a button has been pressed
  12510. */
  12511. onbuttondown(callback: (buttonPressed: number) => void): void;
  12512. /**
  12513. * Callback triggered when a button has been released
  12514. * @param callback Called when a button has been released
  12515. */
  12516. onbuttonup(callback: (buttonReleased: number) => void): void;
  12517. /**
  12518. * Initializes the generic gamepad
  12519. * @param id The id of the generic gamepad
  12520. * @param index The index of the generic gamepad
  12521. * @param browserGamepad The browser gamepad
  12522. */
  12523. constructor(id: string, index: number, browserGamepad: any);
  12524. private _setButtonValue;
  12525. /**
  12526. * Updates the generic gamepad
  12527. */
  12528. update(): void;
  12529. /**
  12530. * Disposes the generic gamepad
  12531. */
  12532. dispose(): void;
  12533. }
  12534. }
  12535. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12536. import { Observable } from "babylonjs/Misc/observable";
  12537. import { Nullable } from "babylonjs/types";
  12538. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12541. import { Ray } from "babylonjs/Culling/ray";
  12542. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12543. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12544. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12545. /**
  12546. * Defines the types of pose enabled controllers that are supported
  12547. */
  12548. export enum PoseEnabledControllerType {
  12549. /**
  12550. * HTC Vive
  12551. */
  12552. VIVE = 0,
  12553. /**
  12554. * Oculus Rift
  12555. */
  12556. OCULUS = 1,
  12557. /**
  12558. * Windows mixed reality
  12559. */
  12560. WINDOWS = 2,
  12561. /**
  12562. * Samsung gear VR
  12563. */
  12564. GEAR_VR = 3,
  12565. /**
  12566. * Google Daydream
  12567. */
  12568. DAYDREAM = 4,
  12569. /**
  12570. * Generic
  12571. */
  12572. GENERIC = 5
  12573. }
  12574. /**
  12575. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12576. */
  12577. export interface MutableGamepadButton {
  12578. /**
  12579. * Value of the button/trigger
  12580. */
  12581. value: number;
  12582. /**
  12583. * If the button/trigger is currently touched
  12584. */
  12585. touched: boolean;
  12586. /**
  12587. * If the button/trigger is currently pressed
  12588. */
  12589. pressed: boolean;
  12590. }
  12591. /**
  12592. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12593. * @hidden
  12594. */
  12595. export interface ExtendedGamepadButton extends GamepadButton {
  12596. /**
  12597. * If the button/trigger is currently pressed
  12598. */
  12599. readonly pressed: boolean;
  12600. /**
  12601. * If the button/trigger is currently touched
  12602. */
  12603. readonly touched: boolean;
  12604. /**
  12605. * Value of the button/trigger
  12606. */
  12607. readonly value: number;
  12608. }
  12609. /** @hidden */
  12610. export interface _GamePadFactory {
  12611. /**
  12612. * Returns wether or not the current gamepad can be created for this type of controller.
  12613. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12614. * @returns true if it can be created, otherwise false
  12615. */
  12616. canCreate(gamepadInfo: any): boolean;
  12617. /**
  12618. * Creates a new instance of the Gamepad.
  12619. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12620. * @returns the new gamepad instance
  12621. */
  12622. create(gamepadInfo: any): Gamepad;
  12623. }
  12624. /**
  12625. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12626. */
  12627. export class PoseEnabledControllerHelper {
  12628. /** @hidden */
  12629. static _ControllerFactories: _GamePadFactory[];
  12630. /** @hidden */
  12631. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12632. /**
  12633. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12634. * @param vrGamepad the gamepad to initialized
  12635. * @returns a vr controller of the type the gamepad identified as
  12636. */
  12637. static InitiateController(vrGamepad: any): Gamepad;
  12638. }
  12639. /**
  12640. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12641. */
  12642. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12643. private _deviceRoomPosition;
  12644. private _deviceRoomRotationQuaternion;
  12645. /**
  12646. * The device position in babylon space
  12647. */
  12648. devicePosition: Vector3;
  12649. /**
  12650. * The device rotation in babylon space
  12651. */
  12652. deviceRotationQuaternion: Quaternion;
  12653. /**
  12654. * The scale factor of the device in babylon space
  12655. */
  12656. deviceScaleFactor: number;
  12657. /**
  12658. * (Likely devicePosition should be used instead) The device position in its room space
  12659. */
  12660. position: Vector3;
  12661. /**
  12662. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12663. */
  12664. rotationQuaternion: Quaternion;
  12665. /**
  12666. * The type of controller (Eg. Windows mixed reality)
  12667. */
  12668. controllerType: PoseEnabledControllerType;
  12669. protected _calculatedPosition: Vector3;
  12670. private _calculatedRotation;
  12671. /**
  12672. * The raw pose from the device
  12673. */
  12674. rawPose: DevicePose;
  12675. private _trackPosition;
  12676. private _maxRotationDistFromHeadset;
  12677. private _draggedRoomRotation;
  12678. /**
  12679. * @hidden
  12680. */
  12681. _disableTrackPosition(fixedPosition: Vector3): void;
  12682. /**
  12683. * Internal, the mesh attached to the controller
  12684. * @hidden
  12685. */
  12686. _mesh: Nullable<AbstractMesh>;
  12687. private _poseControlledCamera;
  12688. private _leftHandSystemQuaternion;
  12689. /**
  12690. * Internal, matrix used to convert room space to babylon space
  12691. * @hidden
  12692. */
  12693. _deviceToWorld: Matrix;
  12694. /**
  12695. * Node to be used when casting a ray from the controller
  12696. * @hidden
  12697. */
  12698. _pointingPoseNode: Nullable<TransformNode>;
  12699. /**
  12700. * Name of the child mesh that can be used to cast a ray from the controller
  12701. */
  12702. static readonly POINTING_POSE: string;
  12703. /**
  12704. * Creates a new PoseEnabledController from a gamepad
  12705. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12706. */
  12707. constructor(browserGamepad: any);
  12708. private _workingMatrix;
  12709. /**
  12710. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12711. */
  12712. update(): void;
  12713. /**
  12714. * Updates only the pose device and mesh without doing any button event checking
  12715. */
  12716. protected _updatePoseAndMesh(): void;
  12717. /**
  12718. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12719. * @param poseData raw pose fromthe device
  12720. */
  12721. updateFromDevice(poseData: DevicePose): void;
  12722. /**
  12723. * @hidden
  12724. */
  12725. _meshAttachedObservable: Observable<AbstractMesh>;
  12726. /**
  12727. * Attaches a mesh to the controller
  12728. * @param mesh the mesh to be attached
  12729. */
  12730. attachToMesh(mesh: AbstractMesh): void;
  12731. /**
  12732. * Attaches the controllers mesh to a camera
  12733. * @param camera the camera the mesh should be attached to
  12734. */
  12735. attachToPoseControlledCamera(camera: TargetCamera): void;
  12736. /**
  12737. * Disposes of the controller
  12738. */
  12739. dispose(): void;
  12740. /**
  12741. * The mesh that is attached to the controller
  12742. */
  12743. readonly mesh: Nullable<AbstractMesh>;
  12744. /**
  12745. * Gets the ray of the controller in the direction the controller is pointing
  12746. * @param length the length the resulting ray should be
  12747. * @returns a ray in the direction the controller is pointing
  12748. */
  12749. getForwardRay(length?: number): Ray;
  12750. }
  12751. }
  12752. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12753. import { Observable } from "babylonjs/Misc/observable";
  12754. import { Scene } from "babylonjs/scene";
  12755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12756. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12757. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12758. /**
  12759. * Defines the WebVRController object that represents controllers tracked in 3D space
  12760. */
  12761. export abstract class WebVRController extends PoseEnabledController {
  12762. /**
  12763. * Internal, the default controller model for the controller
  12764. */
  12765. protected _defaultModel: AbstractMesh;
  12766. /**
  12767. * Fired when the trigger state has changed
  12768. */
  12769. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12770. /**
  12771. * Fired when the main button state has changed
  12772. */
  12773. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12774. /**
  12775. * Fired when the secondary button state has changed
  12776. */
  12777. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12778. /**
  12779. * Fired when the pad state has changed
  12780. */
  12781. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12782. /**
  12783. * Fired when controllers stick values have changed
  12784. */
  12785. onPadValuesChangedObservable: Observable<StickValues>;
  12786. /**
  12787. * Array of button availible on the controller
  12788. */
  12789. protected _buttons: Array<MutableGamepadButton>;
  12790. private _onButtonStateChange;
  12791. /**
  12792. * Fired when a controller button's state has changed
  12793. * @param callback the callback containing the button that was modified
  12794. */
  12795. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12796. /**
  12797. * X and Y axis corrisponding to the controllers joystick
  12798. */
  12799. pad: StickValues;
  12800. /**
  12801. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12802. */
  12803. hand: string;
  12804. /**
  12805. * The default controller model for the controller
  12806. */
  12807. readonly defaultModel: AbstractMesh;
  12808. /**
  12809. * Creates a new WebVRController from a gamepad
  12810. * @param vrGamepad the gamepad that the WebVRController should be created from
  12811. */
  12812. constructor(vrGamepad: any);
  12813. /**
  12814. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12815. */
  12816. update(): void;
  12817. /**
  12818. * Function to be called when a button is modified
  12819. */
  12820. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12821. /**
  12822. * Loads a mesh and attaches it to the controller
  12823. * @param scene the scene the mesh should be added to
  12824. * @param meshLoaded callback for when the mesh has been loaded
  12825. */
  12826. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12827. private _setButtonValue;
  12828. private _changes;
  12829. private _checkChanges;
  12830. /**
  12831. * Disposes of th webVRCOntroller
  12832. */
  12833. dispose(): void;
  12834. }
  12835. }
  12836. declare module "babylonjs/Lights/hemisphericLight" {
  12837. import { Nullable } from "babylonjs/types";
  12838. import { Scene } from "babylonjs/scene";
  12839. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12840. import { Effect } from "babylonjs/Materials/effect";
  12841. import { Light } from "babylonjs/Lights/light";
  12842. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12843. /**
  12844. * The HemisphericLight simulates the ambient environment light,
  12845. * so the passed direction is the light reflection direction, not the incoming direction.
  12846. */
  12847. export class HemisphericLight extends Light {
  12848. /**
  12849. * The groundColor is the light in the opposite direction to the one specified during creation.
  12850. * 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.
  12851. */
  12852. groundColor: Color3;
  12853. /**
  12854. * The light reflection direction, not the incoming direction.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12859. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12860. * The HemisphericLight can't cast shadows.
  12861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12862. * @param name The friendly name of the light
  12863. * @param direction The direction of the light reflection
  12864. * @param scene The scene the light belongs to
  12865. */
  12866. constructor(name: string, direction: Vector3, scene: Scene);
  12867. protected _buildUniformLayout(): void;
  12868. /**
  12869. * Returns the string "HemisphericLight".
  12870. * @return The class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12875. * Returns the updated direction.
  12876. * @param target The target the direction should point to
  12877. * @return The computed direction
  12878. */
  12879. setDirectionToTarget(target: Vector3): Vector3;
  12880. /**
  12881. * Returns the shadow generator associated to the light.
  12882. * @returns Always null for hemispheric lights because it does not support shadows.
  12883. */
  12884. getShadowGenerator(): Nullable<IShadowGenerator>;
  12885. /**
  12886. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12887. * @param effect The effect to update
  12888. * @param lightIndex The index of the light in the effect to update
  12889. * @returns The hemispheric light
  12890. */
  12891. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12892. /**
  12893. * Computes the world matrix of the node
  12894. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12895. * @param useWasUpdatedFlag defines a reserved property
  12896. * @returns the world matrix
  12897. */
  12898. computeWorldMatrix(): Matrix;
  12899. /**
  12900. * Returns the integer 3.
  12901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12902. */
  12903. getTypeID(): number;
  12904. /**
  12905. * Prepares the list of defines specific to the light type.
  12906. * @param defines the list of defines
  12907. * @param lightIndex defines the index of the light for the effect
  12908. */
  12909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12910. }
  12911. }
  12912. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12913. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12914. import { Nullable } from "babylonjs/types";
  12915. import { Observable } from "babylonjs/Misc/observable";
  12916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12917. import { Scene } from "babylonjs/scene";
  12918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12920. import { Node } from "babylonjs/node";
  12921. import { Ray } from "babylonjs/Culling/ray";
  12922. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12923. /**
  12924. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12925. * IMPORTANT!! The data is right-hand data.
  12926. * @export
  12927. * @interface DevicePose
  12928. */
  12929. export interface DevicePose {
  12930. /**
  12931. * The position of the device, values in array are [x,y,z].
  12932. */
  12933. readonly position: Nullable<Float32Array>;
  12934. /**
  12935. * The linearVelocity of the device, values in array are [x,y,z].
  12936. */
  12937. readonly linearVelocity: Nullable<Float32Array>;
  12938. /**
  12939. * The linearAcceleration of the device, values in array are [x,y,z].
  12940. */
  12941. readonly linearAcceleration: Nullable<Float32Array>;
  12942. /**
  12943. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12944. */
  12945. readonly orientation: Nullable<Float32Array>;
  12946. /**
  12947. * The angularVelocity of the device, values in array are [x,y,z].
  12948. */
  12949. readonly angularVelocity: Nullable<Float32Array>;
  12950. /**
  12951. * The angularAcceleration of the device, values in array are [x,y,z].
  12952. */
  12953. readonly angularAcceleration: Nullable<Float32Array>;
  12954. }
  12955. /**
  12956. * Interface representing a pose controlled object in Babylon.
  12957. * A pose controlled object has both regular pose values as well as pose values
  12958. * from an external device such as a VR head mounted display
  12959. */
  12960. export interface PoseControlled {
  12961. /**
  12962. * The position of the object in babylon space.
  12963. */
  12964. position: Vector3;
  12965. /**
  12966. * The rotation quaternion of the object in babylon space.
  12967. */
  12968. rotationQuaternion: Quaternion;
  12969. /**
  12970. * The position of the device in babylon space.
  12971. */
  12972. devicePosition?: Vector3;
  12973. /**
  12974. * The rotation quaternion of the device in babylon space.
  12975. */
  12976. deviceRotationQuaternion: Quaternion;
  12977. /**
  12978. * The raw pose coming from the device.
  12979. */
  12980. rawPose: Nullable<DevicePose>;
  12981. /**
  12982. * The scale of the device to be used when translating from device space to babylon space.
  12983. */
  12984. deviceScaleFactor: number;
  12985. /**
  12986. * Updates the poseControlled values based on the input device pose.
  12987. * @param poseData the pose data to update the object with
  12988. */
  12989. updateFromDevice(poseData: DevicePose): void;
  12990. }
  12991. /**
  12992. * Set of options to customize the webVRCamera
  12993. */
  12994. export interface WebVROptions {
  12995. /**
  12996. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12997. */
  12998. trackPosition?: boolean;
  12999. /**
  13000. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13001. */
  13002. positionScale?: number;
  13003. /**
  13004. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13005. */
  13006. displayName?: string;
  13007. /**
  13008. * Should the native controller meshes be initialized. (default: true)
  13009. */
  13010. controllerMeshes?: boolean;
  13011. /**
  13012. * Creating a default HemiLight only on controllers. (default: true)
  13013. */
  13014. defaultLightingOnControllers?: boolean;
  13015. /**
  13016. * If you don't want to use the default VR button of the helper. (default: false)
  13017. */
  13018. useCustomVRButton?: boolean;
  13019. /**
  13020. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13021. */
  13022. customVRButton?: HTMLButtonElement;
  13023. /**
  13024. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13025. */
  13026. rayLength?: number;
  13027. /**
  13028. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13029. */
  13030. defaultHeight?: number;
  13031. }
  13032. /**
  13033. * This represents a WebVR camera.
  13034. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13035. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13036. */
  13037. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13038. private webVROptions;
  13039. /**
  13040. * @hidden
  13041. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13042. */
  13043. _vrDevice: any;
  13044. /**
  13045. * The rawPose of the vrDevice.
  13046. */
  13047. rawPose: Nullable<DevicePose>;
  13048. private _onVREnabled;
  13049. private _specsVersion;
  13050. private _attached;
  13051. private _frameData;
  13052. protected _descendants: Array<Node>;
  13053. private _deviceRoomPosition;
  13054. /** @hidden */
  13055. _deviceRoomRotationQuaternion: Quaternion;
  13056. private _standingMatrix;
  13057. /**
  13058. * Represents device position in babylon space.
  13059. */
  13060. devicePosition: Vector3;
  13061. /**
  13062. * Represents device rotation in babylon space.
  13063. */
  13064. deviceRotationQuaternion: Quaternion;
  13065. /**
  13066. * The scale of the device to be used when translating from device space to babylon space.
  13067. */
  13068. deviceScaleFactor: number;
  13069. private _deviceToWorld;
  13070. private _worldToDevice;
  13071. /**
  13072. * References to the webVR controllers for the vrDevice.
  13073. */
  13074. controllers: Array<WebVRController>;
  13075. /**
  13076. * Emits an event when a controller is attached.
  13077. */
  13078. onControllersAttachedObservable: Observable<WebVRController[]>;
  13079. /**
  13080. * Emits an event when a controller's mesh has been loaded;
  13081. */
  13082. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13083. /**
  13084. * Emits an event when the HMD's pose has been updated.
  13085. */
  13086. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13087. private _poseSet;
  13088. /**
  13089. * If the rig cameras be used as parent instead of this camera.
  13090. */
  13091. rigParenting: boolean;
  13092. private _lightOnControllers;
  13093. private _defaultHeight?;
  13094. /**
  13095. * Instantiates a WebVRFreeCamera.
  13096. * @param name The name of the WebVRFreeCamera
  13097. * @param position The starting anchor position for the camera
  13098. * @param scene The scene the camera belongs to
  13099. * @param webVROptions a set of customizable options for the webVRCamera
  13100. */
  13101. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13102. /**
  13103. * Gets the device distance from the ground in meters.
  13104. * @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.
  13105. */
  13106. deviceDistanceToRoomGround(): number;
  13107. /**
  13108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13109. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13110. */
  13111. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13112. /**
  13113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13114. * @returns A promise with a boolean set to if the standing matrix is supported.
  13115. */
  13116. useStandingMatrixAsync(): Promise<boolean>;
  13117. /**
  13118. * Disposes the camera
  13119. */
  13120. dispose(): void;
  13121. /**
  13122. * Gets a vrController by name.
  13123. * @param name The name of the controller to retreive
  13124. * @returns the controller matching the name specified or null if not found
  13125. */
  13126. getControllerByName(name: string): Nullable<WebVRController>;
  13127. private _leftController;
  13128. /**
  13129. * The controller corrisponding to the users left hand.
  13130. */
  13131. readonly leftController: Nullable<WebVRController>;
  13132. private _rightController;
  13133. /**
  13134. * The controller corrisponding to the users right hand.
  13135. */
  13136. readonly rightController: Nullable<WebVRController>;
  13137. /**
  13138. * Casts a ray forward from the vrCamera's gaze.
  13139. * @param length Length of the ray (default: 100)
  13140. * @returns the ray corrisponding to the gaze
  13141. */
  13142. getForwardRay(length?: number): Ray;
  13143. /**
  13144. * @hidden
  13145. * Updates the camera based on device's frame data
  13146. */
  13147. _checkInputs(): void;
  13148. /**
  13149. * Updates the poseControlled values based on the input device pose.
  13150. * @param poseData Pose coming from the device
  13151. */
  13152. updateFromDevice(poseData: DevicePose): void;
  13153. private _htmlElementAttached;
  13154. private _detachIfAttached;
  13155. /**
  13156. * WebVR's attach control will start broadcasting frames to the device.
  13157. * Note that in certain browsers (chrome for example) this function must be called
  13158. * within a user-interaction callback. Example:
  13159. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13160. *
  13161. * @param element html element to attach the vrDevice to
  13162. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13163. */
  13164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13165. /**
  13166. * Detaches the camera from the html element and disables VR
  13167. *
  13168. * @param element html element to detach from
  13169. */
  13170. detachControl(element: HTMLElement): void;
  13171. /**
  13172. * @returns the name of this class
  13173. */
  13174. getClassName(): string;
  13175. /**
  13176. * Calls resetPose on the vrDisplay
  13177. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13178. */
  13179. resetToCurrentRotation(): void;
  13180. /**
  13181. * @hidden
  13182. * Updates the rig cameras (left and right eye)
  13183. */
  13184. _updateRigCameras(): void;
  13185. private _workingVector;
  13186. private _oneVector;
  13187. private _workingMatrix;
  13188. private updateCacheCalled;
  13189. private _correctPositionIfNotTrackPosition;
  13190. /**
  13191. * @hidden
  13192. * Updates the cached values of the camera
  13193. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13194. */
  13195. _updateCache(ignoreParentClass?: boolean): void;
  13196. /**
  13197. * @hidden
  13198. * Get current device position in babylon world
  13199. */
  13200. _computeDevicePosition(): void;
  13201. /**
  13202. * Updates the current device position and rotation in the babylon world
  13203. */
  13204. update(): void;
  13205. /**
  13206. * @hidden
  13207. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13208. * @returns an identity matrix
  13209. */
  13210. _getViewMatrix(): Matrix;
  13211. private _tmpMatrix;
  13212. /**
  13213. * This function is called by the two RIG cameras.
  13214. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13215. * @hidden
  13216. */
  13217. _getWebVRViewMatrix(): Matrix;
  13218. /** @hidden */
  13219. _getWebVRProjectionMatrix(): Matrix;
  13220. private _onGamepadConnectedObserver;
  13221. private _onGamepadDisconnectedObserver;
  13222. private _updateCacheWhenTrackingDisabledObserver;
  13223. /**
  13224. * Initializes the controllers and their meshes
  13225. */
  13226. initControllers(): void;
  13227. }
  13228. }
  13229. declare module "babylonjs/PostProcesses/postProcess" {
  13230. import { Nullable } from "babylonjs/types";
  13231. import { SmartArray } from "babylonjs/Misc/smartArray";
  13232. import { Observable } from "babylonjs/Misc/observable";
  13233. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13234. import { Camera } from "babylonjs/Cameras/camera";
  13235. import { Effect } from "babylonjs/Materials/effect";
  13236. import "babylonjs/Shaders/postprocess.vertex";
  13237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13238. import { Engine } from "babylonjs/Engines/engine";
  13239. /**
  13240. * Size options for a post process
  13241. */
  13242. export type PostProcessOptions = {
  13243. width: number;
  13244. height: number;
  13245. };
  13246. /**
  13247. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13248. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13249. */
  13250. export class PostProcess {
  13251. /** Name of the PostProcess. */
  13252. name: string;
  13253. /**
  13254. * Gets or sets the unique id of the post process
  13255. */
  13256. uniqueId: number;
  13257. /**
  13258. * Width of the texture to apply the post process on
  13259. */
  13260. width: number;
  13261. /**
  13262. * Height of the texture to apply the post process on
  13263. */
  13264. height: number;
  13265. /**
  13266. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13267. * @hidden
  13268. */
  13269. _outputTexture: Nullable<InternalTexture>;
  13270. /**
  13271. * Sampling mode used by the shader
  13272. * See https://doc.babylonjs.com/classes/3.1/texture
  13273. */
  13274. renderTargetSamplingMode: number;
  13275. /**
  13276. * Clear color to use when screen clearing
  13277. */
  13278. clearColor: Color4;
  13279. /**
  13280. * If the buffer needs to be cleared before applying the post process. (default: true)
  13281. * Should be set to false if shader will overwrite all previous pixels.
  13282. */
  13283. autoClear: boolean;
  13284. /**
  13285. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13286. */
  13287. alphaMode: number;
  13288. /**
  13289. * Sets the setAlphaBlendConstants of the babylon engine
  13290. */
  13291. alphaConstants: Color4;
  13292. /**
  13293. * Animations to be used for the post processing
  13294. */
  13295. animations: import("babylonjs/Animations/animation").Animation[];
  13296. /**
  13297. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13298. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13299. */
  13300. enablePixelPerfectMode: boolean;
  13301. /**
  13302. * Force the postprocess to be applied without taking in account viewport
  13303. */
  13304. forceFullscreenViewport: boolean;
  13305. /**
  13306. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13307. *
  13308. * | Value | Type | Description |
  13309. * | ----- | ----------------------------------- | ----------- |
  13310. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13311. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13312. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13313. *
  13314. */
  13315. scaleMode: number;
  13316. /**
  13317. * Force textures to be a power of two (default: false)
  13318. */
  13319. alwaysForcePOT: boolean;
  13320. private _samples;
  13321. /**
  13322. * Number of sample textures (default: 1)
  13323. */
  13324. samples: number;
  13325. /**
  13326. * Modify the scale of the post process to be the same as the viewport (default: false)
  13327. */
  13328. adaptScaleToCurrentViewport: boolean;
  13329. private _camera;
  13330. private _scene;
  13331. private _engine;
  13332. private _options;
  13333. private _reusable;
  13334. private _textureType;
  13335. /**
  13336. * Smart array of input and output textures for the post process.
  13337. * @hidden
  13338. */
  13339. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13340. /**
  13341. * The index in _textures that corresponds to the output texture.
  13342. * @hidden
  13343. */
  13344. _currentRenderTextureInd: number;
  13345. private _effect;
  13346. private _samplers;
  13347. private _fragmentUrl;
  13348. private _vertexUrl;
  13349. private _parameters;
  13350. private _scaleRatio;
  13351. protected _indexParameters: any;
  13352. private _shareOutputWithPostProcess;
  13353. private _texelSize;
  13354. private _forcedOutputTexture;
  13355. /**
  13356. * Returns the fragment url or shader name used in the post process.
  13357. * @returns the fragment url or name in the shader store.
  13358. */
  13359. getEffectName(): string;
  13360. /**
  13361. * An event triggered when the postprocess is activated.
  13362. */
  13363. onActivateObservable: Observable<Camera>;
  13364. private _onActivateObserver;
  13365. /**
  13366. * A function that is added to the onActivateObservable
  13367. */
  13368. onActivate: Nullable<(camera: Camera) => void>;
  13369. /**
  13370. * An event triggered when the postprocess changes its size.
  13371. */
  13372. onSizeChangedObservable: Observable<PostProcess>;
  13373. private _onSizeChangedObserver;
  13374. /**
  13375. * A function that is added to the onSizeChangedObservable
  13376. */
  13377. onSizeChanged: (postProcess: PostProcess) => void;
  13378. /**
  13379. * An event triggered when the postprocess applies its effect.
  13380. */
  13381. onApplyObservable: Observable<Effect>;
  13382. private _onApplyObserver;
  13383. /**
  13384. * A function that is added to the onApplyObservable
  13385. */
  13386. onApply: (effect: Effect) => void;
  13387. /**
  13388. * An event triggered before rendering the postprocess
  13389. */
  13390. onBeforeRenderObservable: Observable<Effect>;
  13391. private _onBeforeRenderObserver;
  13392. /**
  13393. * A function that is added to the onBeforeRenderObservable
  13394. */
  13395. onBeforeRender: (effect: Effect) => void;
  13396. /**
  13397. * An event triggered after rendering the postprocess
  13398. */
  13399. onAfterRenderObservable: Observable<Effect>;
  13400. private _onAfterRenderObserver;
  13401. /**
  13402. * A function that is added to the onAfterRenderObservable
  13403. */
  13404. onAfterRender: (efect: Effect) => void;
  13405. /**
  13406. * 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
  13407. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13408. */
  13409. inputTexture: InternalTexture;
  13410. /**
  13411. * Gets the camera which post process is applied to.
  13412. * @returns The camera the post process is applied to.
  13413. */
  13414. getCamera(): Camera;
  13415. /**
  13416. * Gets the texel size of the postprocess.
  13417. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13418. */
  13419. readonly texelSize: Vector2;
  13420. /**
  13421. * Creates a new instance PostProcess
  13422. * @param name The name of the PostProcess.
  13423. * @param fragmentUrl The url of the fragment shader to be used.
  13424. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13425. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13426. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13427. * @param camera The camera to apply the render pass to.
  13428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13429. * @param engine The engine which the post process will be applied. (default: current engine)
  13430. * @param reusable If the post process can be reused on the same frame. (default: false)
  13431. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13432. * @param textureType Type of textures used when performing the post process. (default: 0)
  13433. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13434. * @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
  13435. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13436. */
  13437. constructor(
  13438. /** Name of the PostProcess. */
  13439. 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);
  13440. /**
  13441. * Gets a string idenfifying the name of the class
  13442. * @returns "PostProcess" string
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Gets the engine which this post process belongs to.
  13447. * @returns The engine the post process was enabled with.
  13448. */
  13449. getEngine(): Engine;
  13450. /**
  13451. * The effect that is created when initializing the post process.
  13452. * @returns The created effect corrisponding the the postprocess.
  13453. */
  13454. getEffect(): Effect;
  13455. /**
  13456. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13457. * @param postProcess The post process to share the output with.
  13458. * @returns This post process.
  13459. */
  13460. shareOutputWith(postProcess: PostProcess): PostProcess;
  13461. /**
  13462. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13463. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13464. */
  13465. useOwnOutput(): void;
  13466. /**
  13467. * Updates the effect with the current post process compile time values and recompiles the shader.
  13468. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13469. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13470. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13471. * @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
  13472. * @param onCompiled Called when the shader has been compiled.
  13473. * @param onError Called if there is an error when compiling a shader.
  13474. */
  13475. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13476. /**
  13477. * The post process is reusable if it can be used multiple times within one frame.
  13478. * @returns If the post process is reusable
  13479. */
  13480. isReusable(): boolean;
  13481. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13482. markTextureDirty(): void;
  13483. /**
  13484. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13485. * 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.
  13486. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13487. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13488. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13489. * @returns The target texture that was bound to be written to.
  13490. */
  13491. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13492. /**
  13493. * If the post process is supported.
  13494. */
  13495. readonly isSupported: boolean;
  13496. /**
  13497. * The aspect ratio of the output texture.
  13498. */
  13499. readonly aspectRatio: number;
  13500. /**
  13501. * Get a value indicating if the post-process is ready to be used
  13502. * @returns true if the post-process is ready (shader is compiled)
  13503. */
  13504. isReady(): boolean;
  13505. /**
  13506. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13507. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13508. */
  13509. apply(): Nullable<Effect>;
  13510. private _disposeTextures;
  13511. /**
  13512. * Disposes the post process.
  13513. * @param camera The camera to dispose the post process on.
  13514. */
  13515. dispose(camera?: Camera): void;
  13516. }
  13517. }
  13518. declare module "babylonjs/PostProcesses/postProcessManager" {
  13519. import { Nullable } from "babylonjs/types";
  13520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13522. import { Scene } from "babylonjs/scene";
  13523. /**
  13524. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13525. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13526. */
  13527. export class PostProcessManager {
  13528. private _scene;
  13529. private _indexBuffer;
  13530. private _vertexBuffers;
  13531. /**
  13532. * Creates a new instance PostProcess
  13533. * @param scene The scene that the post process is associated with.
  13534. */
  13535. constructor(scene: Scene);
  13536. private _prepareBuffers;
  13537. private _buildIndexBuffer;
  13538. /**
  13539. * Rebuilds the vertex buffers of the manager.
  13540. * @hidden
  13541. */
  13542. _rebuild(): void;
  13543. /**
  13544. * Prepares a frame to be run through a post process.
  13545. * @param sourceTexture The input texture to the post procesess. (default: null)
  13546. * @param postProcesses An array of post processes to be run. (default: null)
  13547. * @returns True if the post processes were able to be run.
  13548. * @hidden
  13549. */
  13550. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13551. /**
  13552. * Manually render a set of post processes to a texture.
  13553. * @param postProcesses An array of post processes to be run.
  13554. * @param targetTexture The target texture to render to.
  13555. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13556. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13557. * @param lodLevel defines which lod of the texture to render to
  13558. */
  13559. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13560. /**
  13561. * Finalize the result of the output of the postprocesses.
  13562. * @param doNotPresent If true the result will not be displayed to the screen.
  13563. * @param targetTexture The target texture to render to.
  13564. * @param faceIndex The index of the face to bind the target texture to.
  13565. * @param postProcesses The array of post processes to render.
  13566. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13567. * @hidden
  13568. */
  13569. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13570. /**
  13571. * Disposes of the post process manager.
  13572. */
  13573. dispose(): void;
  13574. }
  13575. }
  13576. declare module "babylonjs/Layers/layerSceneComponent" {
  13577. import { Scene } from "babylonjs/scene";
  13578. import { ISceneComponent } from "babylonjs/sceneComponent";
  13579. import { Layer } from "babylonjs/Layers/layer";
  13580. module "babylonjs/abstractScene" {
  13581. interface AbstractScene {
  13582. /**
  13583. * The list of layers (background and foreground) of the scene
  13584. */
  13585. layers: Array<Layer>;
  13586. }
  13587. }
  13588. /**
  13589. * Defines the layer scene component responsible to manage any layers
  13590. * in a given scene.
  13591. */
  13592. export class LayerSceneComponent implements ISceneComponent {
  13593. /**
  13594. * The component name helpfull to identify the component in the list of scene components.
  13595. */
  13596. readonly name: string;
  13597. /**
  13598. * The scene the component belongs to.
  13599. */
  13600. scene: Scene;
  13601. private _engine;
  13602. /**
  13603. * Creates a new instance of the component for the given scene
  13604. * @param scene Defines the scene to register the component in
  13605. */
  13606. constructor(scene: Scene);
  13607. /**
  13608. * Registers the component in a given scene
  13609. */
  13610. register(): void;
  13611. /**
  13612. * Rebuilds the elements related to this component in case of
  13613. * context lost for instance.
  13614. */
  13615. rebuild(): void;
  13616. /**
  13617. * Disposes the component and the associated ressources.
  13618. */
  13619. dispose(): void;
  13620. private _draw;
  13621. private _drawCameraPredicate;
  13622. private _drawCameraBackground;
  13623. private _drawCameraForeground;
  13624. private _drawRenderTargetPredicate;
  13625. private _drawRenderTargetBackground;
  13626. private _drawRenderTargetForeground;
  13627. }
  13628. }
  13629. declare module "babylonjs/Shaders/layer.fragment" {
  13630. /** @hidden */
  13631. export var layerPixelShader: {
  13632. name: string;
  13633. shader: string;
  13634. };
  13635. }
  13636. declare module "babylonjs/Shaders/layer.vertex" {
  13637. /** @hidden */
  13638. export var layerVertexShader: {
  13639. name: string;
  13640. shader: string;
  13641. };
  13642. }
  13643. declare module "babylonjs/Layers/layer" {
  13644. import { Observable } from "babylonjs/Misc/observable";
  13645. import { Nullable } from "babylonjs/types";
  13646. import { Scene } from "babylonjs/scene";
  13647. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13648. import { Texture } from "babylonjs/Materials/Textures/texture";
  13649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13650. import "babylonjs/Shaders/layer.fragment";
  13651. import "babylonjs/Shaders/layer.vertex";
  13652. /**
  13653. * This represents a full screen 2d layer.
  13654. * This can be useful to display a picture in the background of your scene for instance.
  13655. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13656. */
  13657. export class Layer {
  13658. /**
  13659. * Define the name of the layer.
  13660. */
  13661. name: string;
  13662. /**
  13663. * Define the texture the layer should display.
  13664. */
  13665. texture: Nullable<Texture>;
  13666. /**
  13667. * Is the layer in background or foreground.
  13668. */
  13669. isBackground: boolean;
  13670. /**
  13671. * Define the color of the layer (instead of texture).
  13672. */
  13673. color: Color4;
  13674. /**
  13675. * Define the scale of the layer in order to zoom in out of the texture.
  13676. */
  13677. scale: Vector2;
  13678. /**
  13679. * Define an offset for the layer in order to shift the texture.
  13680. */
  13681. offset: Vector2;
  13682. /**
  13683. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13684. */
  13685. alphaBlendingMode: number;
  13686. /**
  13687. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13688. * Alpha test will not mix with the background color in case of transparency.
  13689. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13690. */
  13691. alphaTest: boolean;
  13692. /**
  13693. * Define a mask to restrict the layer to only some of the scene cameras.
  13694. */
  13695. layerMask: number;
  13696. /**
  13697. * Define the list of render target the layer is visible into.
  13698. */
  13699. renderTargetTextures: RenderTargetTexture[];
  13700. /**
  13701. * Define if the layer is only used in renderTarget or if it also
  13702. * renders in the main frame buffer of the canvas.
  13703. */
  13704. renderOnlyInRenderTargetTextures: boolean;
  13705. private _scene;
  13706. private _vertexBuffers;
  13707. private _indexBuffer;
  13708. private _effect;
  13709. private _alphaTestEffect;
  13710. /**
  13711. * An event triggered when the layer is disposed.
  13712. */
  13713. onDisposeObservable: Observable<Layer>;
  13714. private _onDisposeObserver;
  13715. /**
  13716. * Back compatibility with callback before the onDisposeObservable existed.
  13717. * The set callback will be triggered when the layer has been disposed.
  13718. */
  13719. onDispose: () => void;
  13720. /**
  13721. * An event triggered before rendering the scene
  13722. */
  13723. onBeforeRenderObservable: Observable<Layer>;
  13724. private _onBeforeRenderObserver;
  13725. /**
  13726. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13727. * The set callback will be triggered just before rendering the layer.
  13728. */
  13729. onBeforeRender: () => void;
  13730. /**
  13731. * An event triggered after rendering the scene
  13732. */
  13733. onAfterRenderObservable: Observable<Layer>;
  13734. private _onAfterRenderObserver;
  13735. /**
  13736. * Back compatibility with callback before the onAfterRenderObservable existed.
  13737. * The set callback will be triggered just after rendering the layer.
  13738. */
  13739. onAfterRender: () => void;
  13740. /**
  13741. * Instantiates a new layer.
  13742. * This represents a full screen 2d layer.
  13743. * This can be useful to display a picture in the background of your scene for instance.
  13744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13745. * @param name Define the name of the layer in the scene
  13746. * @param imgUrl Define the url of the texture to display in the layer
  13747. * @param scene Define the scene the layer belongs to
  13748. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13749. * @param color Defines a color for the layer
  13750. */
  13751. constructor(
  13752. /**
  13753. * Define the name of the layer.
  13754. */
  13755. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13756. private _createIndexBuffer;
  13757. /** @hidden */
  13758. _rebuild(): void;
  13759. /**
  13760. * Renders the layer in the scene.
  13761. */
  13762. render(): void;
  13763. /**
  13764. * Disposes and releases the associated ressources.
  13765. */
  13766. dispose(): void;
  13767. }
  13768. }
  13769. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13770. import { Scene } from "babylonjs/scene";
  13771. import { ISceneComponent } from "babylonjs/sceneComponent";
  13772. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13773. module "babylonjs/abstractScene" {
  13774. interface AbstractScene {
  13775. /**
  13776. * The list of procedural textures added to the scene
  13777. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13778. */
  13779. proceduralTextures: Array<ProceduralTexture>;
  13780. }
  13781. }
  13782. /**
  13783. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13784. * in a given scene.
  13785. */
  13786. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13787. /**
  13788. * The component name helpfull to identify the component in the list of scene components.
  13789. */
  13790. readonly name: string;
  13791. /**
  13792. * The scene the component belongs to.
  13793. */
  13794. scene: Scene;
  13795. /**
  13796. * Creates a new instance of the component for the given scene
  13797. * @param scene Defines the scene to register the component in
  13798. */
  13799. constructor(scene: Scene);
  13800. /**
  13801. * Registers the component in a given scene
  13802. */
  13803. register(): void;
  13804. /**
  13805. * Rebuilds the elements related to this component in case of
  13806. * context lost for instance.
  13807. */
  13808. rebuild(): void;
  13809. /**
  13810. * Disposes the component and the associated ressources.
  13811. */
  13812. dispose(): void;
  13813. private _beforeClear;
  13814. }
  13815. }
  13816. declare module "babylonjs/Shaders/procedural.vertex" {
  13817. /** @hidden */
  13818. export var proceduralVertexShader: {
  13819. name: string;
  13820. shader: string;
  13821. };
  13822. }
  13823. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13824. import { Observable } from "babylonjs/Misc/observable";
  13825. import { Nullable } from "babylonjs/types";
  13826. import { Scene } from "babylonjs/scene";
  13827. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13828. import { Effect } from "babylonjs/Materials/effect";
  13829. import { Texture } from "babylonjs/Materials/Textures/texture";
  13830. import "babylonjs/Shaders/procedural.vertex";
  13831. /**
  13832. * 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.
  13833. * This is the base class of any Procedural texture and contains most of the shareable code.
  13834. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13835. */
  13836. export class ProceduralTexture extends Texture {
  13837. isCube: boolean;
  13838. /**
  13839. * Define if the texture is enabled or not (disabled texture will not render)
  13840. */
  13841. isEnabled: boolean;
  13842. /**
  13843. * Define if the texture must be cleared before rendering (default is true)
  13844. */
  13845. autoClear: boolean;
  13846. /**
  13847. * Callback called when the texture is generated
  13848. */
  13849. onGenerated: () => void;
  13850. /**
  13851. * Event raised when the texture is generated
  13852. */
  13853. onGeneratedObservable: Observable<ProceduralTexture>;
  13854. /** @hidden */
  13855. _generateMipMaps: boolean;
  13856. /** @hidden **/
  13857. _effect: Effect;
  13858. /** @hidden */
  13859. _textures: {
  13860. [key: string]: Texture;
  13861. };
  13862. private _size;
  13863. private _currentRefreshId;
  13864. private _refreshRate;
  13865. private _vertexBuffers;
  13866. private _indexBuffer;
  13867. private _uniforms;
  13868. private _samplers;
  13869. private _fragment;
  13870. private _floats;
  13871. private _ints;
  13872. private _floatsArrays;
  13873. private _colors3;
  13874. private _colors4;
  13875. private _vectors2;
  13876. private _vectors3;
  13877. private _matrices;
  13878. private _fallbackTexture;
  13879. private _fallbackTextureUsed;
  13880. private _engine;
  13881. private _cachedDefines;
  13882. private _contentUpdateId;
  13883. private _contentData;
  13884. /**
  13885. * Instantiates a new procedural texture.
  13886. * 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.
  13887. * This is the base class of any Procedural texture and contains most of the shareable code.
  13888. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13889. * @param name Define the name of the texture
  13890. * @param size Define the size of the texture to create
  13891. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13892. * @param scene Define the scene the texture belongs to
  13893. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13894. * @param generateMipMaps Define if the texture should creates mip maps or not
  13895. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13896. */
  13897. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13898. /**
  13899. * The effect that is created when initializing the post process.
  13900. * @returns The created effect corrisponding the the postprocess.
  13901. */
  13902. getEffect(): Effect;
  13903. /**
  13904. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13905. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13906. */
  13907. getContent(): Nullable<ArrayBufferView>;
  13908. private _createIndexBuffer;
  13909. /** @hidden */
  13910. _rebuild(): void;
  13911. /**
  13912. * Resets the texture in order to recreate its associated resources.
  13913. * This can be called in case of context loss
  13914. */
  13915. reset(): void;
  13916. protected _getDefines(): string;
  13917. /**
  13918. * Is the texture ready to be used ? (rendered at least once)
  13919. * @returns true if ready, otherwise, false.
  13920. */
  13921. isReady(): boolean;
  13922. /**
  13923. * Resets the refresh counter of the texture and start bak from scratch.
  13924. * Could be useful to regenerate the texture if it is setup to render only once.
  13925. */
  13926. resetRefreshCounter(): void;
  13927. /**
  13928. * Set the fragment shader to use in order to render the texture.
  13929. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13930. */
  13931. setFragment(fragment: any): void;
  13932. /**
  13933. * Define the refresh rate of the texture or the rendering frequency.
  13934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13935. */
  13936. refreshRate: number;
  13937. /** @hidden */
  13938. _shouldRender(): boolean;
  13939. /**
  13940. * Get the size the texture is rendering at.
  13941. * @returns the size (texture is always squared)
  13942. */
  13943. getRenderSize(): number;
  13944. /**
  13945. * Resize the texture to new value.
  13946. * @param size Define the new size the texture should have
  13947. * @param generateMipMaps Define whether the new texture should create mip maps
  13948. */
  13949. resize(size: number, generateMipMaps: boolean): void;
  13950. private _checkUniform;
  13951. /**
  13952. * Set a texture in the shader program used to render.
  13953. * @param name Define the name of the uniform samplers as defined in the shader
  13954. * @param texture Define the texture to bind to this sampler
  13955. * @return the texture itself allowing "fluent" like uniform updates
  13956. */
  13957. setTexture(name: string, texture: Texture): ProceduralTexture;
  13958. /**
  13959. * Set a float in the shader.
  13960. * @param name Define the name of the uniform as defined in the shader
  13961. * @param value Define the value to give to the uniform
  13962. * @return the texture itself allowing "fluent" like uniform updates
  13963. */
  13964. setFloat(name: string, value: number): ProceduralTexture;
  13965. /**
  13966. * Set a int in the shader.
  13967. * @param name Define the name of the uniform as defined in the shader
  13968. * @param value Define the value to give to the uniform
  13969. * @return the texture itself allowing "fluent" like uniform updates
  13970. */
  13971. setInt(name: string, value: number): ProceduralTexture;
  13972. /**
  13973. * Set an array of floats in the shader.
  13974. * @param name Define the name of the uniform as defined in the shader
  13975. * @param value Define the value to give to the uniform
  13976. * @return the texture itself allowing "fluent" like uniform updates
  13977. */
  13978. setFloats(name: string, value: number[]): ProceduralTexture;
  13979. /**
  13980. * Set a vec3 in the shader from a Color3.
  13981. * @param name Define the name of the uniform as defined in the shader
  13982. * @param value Define the value to give to the uniform
  13983. * @return the texture itself allowing "fluent" like uniform updates
  13984. */
  13985. setColor3(name: string, value: Color3): ProceduralTexture;
  13986. /**
  13987. * Set a vec4 in the shader from a Color4.
  13988. * @param name Define the name of the uniform as defined in the shader
  13989. * @param value Define the value to give to the uniform
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setColor4(name: string, value: Color4): ProceduralTexture;
  13993. /**
  13994. * Set a vec2 in the shader from a Vector2.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setVector2(name: string, value: Vector2): ProceduralTexture;
  14000. /**
  14001. * Set a vec3 in the shader from a Vector3.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setVector3(name: string, value: Vector3): ProceduralTexture;
  14007. /**
  14008. * Set a mat4 in the shader from a MAtrix.
  14009. * @param name Define the name of the uniform as defined in the shader
  14010. * @param value Define the value to give to the uniform
  14011. * @return the texture itself allowing "fluent" like uniform updates
  14012. */
  14013. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14014. /**
  14015. * Render the texture to its associated render target.
  14016. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14017. */
  14018. render(useCameraPostProcess?: boolean): void;
  14019. /**
  14020. * Clone the texture.
  14021. * @returns the cloned texture
  14022. */
  14023. clone(): ProceduralTexture;
  14024. /**
  14025. * Dispose the texture and release its asoociated resources.
  14026. */
  14027. dispose(): void;
  14028. }
  14029. }
  14030. declare module "babylonjs/Particles/baseParticleSystem" {
  14031. import { Nullable } from "babylonjs/types";
  14032. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14034. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14035. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14036. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14037. import { Scene } from "babylonjs/scene";
  14038. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14039. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14040. import { Texture } from "babylonjs/Materials/Textures/texture";
  14041. import { Animation } from "babylonjs/Animations/animation";
  14042. /**
  14043. * This represents the base class for particle system in Babylon.
  14044. * 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.
  14045. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14046. * @example https://doc.babylonjs.com/babylon101/particles
  14047. */
  14048. export class BaseParticleSystem {
  14049. /**
  14050. * Source color is added to the destination color without alpha affecting the result
  14051. */
  14052. static BLENDMODE_ONEONE: number;
  14053. /**
  14054. * Blend current color and particle color using particle’s alpha
  14055. */
  14056. static BLENDMODE_STANDARD: number;
  14057. /**
  14058. * Add current color and particle color multiplied by particle’s alpha
  14059. */
  14060. static BLENDMODE_ADD: number;
  14061. /**
  14062. * Multiply current color with particle color
  14063. */
  14064. static BLENDMODE_MULTIPLY: number;
  14065. /**
  14066. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14067. */
  14068. static BLENDMODE_MULTIPLYADD: number;
  14069. /**
  14070. * List of animations used by the particle system.
  14071. */
  14072. animations: Animation[];
  14073. /**
  14074. * The id of the Particle system.
  14075. */
  14076. id: string;
  14077. /**
  14078. * The friendly name of the Particle system.
  14079. */
  14080. name: string;
  14081. /**
  14082. * The rendering group used by the Particle system to chose when to render.
  14083. */
  14084. renderingGroupId: number;
  14085. /**
  14086. * The emitter represents the Mesh or position we are attaching the particle system to.
  14087. */
  14088. emitter: Nullable<AbstractMesh | Vector3>;
  14089. /**
  14090. * The maximum number of particles to emit per frame
  14091. */
  14092. emitRate: number;
  14093. /**
  14094. * If you want to launch only a few particles at once, that can be done, as well.
  14095. */
  14096. manualEmitCount: number;
  14097. /**
  14098. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14099. */
  14100. updateSpeed: number;
  14101. /**
  14102. * The amount of time the particle system is running (depends of the overall update speed).
  14103. */
  14104. targetStopDuration: number;
  14105. /**
  14106. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14107. */
  14108. disposeOnStop: boolean;
  14109. /**
  14110. * Minimum power of emitting particles.
  14111. */
  14112. minEmitPower: number;
  14113. /**
  14114. * Maximum power of emitting particles.
  14115. */
  14116. maxEmitPower: number;
  14117. /**
  14118. * Minimum life time of emitting particles.
  14119. */
  14120. minLifeTime: number;
  14121. /**
  14122. * Maximum life time of emitting particles.
  14123. */
  14124. maxLifeTime: number;
  14125. /**
  14126. * Minimum Size of emitting particles.
  14127. */
  14128. minSize: number;
  14129. /**
  14130. * Maximum Size of emitting particles.
  14131. */
  14132. maxSize: number;
  14133. /**
  14134. * Minimum scale of emitting particles on X axis.
  14135. */
  14136. minScaleX: number;
  14137. /**
  14138. * Maximum scale of emitting particles on X axis.
  14139. */
  14140. maxScaleX: number;
  14141. /**
  14142. * Minimum scale of emitting particles on Y axis.
  14143. */
  14144. minScaleY: number;
  14145. /**
  14146. * Maximum scale of emitting particles on Y axis.
  14147. */
  14148. maxScaleY: number;
  14149. /**
  14150. * Gets or sets the minimal initial rotation in radians.
  14151. */
  14152. minInitialRotation: number;
  14153. /**
  14154. * Gets or sets the maximal initial rotation in radians.
  14155. */
  14156. maxInitialRotation: number;
  14157. /**
  14158. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14159. */
  14160. minAngularSpeed: number;
  14161. /**
  14162. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14163. */
  14164. maxAngularSpeed: number;
  14165. /**
  14166. * The texture used to render each particle. (this can be a spritesheet)
  14167. */
  14168. particleTexture: Nullable<Texture>;
  14169. /**
  14170. * The layer mask we are rendering the particles through.
  14171. */
  14172. layerMask: number;
  14173. /**
  14174. * This can help using your own shader to render the particle system.
  14175. * The according effect will be created
  14176. */
  14177. customShader: any;
  14178. /**
  14179. * By default particle system starts as soon as they are created. This prevents the
  14180. * automatic start to happen and let you decide when to start emitting particles.
  14181. */
  14182. preventAutoStart: boolean;
  14183. private _noiseTexture;
  14184. /**
  14185. * Gets or sets a texture used to add random noise to particle positions
  14186. */
  14187. noiseTexture: Nullable<ProceduralTexture>;
  14188. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14189. noiseStrength: Vector3;
  14190. /**
  14191. * Callback triggered when the particle animation is ending.
  14192. */
  14193. onAnimationEnd: Nullable<() => void>;
  14194. /**
  14195. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14196. */
  14197. blendMode: number;
  14198. /**
  14199. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14200. * to override the particles.
  14201. */
  14202. forceDepthWrite: boolean;
  14203. /** 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 */
  14204. preWarmCycles: number;
  14205. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14206. preWarmStepOffset: number;
  14207. /**
  14208. * 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)
  14209. */
  14210. spriteCellChangeSpeed: number;
  14211. /**
  14212. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14213. */
  14214. startSpriteCellID: number;
  14215. /**
  14216. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14217. */
  14218. endSpriteCellID: number;
  14219. /**
  14220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14221. */
  14222. spriteCellWidth: number;
  14223. /**
  14224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14225. */
  14226. spriteCellHeight: number;
  14227. /**
  14228. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14229. */
  14230. spriteRandomStartCell: boolean;
  14231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14232. translationPivot: Vector2;
  14233. /** @hidden */
  14234. protected _isAnimationSheetEnabled: boolean;
  14235. /**
  14236. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14237. */
  14238. beginAnimationOnStart: boolean;
  14239. /**
  14240. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14241. */
  14242. beginAnimationFrom: number;
  14243. /**
  14244. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14245. */
  14246. beginAnimationTo: number;
  14247. /**
  14248. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14249. */
  14250. beginAnimationLoop: boolean;
  14251. /**
  14252. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14253. */
  14254. isAnimationSheetEnabled: boolean;
  14255. /**
  14256. * Get hosting scene
  14257. * @returns the scene
  14258. */
  14259. getScene(): Scene;
  14260. /**
  14261. * You can use gravity if you want to give an orientation to your particles.
  14262. */
  14263. gravity: Vector3;
  14264. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14265. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14266. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14267. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14268. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14269. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14270. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14271. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14272. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14273. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14274. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14275. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14276. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14277. /**
  14278. * Defines the delay in milliseconds before starting the system (0 by default)
  14279. */
  14280. startDelay: number;
  14281. /**
  14282. * Gets the current list of drag gradients.
  14283. * You must use addDragGradient and removeDragGradient to udpate this list
  14284. * @returns the list of drag gradients
  14285. */
  14286. getDragGradients(): Nullable<Array<FactorGradient>>;
  14287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14288. limitVelocityDamping: number;
  14289. /**
  14290. * Gets the current list of limit velocity gradients.
  14291. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14292. * @returns the list of limit velocity gradients
  14293. */
  14294. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of color gradients.
  14297. * You must use addColorGradient and removeColorGradient to udpate this list
  14298. * @returns the list of color gradients
  14299. */
  14300. getColorGradients(): Nullable<Array<ColorGradient>>;
  14301. /**
  14302. * Gets the current list of size gradients.
  14303. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14304. * @returns the list of size gradients
  14305. */
  14306. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Gets the current list of color remap gradients.
  14309. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14310. * @returns the list of color remap gradients
  14311. */
  14312. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14313. /**
  14314. * Gets the current list of alpha remap gradients.
  14315. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14316. * @returns the list of alpha remap gradients
  14317. */
  14318. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14319. /**
  14320. * Gets the current list of life time gradients.
  14321. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14322. * @returns the list of life time gradients
  14323. */
  14324. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Gets the current list of angular speed gradients.
  14327. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14328. * @returns the list of angular speed gradients
  14329. */
  14330. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Gets the current list of velocity gradients.
  14333. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14334. * @returns the list of velocity gradients
  14335. */
  14336. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14337. /**
  14338. * Gets the current list of start size gradients.
  14339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14340. * @returns the list of start size gradients
  14341. */
  14342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Gets the current list of emit rate gradients.
  14345. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14346. * @returns the list of emit rate gradients
  14347. */
  14348. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14349. /**
  14350. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14352. */
  14353. direction1: Vector3;
  14354. /**
  14355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14356. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14357. */
  14358. direction2: Vector3;
  14359. /**
  14360. * 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.
  14361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14362. */
  14363. minEmitBox: Vector3;
  14364. /**
  14365. * 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.
  14366. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14367. */
  14368. maxEmitBox: Vector3;
  14369. /**
  14370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14371. */
  14372. color1: Color4;
  14373. /**
  14374. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14375. */
  14376. color2: Color4;
  14377. /**
  14378. * Color the particle will have at the end of its lifetime
  14379. */
  14380. colorDead: Color4;
  14381. /**
  14382. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14383. */
  14384. textureMask: Color4;
  14385. /**
  14386. * The particle emitter type defines the emitter used by the particle system.
  14387. * It can be for example box, sphere, or cone...
  14388. */
  14389. particleEmitterType: IParticleEmitterType;
  14390. /** @hidden */
  14391. _isSubEmitter: boolean;
  14392. /**
  14393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14395. */
  14396. billboardMode: number;
  14397. protected _isBillboardBased: boolean;
  14398. /**
  14399. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14400. */
  14401. isBillboardBased: boolean;
  14402. /**
  14403. * The scene the particle system belongs to.
  14404. */
  14405. protected _scene: Scene;
  14406. /**
  14407. * Local cache of defines for image processing.
  14408. */
  14409. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14410. /**
  14411. * Default configuration related to image processing available in the standard Material.
  14412. */
  14413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14414. /**
  14415. * Gets the image processing configuration used either in this material.
  14416. */
  14417. /**
  14418. * Sets the Default image processing configuration used either in the this material.
  14419. *
  14420. * If sets to null, the scene one is in use.
  14421. */
  14422. imageProcessingConfiguration: ImageProcessingConfiguration;
  14423. /**
  14424. * Attaches a new image processing configuration to the Standard Material.
  14425. * @param configuration
  14426. */
  14427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14428. /** @hidden */
  14429. protected _reset(): void;
  14430. /** @hidden */
  14431. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14432. /**
  14433. * Instantiates a particle system.
  14434. * 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.
  14435. * @param name The name of the particle system
  14436. */
  14437. constructor(name: string);
  14438. /**
  14439. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14442. * @returns the emitter
  14443. */
  14444. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14445. /**
  14446. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14447. * @param radius The radius of the hemisphere to emit from
  14448. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14449. * @returns the emitter
  14450. */
  14451. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14452. /**
  14453. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14454. * @param radius The radius of the sphere to emit from
  14455. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14456. * @returns the emitter
  14457. */
  14458. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14459. /**
  14460. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14461. * @param radius The radius of the sphere to emit from
  14462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14464. * @returns the emitter
  14465. */
  14466. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14467. /**
  14468. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14469. * @param radius The radius of the emission cylinder
  14470. * @param height The height of the emission cylinder
  14471. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14472. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14473. * @returns the emitter
  14474. */
  14475. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14476. /**
  14477. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14478. * @param radius The radius of the cylinder to emit from
  14479. * @param height The height of the emission cylinder
  14480. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14481. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14482. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14483. * @returns the emitter
  14484. */
  14485. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14486. /**
  14487. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14488. * @param radius The radius of the cone to emit from
  14489. * @param angle The base angle of the cone
  14490. * @returns the emitter
  14491. */
  14492. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14493. /**
  14494. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14498. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14499. * @returns the emitter
  14500. */
  14501. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14502. }
  14503. }
  14504. declare module "babylonjs/Particles/subEmitter" {
  14505. import { Scene } from "babylonjs/scene";
  14506. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14507. /**
  14508. * Type of sub emitter
  14509. */
  14510. export enum SubEmitterType {
  14511. /**
  14512. * Attached to the particle over it's lifetime
  14513. */
  14514. ATTACHED = 0,
  14515. /**
  14516. * Created when the particle dies
  14517. */
  14518. END = 1
  14519. }
  14520. /**
  14521. * Sub emitter class used to emit particles from an existing particle
  14522. */
  14523. export class SubEmitter {
  14524. /**
  14525. * the particle system to be used by the sub emitter
  14526. */
  14527. particleSystem: ParticleSystem;
  14528. /**
  14529. * Type of the submitter (Default: END)
  14530. */
  14531. type: SubEmitterType;
  14532. /**
  14533. * 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)
  14534. * Note: This only is supported when using an emitter of type Mesh
  14535. */
  14536. inheritDirection: boolean;
  14537. /**
  14538. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14539. */
  14540. inheritedVelocityAmount: number;
  14541. /**
  14542. * Creates a sub emitter
  14543. * @param particleSystem the particle system to be used by the sub emitter
  14544. */
  14545. constructor(
  14546. /**
  14547. * the particle system to be used by the sub emitter
  14548. */
  14549. particleSystem: ParticleSystem);
  14550. /**
  14551. * Clones the sub emitter
  14552. * @returns the cloned sub emitter
  14553. */
  14554. clone(): SubEmitter;
  14555. /**
  14556. * Serialize current object to a JSON object
  14557. * @returns the serialized object
  14558. */
  14559. serialize(): any;
  14560. /** @hidden */
  14561. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14562. /**
  14563. * Creates a new SubEmitter from a serialized JSON version
  14564. * @param serializationObject defines the JSON object to read from
  14565. * @param scene defines the hosting scene
  14566. * @param rootUrl defines the rootUrl for data loading
  14567. * @returns a new SubEmitter
  14568. */
  14569. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14570. /** Release associated resources */
  14571. dispose(): void;
  14572. }
  14573. }
  14574. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14575. /** @hidden */
  14576. export var clipPlaneFragmentDeclaration: {
  14577. name: string;
  14578. shader: string;
  14579. };
  14580. }
  14581. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14582. /** @hidden */
  14583. export var imageProcessingDeclaration: {
  14584. name: string;
  14585. shader: string;
  14586. };
  14587. }
  14588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14589. /** @hidden */
  14590. export var imageProcessingFunctions: {
  14591. name: string;
  14592. shader: string;
  14593. };
  14594. }
  14595. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14596. /** @hidden */
  14597. export var clipPlaneFragment: {
  14598. name: string;
  14599. shader: string;
  14600. };
  14601. }
  14602. declare module "babylonjs/Shaders/particles.fragment" {
  14603. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14608. /** @hidden */
  14609. export var particlesPixelShader: {
  14610. name: string;
  14611. shader: string;
  14612. };
  14613. }
  14614. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14615. /** @hidden */
  14616. export var clipPlaneVertexDeclaration: {
  14617. name: string;
  14618. shader: string;
  14619. };
  14620. }
  14621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14622. /** @hidden */
  14623. export var clipPlaneVertex: {
  14624. name: string;
  14625. shader: string;
  14626. };
  14627. }
  14628. declare module "babylonjs/Shaders/particles.vertex" {
  14629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14631. /** @hidden */
  14632. export var particlesVertexShader: {
  14633. name: string;
  14634. shader: string;
  14635. };
  14636. }
  14637. declare module "babylonjs/Particles/particleSystem" {
  14638. import { Nullable } from "babylonjs/types";
  14639. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14640. import { Observable } from "babylonjs/Misc/observable";
  14641. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14642. import { Effect } from "babylonjs/Materials/effect";
  14643. import { Scene, IDisposable } from "babylonjs/scene";
  14644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14645. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14646. import { Particle } from "babylonjs/Particles/particle";
  14647. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14648. import "babylonjs/Shaders/particles.fragment";
  14649. import "babylonjs/Shaders/particles.vertex";
  14650. /**
  14651. * This represents a particle system in Babylon.
  14652. * 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.
  14653. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14654. * @example https://doc.babylonjs.com/babylon101/particles
  14655. */
  14656. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14657. /**
  14658. * Billboard mode will only apply to Y axis
  14659. */
  14660. static readonly BILLBOARDMODE_Y: number;
  14661. /**
  14662. * Billboard mode will apply to all axes
  14663. */
  14664. static readonly BILLBOARDMODE_ALL: number;
  14665. /**
  14666. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14667. */
  14668. static readonly BILLBOARDMODE_STRETCHED: number;
  14669. /**
  14670. * This function can be defined to provide custom update for active particles.
  14671. * This function will be called instead of regular update (age, position, color, etc.).
  14672. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14673. */
  14674. updateFunction: (particles: Particle[]) => void;
  14675. private _emitterWorldMatrix;
  14676. /**
  14677. * This function can be defined to specify initial direction for every new particle.
  14678. * It by default use the emitterType defined function
  14679. */
  14680. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14681. /**
  14682. * This function can be defined to specify initial position for every new particle.
  14683. * It by default use the emitterType defined function
  14684. */
  14685. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14686. /**
  14687. * @hidden
  14688. */
  14689. _inheritedVelocityOffset: Vector3;
  14690. /**
  14691. * An event triggered when the system is disposed
  14692. */
  14693. onDisposeObservable: Observable<ParticleSystem>;
  14694. private _onDisposeObserver;
  14695. /**
  14696. * Sets a callback that will be triggered when the system is disposed
  14697. */
  14698. onDispose: () => void;
  14699. private _particles;
  14700. private _epsilon;
  14701. private _capacity;
  14702. private _stockParticles;
  14703. private _newPartsExcess;
  14704. private _vertexData;
  14705. private _vertexBuffer;
  14706. private _vertexBuffers;
  14707. private _spriteBuffer;
  14708. private _indexBuffer;
  14709. private _effect;
  14710. private _customEffect;
  14711. private _cachedDefines;
  14712. private _scaledColorStep;
  14713. private _colorDiff;
  14714. private _scaledDirection;
  14715. private _scaledGravity;
  14716. private _currentRenderId;
  14717. private _alive;
  14718. private _useInstancing;
  14719. private _started;
  14720. private _stopped;
  14721. private _actualFrame;
  14722. private _scaledUpdateSpeed;
  14723. private _vertexBufferSize;
  14724. /** @hidden */
  14725. _currentEmitRateGradient: Nullable<FactorGradient>;
  14726. /** @hidden */
  14727. _currentEmitRate1: number;
  14728. /** @hidden */
  14729. _currentEmitRate2: number;
  14730. /** @hidden */
  14731. _currentStartSizeGradient: Nullable<FactorGradient>;
  14732. /** @hidden */
  14733. _currentStartSize1: number;
  14734. /** @hidden */
  14735. _currentStartSize2: number;
  14736. private readonly _rawTextureWidth;
  14737. private _rampGradientsTexture;
  14738. private _useRampGradients;
  14739. /** Gets or sets a boolean indicating that ramp gradients must be used
  14740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14741. */
  14742. useRampGradients: boolean;
  14743. /**
  14744. * 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.
  14745. * 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: [])
  14746. */
  14747. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14748. private _subEmitters;
  14749. /**
  14750. * @hidden
  14751. * If the particle systems emitter should be disposed when the particle system is disposed
  14752. */
  14753. _disposeEmitterOnDispose: boolean;
  14754. /**
  14755. * The current active Sub-systems, this property is used by the root particle system only.
  14756. */
  14757. activeSubSystems: Array<ParticleSystem>;
  14758. private _rootParticleSystem;
  14759. /**
  14760. * Gets the current list of active particles
  14761. */
  14762. readonly particles: Particle[];
  14763. /**
  14764. * Returns the string "ParticleSystem"
  14765. * @returns a string containing the class name
  14766. */
  14767. getClassName(): string;
  14768. /**
  14769. * Instantiates a particle system.
  14770. * 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.
  14771. * @param name The name of the particle system
  14772. * @param capacity The max number of particles alive at the same time
  14773. * @param scene The scene the particle system belongs to
  14774. * @param customEffect a custom effect used to change the way particles are rendered by default
  14775. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14776. * @param epsilon Offset used to render the particles
  14777. */
  14778. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14779. private _addFactorGradient;
  14780. private _removeFactorGradient;
  14781. /**
  14782. * Adds a new life time gradient
  14783. * @param gradient defines the gradient to use (between 0 and 1)
  14784. * @param factor defines the life time factor to affect to the specified gradient
  14785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14786. * @returns the current particle system
  14787. */
  14788. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14789. /**
  14790. * Remove a specific life time gradient
  14791. * @param gradient defines the gradient to remove
  14792. * @returns the current particle system
  14793. */
  14794. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14795. /**
  14796. * Adds a new size gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param factor defines the size factor to affect to the specified gradient
  14799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14800. * @returns the current particle system
  14801. */
  14802. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14803. /**
  14804. * Remove a specific size gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeSizeGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new color remap gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param min defines the color remap minimal range
  14813. * @param max defines the color remap maximal range
  14814. * @returns the current particle system
  14815. */
  14816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific color remap gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeColorRemapGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Adds a new alpha remap gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param min defines the alpha remap minimal range
  14827. * @param max defines the alpha remap maximal range
  14828. * @returns the current particle system
  14829. */
  14830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific alpha remap gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new angular speed gradient
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the angular speed to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific angular speed gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14851. /**
  14852. * Adds a new velocity gradient
  14853. * @param gradient defines the gradient to use (between 0 and 1)
  14854. * @param factor defines the velocity to affect to the specified gradient
  14855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14856. * @returns the current particle system
  14857. */
  14858. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14859. /**
  14860. * Remove a specific velocity gradient
  14861. * @param gradient defines the gradient to remove
  14862. * @returns the current particle system
  14863. */
  14864. removeVelocityGradient(gradient: number): IParticleSystem;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity value to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag value to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14895. * @param gradient defines the gradient to use (between 0 and 1)
  14896. * @param factor defines the emit rate value to affect to the specified gradient
  14897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14898. * @returns the current particle system
  14899. */
  14900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14901. /**
  14902. * Remove a specific emit rate gradient
  14903. * @param gradient defines the gradient to remove
  14904. * @returns the current particle system
  14905. */
  14906. removeEmitRateGradient(gradient: number): IParticleSystem;
  14907. /**
  14908. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param factor defines the start size value to affect to the specified gradient
  14911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14912. * @returns the current particle system
  14913. */
  14914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14915. /**
  14916. * Remove a specific start size gradient
  14917. * @param gradient defines the gradient to remove
  14918. * @returns the current particle system
  14919. */
  14920. removeStartSizeGradient(gradient: number): IParticleSystem;
  14921. private _createRampGradientTexture;
  14922. /**
  14923. * Gets the current list of ramp gradients.
  14924. * You must use addRampGradient and removeRampGradient to udpate this list
  14925. * @returns the list of ramp gradients
  14926. */
  14927. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14928. /**
  14929. * Adds a new ramp gradient used to remap particle colors
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param color defines the color to affect to the specified gradient
  14932. * @returns the current particle system
  14933. */
  14934. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14935. /**
  14936. * Remove a specific ramp gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeRampGradient(gradient: number): ParticleSystem;
  14941. /**
  14942. * Adds a new color gradient
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param color1 defines the color to affect to the specified gradient
  14945. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14946. * @returns this particle system
  14947. */
  14948. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14949. /**
  14950. * Remove a specific color gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns this particle system
  14953. */
  14954. removeColorGradient(gradient: number): IParticleSystem;
  14955. private _fetchR;
  14956. protected _reset(): void;
  14957. private _resetEffect;
  14958. private _createVertexBuffers;
  14959. private _createIndexBuffer;
  14960. /**
  14961. * Gets the maximum number of particles active at the same time.
  14962. * @returns The max number of active particles.
  14963. */
  14964. getCapacity(): number;
  14965. /**
  14966. * Gets whether there are still active particles in the system.
  14967. * @returns True if it is alive, otherwise false.
  14968. */
  14969. isAlive(): boolean;
  14970. /**
  14971. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14972. * @returns True if it has been started, otherwise false.
  14973. */
  14974. isStarted(): boolean;
  14975. private _prepareSubEmitterInternalArray;
  14976. /**
  14977. * Starts the particle system and begins to emit
  14978. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14979. */
  14980. start(delay?: number): void;
  14981. /**
  14982. * Stops the particle system.
  14983. * @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.
  14984. */
  14985. stop(stopSubEmitters?: boolean): void;
  14986. /**
  14987. * Remove all active particles
  14988. */
  14989. reset(): void;
  14990. /**
  14991. * @hidden (for internal use only)
  14992. */
  14993. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14994. /**
  14995. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14996. * Its lifetime will start back at 0.
  14997. */
  14998. recycleParticle: (particle: Particle) => void;
  14999. private _stopSubEmitters;
  15000. private _createParticle;
  15001. private _removeFromRoot;
  15002. private _emitFromParticle;
  15003. private _update;
  15004. /** @hidden */
  15005. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15006. /** @hidden */
  15007. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15008. /** @hidden */
  15009. private _getEffect;
  15010. /**
  15011. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15012. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15013. */
  15014. animate(preWarmOnly?: boolean): void;
  15015. private _appendParticleVertices;
  15016. /**
  15017. * Rebuilds the particle system.
  15018. */
  15019. rebuild(): void;
  15020. /**
  15021. * Is this system ready to be used/rendered
  15022. * @return true if the system is ready
  15023. */
  15024. isReady(): boolean;
  15025. private _render;
  15026. /**
  15027. * Renders the particle system in its current state.
  15028. * @returns the current number of particles
  15029. */
  15030. render(): number;
  15031. /**
  15032. * Disposes the particle system and free the associated resources
  15033. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15034. */
  15035. dispose(disposeTexture?: boolean): void;
  15036. /**
  15037. * Clones the particle system.
  15038. * @param name The name of the cloned object
  15039. * @param newEmitter The new emitter to use
  15040. * @returns the cloned particle system
  15041. */
  15042. clone(name: string, newEmitter: any): ParticleSystem;
  15043. /**
  15044. * Serializes the particle system to a JSON object.
  15045. * @returns the JSON object
  15046. */
  15047. serialize(): any;
  15048. /** @hidden */
  15049. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15050. /** @hidden */
  15051. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15052. /**
  15053. * Parses a JSON object to create a particle system.
  15054. * @param parsedParticleSystem The JSON object to parse
  15055. * @param scene The scene to create the particle system in
  15056. * @param rootUrl The root url to use to load external dependencies like texture
  15057. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15058. * @returns the Parsed particle system
  15059. */
  15060. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15061. }
  15062. }
  15063. declare module "babylonjs/Particles/particle" {
  15064. import { Nullable } from "babylonjs/types";
  15065. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15066. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15067. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15068. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15069. /**
  15070. * A particle represents one of the element emitted by a particle system.
  15071. * This is mainly define by its coordinates, direction, velocity and age.
  15072. */
  15073. export class Particle {
  15074. /**
  15075. * The particle system the particle belongs to.
  15076. */
  15077. particleSystem: ParticleSystem;
  15078. private static _Count;
  15079. /**
  15080. * Unique ID of the particle
  15081. */
  15082. id: number;
  15083. /**
  15084. * The world position of the particle in the scene.
  15085. */
  15086. position: Vector3;
  15087. /**
  15088. * The world direction of the particle in the scene.
  15089. */
  15090. direction: Vector3;
  15091. /**
  15092. * The color of the particle.
  15093. */
  15094. color: Color4;
  15095. /**
  15096. * The color change of the particle per step.
  15097. */
  15098. colorStep: Color4;
  15099. /**
  15100. * Defines how long will the life of the particle be.
  15101. */
  15102. lifeTime: number;
  15103. /**
  15104. * The current age of the particle.
  15105. */
  15106. age: number;
  15107. /**
  15108. * The current size of the particle.
  15109. */
  15110. size: number;
  15111. /**
  15112. * The current scale of the particle.
  15113. */
  15114. scale: Vector2;
  15115. /**
  15116. * The current angle of the particle.
  15117. */
  15118. angle: number;
  15119. /**
  15120. * Defines how fast is the angle changing.
  15121. */
  15122. angularSpeed: number;
  15123. /**
  15124. * Defines the cell index used by the particle to be rendered from a sprite.
  15125. */
  15126. cellIndex: number;
  15127. /**
  15128. * The information required to support color remapping
  15129. */
  15130. remapData: Vector4;
  15131. /** @hidden */
  15132. _randomCellOffset?: number;
  15133. /** @hidden */
  15134. _initialDirection: Nullable<Vector3>;
  15135. /** @hidden */
  15136. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15137. /** @hidden */
  15138. _initialStartSpriteCellID: number;
  15139. /** @hidden */
  15140. _initialEndSpriteCellID: number;
  15141. /** @hidden */
  15142. _currentColorGradient: Nullable<ColorGradient>;
  15143. /** @hidden */
  15144. _currentColor1: Color4;
  15145. /** @hidden */
  15146. _currentColor2: Color4;
  15147. /** @hidden */
  15148. _currentSizeGradient: Nullable<FactorGradient>;
  15149. /** @hidden */
  15150. _currentSize1: number;
  15151. /** @hidden */
  15152. _currentSize2: number;
  15153. /** @hidden */
  15154. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15155. /** @hidden */
  15156. _currentAngularSpeed1: number;
  15157. /** @hidden */
  15158. _currentAngularSpeed2: number;
  15159. /** @hidden */
  15160. _currentVelocityGradient: Nullable<FactorGradient>;
  15161. /** @hidden */
  15162. _currentVelocity1: number;
  15163. /** @hidden */
  15164. _currentVelocity2: number;
  15165. /** @hidden */
  15166. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15167. /** @hidden */
  15168. _currentLimitVelocity1: number;
  15169. /** @hidden */
  15170. _currentLimitVelocity2: number;
  15171. /** @hidden */
  15172. _currentDragGradient: Nullable<FactorGradient>;
  15173. /** @hidden */
  15174. _currentDrag1: number;
  15175. /** @hidden */
  15176. _currentDrag2: number;
  15177. /** @hidden */
  15178. _randomNoiseCoordinates1: Vector3;
  15179. /** @hidden */
  15180. _randomNoiseCoordinates2: Vector3;
  15181. /**
  15182. * Creates a new instance Particle
  15183. * @param particleSystem the particle system the particle belongs to
  15184. */
  15185. constructor(
  15186. /**
  15187. * The particle system the particle belongs to.
  15188. */
  15189. particleSystem: ParticleSystem);
  15190. private updateCellInfoFromSystem;
  15191. /**
  15192. * Defines how the sprite cell index is updated for the particle
  15193. */
  15194. updateCellIndex(): void;
  15195. /** @hidden */
  15196. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15197. /** @hidden */
  15198. _inheritParticleInfoToSubEmitters(): void;
  15199. /** @hidden */
  15200. _reset(): void;
  15201. /**
  15202. * Copy the properties of particle to another one.
  15203. * @param other the particle to copy the information to.
  15204. */
  15205. copyTo(other: Particle): void;
  15206. }
  15207. }
  15208. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15209. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15210. import { Effect } from "babylonjs/Materials/effect";
  15211. import { Particle } from "babylonjs/Particles/particle";
  15212. /**
  15213. * Particle emitter represents a volume emitting particles.
  15214. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15215. */
  15216. export interface IParticleEmitterType {
  15217. /**
  15218. * Called by the particle System when the direction is computed for the created particle.
  15219. * @param worldMatrix is the world matrix of the particle system
  15220. * @param directionToUpdate is the direction vector to update with the result
  15221. * @param particle is the particle we are computed the direction for
  15222. */
  15223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15224. /**
  15225. * Called by the particle System when the position is computed for the created particle.
  15226. * @param worldMatrix is the world matrix of the particle system
  15227. * @param positionToUpdate is the position vector to update with the result
  15228. * @param particle is the particle we are computed the position for
  15229. */
  15230. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15231. /**
  15232. * Clones the current emitter and returns a copy of it
  15233. * @returns the new emitter
  15234. */
  15235. clone(): IParticleEmitterType;
  15236. /**
  15237. * Called by the GPUParticleSystem to setup the update shader
  15238. * @param effect defines the update shader
  15239. */
  15240. applyToShader(effect: Effect): void;
  15241. /**
  15242. * Returns a string to use to update the GPU particles update shader
  15243. * @returns the effect defines string
  15244. */
  15245. getEffectDefines(): string;
  15246. /**
  15247. * Returns a string representing the class name
  15248. * @returns a string containing the class name
  15249. */
  15250. getClassName(): string;
  15251. /**
  15252. * Serializes the particle system to a JSON object.
  15253. * @returns the JSON object
  15254. */
  15255. serialize(): any;
  15256. /**
  15257. * Parse properties from a JSON object
  15258. * @param serializationObject defines the JSON object
  15259. */
  15260. parse(serializationObject: any): void;
  15261. }
  15262. }
  15263. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15265. import { Effect } from "babylonjs/Materials/effect";
  15266. import { Particle } from "babylonjs/Particles/particle";
  15267. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15268. /**
  15269. * Particle emitter emitting particles from the inside of a box.
  15270. * It emits the particles randomly between 2 given directions.
  15271. */
  15272. export class BoxParticleEmitter implements IParticleEmitterType {
  15273. /**
  15274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15275. */
  15276. direction1: Vector3;
  15277. /**
  15278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15279. */
  15280. direction2: Vector3;
  15281. /**
  15282. * 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.
  15283. */
  15284. minEmitBox: Vector3;
  15285. /**
  15286. * 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.
  15287. */
  15288. maxEmitBox: Vector3;
  15289. /**
  15290. * Creates a new instance BoxParticleEmitter
  15291. */
  15292. constructor();
  15293. /**
  15294. * Called by the particle System when the direction is computed for the created particle.
  15295. * @param worldMatrix is the world matrix of the particle system
  15296. * @param directionToUpdate is the direction vector to update with the result
  15297. * @param particle is the particle we are computed the direction for
  15298. */
  15299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15300. /**
  15301. * Called by the particle System when the position is computed for the created particle.
  15302. * @param worldMatrix is the world matrix of the particle system
  15303. * @param positionToUpdate is the position vector to update with the result
  15304. * @param particle is the particle we are computed the position for
  15305. */
  15306. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15307. /**
  15308. * Clones the current emitter and returns a copy of it
  15309. * @returns the new emitter
  15310. */
  15311. clone(): BoxParticleEmitter;
  15312. /**
  15313. * Called by the GPUParticleSystem to setup the update shader
  15314. * @param effect defines the update shader
  15315. */
  15316. applyToShader(effect: Effect): void;
  15317. /**
  15318. * Returns a string to use to update the GPU particles update shader
  15319. * @returns a string containng the defines string
  15320. */
  15321. getEffectDefines(): string;
  15322. /**
  15323. * Returns the string "BoxParticleEmitter"
  15324. * @returns a string containing the class name
  15325. */
  15326. getClassName(): string;
  15327. /**
  15328. * Serializes the particle system to a JSON object.
  15329. * @returns the JSON object
  15330. */
  15331. serialize(): any;
  15332. /**
  15333. * Parse properties from a JSON object
  15334. * @param serializationObject defines the JSON object
  15335. */
  15336. parse(serializationObject: any): void;
  15337. }
  15338. }
  15339. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15340. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15341. import { Effect } from "babylonjs/Materials/effect";
  15342. import { Particle } from "babylonjs/Particles/particle";
  15343. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15344. /**
  15345. * Particle emitter emitting particles from the inside of a cone.
  15346. * It emits the particles alongside the cone volume from the base to the particle.
  15347. * The emission direction might be randomized.
  15348. */
  15349. export class ConeParticleEmitter implements IParticleEmitterType {
  15350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15351. directionRandomizer: number;
  15352. private _radius;
  15353. private _angle;
  15354. private _height;
  15355. /**
  15356. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15357. */
  15358. radiusRange: number;
  15359. /**
  15360. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15361. */
  15362. heightRange: number;
  15363. /**
  15364. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15365. */
  15366. emitFromSpawnPointOnly: boolean;
  15367. /**
  15368. * Gets or sets the radius of the emission cone
  15369. */
  15370. radius: number;
  15371. /**
  15372. * Gets or sets the angle of the emission cone
  15373. */
  15374. angle: number;
  15375. private _buildHeight;
  15376. /**
  15377. * Creates a new instance ConeParticleEmitter
  15378. * @param radius the radius of the emission cone (1 by default)
  15379. * @param angle the cone base angle (PI by default)
  15380. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15381. */
  15382. constructor(radius?: number, angle?: number,
  15383. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15384. directionRandomizer?: number);
  15385. /**
  15386. * Called by the particle System when the direction is computed for the created particle.
  15387. * @param worldMatrix is the world matrix of the particle system
  15388. * @param directionToUpdate is the direction vector to update with the result
  15389. * @param particle is the particle we are computed the direction for
  15390. */
  15391. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15392. /**
  15393. * Called by the particle System when the position is computed for the created particle.
  15394. * @param worldMatrix is the world matrix of the particle system
  15395. * @param positionToUpdate is the position vector to update with the result
  15396. * @param particle is the particle we are computed the position for
  15397. */
  15398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15399. /**
  15400. * Clones the current emitter and returns a copy of it
  15401. * @returns the new emitter
  15402. */
  15403. clone(): ConeParticleEmitter;
  15404. /**
  15405. * Called by the GPUParticleSystem to setup the update shader
  15406. * @param effect defines the update shader
  15407. */
  15408. applyToShader(effect: Effect): void;
  15409. /**
  15410. * Returns a string to use to update the GPU particles update shader
  15411. * @returns a string containng the defines string
  15412. */
  15413. getEffectDefines(): string;
  15414. /**
  15415. * Returns the string "ConeParticleEmitter"
  15416. * @returns a string containing the class name
  15417. */
  15418. getClassName(): string;
  15419. /**
  15420. * Serializes the particle system to a JSON object.
  15421. * @returns the JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Parse properties from a JSON object
  15426. * @param serializationObject defines the JSON object
  15427. */
  15428. parse(serializationObject: any): void;
  15429. }
  15430. }
  15431. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15432. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15433. import { Effect } from "babylonjs/Materials/effect";
  15434. import { Particle } from "babylonjs/Particles/particle";
  15435. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15436. /**
  15437. * Particle emitter emitting particles from the inside of a cylinder.
  15438. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15439. */
  15440. export class CylinderParticleEmitter implements IParticleEmitterType {
  15441. /**
  15442. * The radius of the emission cylinder.
  15443. */
  15444. radius: number;
  15445. /**
  15446. * The height of the emission cylinder.
  15447. */
  15448. height: number;
  15449. /**
  15450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15451. */
  15452. radiusRange: number;
  15453. /**
  15454. * How much to randomize the particle direction [0-1].
  15455. */
  15456. directionRandomizer: number;
  15457. /**
  15458. * Creates a new instance CylinderParticleEmitter
  15459. * @param radius the radius of the emission cylinder (1 by default)
  15460. * @param height the height of the emission cylinder (1 by default)
  15461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15462. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15463. */
  15464. constructor(
  15465. /**
  15466. * The radius of the emission cylinder.
  15467. */
  15468. radius?: number,
  15469. /**
  15470. * The height of the emission cylinder.
  15471. */
  15472. height?: number,
  15473. /**
  15474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15475. */
  15476. radiusRange?: number,
  15477. /**
  15478. * How much to randomize the particle direction [0-1].
  15479. */
  15480. directionRandomizer?: number);
  15481. /**
  15482. * Called by the particle System when the direction is computed for the created particle.
  15483. * @param worldMatrix is the world matrix of the particle system
  15484. * @param directionToUpdate is the direction vector to update with the result
  15485. * @param particle is the particle we are computed the direction for
  15486. */
  15487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15488. /**
  15489. * Called by the particle System when the position is computed for the created particle.
  15490. * @param worldMatrix is the world matrix of the particle system
  15491. * @param positionToUpdate is the position vector to update with the result
  15492. * @param particle is the particle we are computed the position for
  15493. */
  15494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15495. /**
  15496. * Clones the current emitter and returns a copy of it
  15497. * @returns the new emitter
  15498. */
  15499. clone(): CylinderParticleEmitter;
  15500. /**
  15501. * Called by the GPUParticleSystem to setup the update shader
  15502. * @param effect defines the update shader
  15503. */
  15504. applyToShader(effect: Effect): void;
  15505. /**
  15506. * Returns a string to use to update the GPU particles update shader
  15507. * @returns a string containng the defines string
  15508. */
  15509. getEffectDefines(): string;
  15510. /**
  15511. * Returns the string "CylinderParticleEmitter"
  15512. * @returns a string containing the class name
  15513. */
  15514. getClassName(): string;
  15515. /**
  15516. * Serializes the particle system to a JSON object.
  15517. * @returns the JSON object
  15518. */
  15519. serialize(): any;
  15520. /**
  15521. * Parse properties from a JSON object
  15522. * @param serializationObject defines the JSON object
  15523. */
  15524. parse(serializationObject: any): void;
  15525. }
  15526. /**
  15527. * Particle emitter emitting particles from the inside of a cylinder.
  15528. * It emits the particles randomly between two vectors.
  15529. */
  15530. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15531. /**
  15532. * The min limit of the emission direction.
  15533. */
  15534. direction1: Vector3;
  15535. /**
  15536. * The max limit of the emission direction.
  15537. */
  15538. direction2: Vector3;
  15539. /**
  15540. * Creates a new instance CylinderDirectedParticleEmitter
  15541. * @param radius the radius of the emission cylinder (1 by default)
  15542. * @param height the height of the emission cylinder (1 by default)
  15543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15544. * @param direction1 the min limit of the emission direction (up vector by default)
  15545. * @param direction2 the max limit of the emission direction (up vector by default)
  15546. */
  15547. constructor(radius?: number, height?: number, radiusRange?: number,
  15548. /**
  15549. * The min limit of the emission direction.
  15550. */
  15551. direction1?: Vector3,
  15552. /**
  15553. * The max limit of the emission direction.
  15554. */
  15555. direction2?: Vector3);
  15556. /**
  15557. * Called by the particle System when the direction is computed for the created particle.
  15558. * @param worldMatrix is the world matrix of the particle system
  15559. * @param directionToUpdate is the direction vector to update with the result
  15560. * @param particle is the particle we are computed the direction for
  15561. */
  15562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15563. /**
  15564. * Clones the current emitter and returns a copy of it
  15565. * @returns the new emitter
  15566. */
  15567. clone(): CylinderDirectedParticleEmitter;
  15568. /**
  15569. * Called by the GPUParticleSystem to setup the update shader
  15570. * @param effect defines the update shader
  15571. */
  15572. applyToShader(effect: Effect): void;
  15573. /**
  15574. * Returns a string to use to update the GPU particles update shader
  15575. * @returns a string containng the defines string
  15576. */
  15577. getEffectDefines(): string;
  15578. /**
  15579. * Returns the string "CylinderDirectedParticleEmitter"
  15580. * @returns a string containing the class name
  15581. */
  15582. getClassName(): string;
  15583. /**
  15584. * Serializes the particle system to a JSON object.
  15585. * @returns the JSON object
  15586. */
  15587. serialize(): any;
  15588. /**
  15589. * Parse properties from a JSON object
  15590. * @param serializationObject defines the JSON object
  15591. */
  15592. parse(serializationObject: any): void;
  15593. }
  15594. }
  15595. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15596. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15597. import { Effect } from "babylonjs/Materials/effect";
  15598. import { Particle } from "babylonjs/Particles/particle";
  15599. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15600. /**
  15601. * Particle emitter emitting particles from the inside of a hemisphere.
  15602. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15603. */
  15604. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15605. /**
  15606. * The radius of the emission hemisphere.
  15607. */
  15608. radius: number;
  15609. /**
  15610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15611. */
  15612. radiusRange: number;
  15613. /**
  15614. * How much to randomize the particle direction [0-1].
  15615. */
  15616. directionRandomizer: number;
  15617. /**
  15618. * Creates a new instance HemisphericParticleEmitter
  15619. * @param radius the radius of the emission hemisphere (1 by default)
  15620. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15622. */
  15623. constructor(
  15624. /**
  15625. * The radius of the emission hemisphere.
  15626. */
  15627. radius?: number,
  15628. /**
  15629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15630. */
  15631. radiusRange?: number,
  15632. /**
  15633. * How much to randomize the particle direction [0-1].
  15634. */
  15635. directionRandomizer?: number);
  15636. /**
  15637. * Called by the particle System when the direction is computed for the created particle.
  15638. * @param worldMatrix is the world matrix of the particle system
  15639. * @param directionToUpdate is the direction vector to update with the result
  15640. * @param particle is the particle we are computed the direction for
  15641. */
  15642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15643. /**
  15644. * Called by the particle System when the position is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param positionToUpdate is the position vector to update with the result
  15647. * @param particle is the particle we are computed the position for
  15648. */
  15649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15650. /**
  15651. * Clones the current emitter and returns a copy of it
  15652. * @returns the new emitter
  15653. */
  15654. clone(): HemisphericParticleEmitter;
  15655. /**
  15656. * Called by the GPUParticleSystem to setup the update shader
  15657. * @param effect defines the update shader
  15658. */
  15659. applyToShader(effect: Effect): void;
  15660. /**
  15661. * Returns a string to use to update the GPU particles update shader
  15662. * @returns a string containng the defines string
  15663. */
  15664. getEffectDefines(): string;
  15665. /**
  15666. * Returns the string "HemisphericParticleEmitter"
  15667. * @returns a string containing the class name
  15668. */
  15669. getClassName(): string;
  15670. /**
  15671. * Serializes the particle system to a JSON object.
  15672. * @returns the JSON object
  15673. */
  15674. serialize(): any;
  15675. /**
  15676. * Parse properties from a JSON object
  15677. * @param serializationObject defines the JSON object
  15678. */
  15679. parse(serializationObject: any): void;
  15680. }
  15681. }
  15682. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15683. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15684. import { Effect } from "babylonjs/Materials/effect";
  15685. import { Particle } from "babylonjs/Particles/particle";
  15686. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15687. /**
  15688. * Particle emitter emitting particles from a point.
  15689. * It emits the particles randomly between 2 given directions.
  15690. */
  15691. export class PointParticleEmitter implements IParticleEmitterType {
  15692. /**
  15693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15694. */
  15695. direction1: Vector3;
  15696. /**
  15697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15698. */
  15699. direction2: Vector3;
  15700. /**
  15701. * Creates a new instance PointParticleEmitter
  15702. */
  15703. constructor();
  15704. /**
  15705. * Called by the particle System when the direction is computed for the created particle.
  15706. * @param worldMatrix is the world matrix of the particle system
  15707. * @param directionToUpdate is the direction vector to update with the result
  15708. * @param particle is the particle we are computed the direction for
  15709. */
  15710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15711. /**
  15712. * Called by the particle System when the position is computed for the created particle.
  15713. * @param worldMatrix is the world matrix of the particle system
  15714. * @param positionToUpdate is the position vector to update with the result
  15715. * @param particle is the particle we are computed the position for
  15716. */
  15717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15718. /**
  15719. * Clones the current emitter and returns a copy of it
  15720. * @returns the new emitter
  15721. */
  15722. clone(): PointParticleEmitter;
  15723. /**
  15724. * Called by the GPUParticleSystem to setup the update shader
  15725. * @param effect defines the update shader
  15726. */
  15727. applyToShader(effect: Effect): void;
  15728. /**
  15729. * Returns a string to use to update the GPU particles update shader
  15730. * @returns a string containng the defines string
  15731. */
  15732. getEffectDefines(): string;
  15733. /**
  15734. * Returns the string "PointParticleEmitter"
  15735. * @returns a string containing the class name
  15736. */
  15737. getClassName(): string;
  15738. /**
  15739. * Serializes the particle system to a JSON object.
  15740. * @returns the JSON object
  15741. */
  15742. serialize(): any;
  15743. /**
  15744. * Parse properties from a JSON object
  15745. * @param serializationObject defines the JSON object
  15746. */
  15747. parse(serializationObject: any): void;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15751. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15752. import { Effect } from "babylonjs/Materials/effect";
  15753. import { Particle } from "babylonjs/Particles/particle";
  15754. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15755. /**
  15756. * Particle emitter emitting particles from the inside of a sphere.
  15757. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15758. */
  15759. export class SphereParticleEmitter implements IParticleEmitterType {
  15760. /**
  15761. * The radius of the emission sphere.
  15762. */
  15763. radius: number;
  15764. /**
  15765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15766. */
  15767. radiusRange: number;
  15768. /**
  15769. * How much to randomize the particle direction [0-1].
  15770. */
  15771. directionRandomizer: number;
  15772. /**
  15773. * Creates a new instance SphereParticleEmitter
  15774. * @param radius the radius of the emission sphere (1 by default)
  15775. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15776. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15777. */
  15778. constructor(
  15779. /**
  15780. * The radius of the emission sphere.
  15781. */
  15782. radius?: number,
  15783. /**
  15784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15785. */
  15786. radiusRange?: number,
  15787. /**
  15788. * How much to randomize the particle direction [0-1].
  15789. */
  15790. directionRandomizer?: number);
  15791. /**
  15792. * Called by the particle System when the direction is computed for the created particle.
  15793. * @param worldMatrix is the world matrix of the particle system
  15794. * @param directionToUpdate is the direction vector to update with the result
  15795. * @param particle is the particle we are computed the direction for
  15796. */
  15797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15798. /**
  15799. * Called by the particle System when the position is computed for the created particle.
  15800. * @param worldMatrix is the world matrix of the particle system
  15801. * @param positionToUpdate is the position vector to update with the result
  15802. * @param particle is the particle we are computed the position for
  15803. */
  15804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15805. /**
  15806. * Clones the current emitter and returns a copy of it
  15807. * @returns the new emitter
  15808. */
  15809. clone(): SphereParticleEmitter;
  15810. /**
  15811. * Called by the GPUParticleSystem to setup the update shader
  15812. * @param effect defines the update shader
  15813. */
  15814. applyToShader(effect: Effect): void;
  15815. /**
  15816. * Returns a string to use to update the GPU particles update shader
  15817. * @returns a string containng the defines string
  15818. */
  15819. getEffectDefines(): string;
  15820. /**
  15821. * Returns the string "SphereParticleEmitter"
  15822. * @returns a string containing the class name
  15823. */
  15824. getClassName(): string;
  15825. /**
  15826. * Serializes the particle system to a JSON object.
  15827. * @returns the JSON object
  15828. */
  15829. serialize(): any;
  15830. /**
  15831. * Parse properties from a JSON object
  15832. * @param serializationObject defines the JSON object
  15833. */
  15834. parse(serializationObject: any): void;
  15835. }
  15836. /**
  15837. * Particle emitter emitting particles from the inside of a sphere.
  15838. * It emits the particles randomly between two vectors.
  15839. */
  15840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15841. /**
  15842. * The min limit of the emission direction.
  15843. */
  15844. direction1: Vector3;
  15845. /**
  15846. * The max limit of the emission direction.
  15847. */
  15848. direction2: Vector3;
  15849. /**
  15850. * Creates a new instance SphereDirectedParticleEmitter
  15851. * @param radius the radius of the emission sphere (1 by default)
  15852. * @param direction1 the min limit of the emission direction (up vector by default)
  15853. * @param direction2 the max limit of the emission direction (up vector by default)
  15854. */
  15855. constructor(radius?: number,
  15856. /**
  15857. * The min limit of the emission direction.
  15858. */
  15859. direction1?: Vector3,
  15860. /**
  15861. * The max limit of the emission direction.
  15862. */
  15863. direction2?: Vector3);
  15864. /**
  15865. * Called by the particle System when the direction is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param directionToUpdate is the direction vector to update with the result
  15868. * @param particle is the particle we are computed the direction for
  15869. */
  15870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereDirectedParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereDirectedParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. }
  15903. declare module "babylonjs/Particles/EmitterTypes/index" {
  15904. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15905. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15906. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15907. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15908. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15909. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15910. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15911. }
  15912. declare module "babylonjs/Particles/IParticleSystem" {
  15913. import { Nullable } from "babylonjs/types";
  15914. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15917. import { Texture } from "babylonjs/Materials/Textures/texture";
  15918. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15919. import { Scene } from "babylonjs/scene";
  15920. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15921. import { Animation } from "babylonjs/Animations/animation";
  15922. /**
  15923. * Interface representing a particle system in Babylon.js.
  15924. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15925. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15926. */
  15927. export interface IParticleSystem {
  15928. /**
  15929. * List of animations used by the particle system.
  15930. */
  15931. animations: Animation[];
  15932. /**
  15933. * The id of the Particle system.
  15934. */
  15935. id: string;
  15936. /**
  15937. * The name of the Particle system.
  15938. */
  15939. name: string;
  15940. /**
  15941. * The emitter represents the Mesh or position we are attaching the particle system to.
  15942. */
  15943. emitter: Nullable<AbstractMesh | Vector3>;
  15944. /**
  15945. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15946. */
  15947. isBillboardBased: boolean;
  15948. /**
  15949. * The rendering group used by the Particle system to chose when to render.
  15950. */
  15951. renderingGroupId: number;
  15952. /**
  15953. * The layer mask we are rendering the particles through.
  15954. */
  15955. layerMask: number;
  15956. /**
  15957. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15958. */
  15959. updateSpeed: number;
  15960. /**
  15961. * The amount of time the particle system is running (depends of the overall update speed).
  15962. */
  15963. targetStopDuration: number;
  15964. /**
  15965. * The texture used to render each particle. (this can be a spritesheet)
  15966. */
  15967. particleTexture: Nullable<Texture>;
  15968. /**
  15969. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15970. */
  15971. blendMode: number;
  15972. /**
  15973. * Minimum life time of emitting particles.
  15974. */
  15975. minLifeTime: number;
  15976. /**
  15977. * Maximum life time of emitting particles.
  15978. */
  15979. maxLifeTime: number;
  15980. /**
  15981. * Minimum Size of emitting particles.
  15982. */
  15983. minSize: number;
  15984. /**
  15985. * Maximum Size of emitting particles.
  15986. */
  15987. maxSize: number;
  15988. /**
  15989. * Minimum scale of emitting particles on X axis.
  15990. */
  15991. minScaleX: number;
  15992. /**
  15993. * Maximum scale of emitting particles on X axis.
  15994. */
  15995. maxScaleX: number;
  15996. /**
  15997. * Minimum scale of emitting particles on Y axis.
  15998. */
  15999. minScaleY: number;
  16000. /**
  16001. * Maximum scale of emitting particles on Y axis.
  16002. */
  16003. maxScaleY: number;
  16004. /**
  16005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16006. */
  16007. color1: Color4;
  16008. /**
  16009. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16010. */
  16011. color2: Color4;
  16012. /**
  16013. * Color the particle will have at the end of its lifetime.
  16014. */
  16015. colorDead: Color4;
  16016. /**
  16017. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16018. */
  16019. emitRate: number;
  16020. /**
  16021. * You can use gravity if you want to give an orientation to your particles.
  16022. */
  16023. gravity: Vector3;
  16024. /**
  16025. * Minimum power of emitting particles.
  16026. */
  16027. minEmitPower: number;
  16028. /**
  16029. * Maximum power of emitting particles.
  16030. */
  16031. maxEmitPower: number;
  16032. /**
  16033. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16034. */
  16035. minAngularSpeed: number;
  16036. /**
  16037. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16038. */
  16039. maxAngularSpeed: number;
  16040. /**
  16041. * Gets or sets the minimal initial rotation in radians.
  16042. */
  16043. minInitialRotation: number;
  16044. /**
  16045. * Gets or sets the maximal initial rotation in radians.
  16046. */
  16047. maxInitialRotation: number;
  16048. /**
  16049. * The particle emitter type defines the emitter used by the particle system.
  16050. * It can be for example box, sphere, or cone...
  16051. */
  16052. particleEmitterType: Nullable<IParticleEmitterType>;
  16053. /**
  16054. * Defines the delay in milliseconds before starting the system (0 by default)
  16055. */
  16056. startDelay: number;
  16057. /**
  16058. * 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
  16059. */
  16060. preWarmCycles: number;
  16061. /**
  16062. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16063. */
  16064. preWarmStepOffset: number;
  16065. /**
  16066. * 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)
  16067. */
  16068. spriteCellChangeSpeed: number;
  16069. /**
  16070. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16071. */
  16072. startSpriteCellID: number;
  16073. /**
  16074. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16075. */
  16076. endSpriteCellID: number;
  16077. /**
  16078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16079. */
  16080. spriteCellWidth: number;
  16081. /**
  16082. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16083. */
  16084. spriteCellHeight: number;
  16085. /**
  16086. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16087. */
  16088. spriteRandomStartCell: boolean;
  16089. /**
  16090. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16091. */
  16092. isAnimationSheetEnabled: boolean;
  16093. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16094. translationPivot: Vector2;
  16095. /**
  16096. * Gets or sets a texture used to add random noise to particle positions
  16097. */
  16098. noiseTexture: Nullable<BaseTexture>;
  16099. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16100. noiseStrength: Vector3;
  16101. /**
  16102. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16103. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16104. */
  16105. billboardMode: number;
  16106. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16107. limitVelocityDamping: number;
  16108. /**
  16109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16110. */
  16111. beginAnimationOnStart: boolean;
  16112. /**
  16113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16114. */
  16115. beginAnimationFrom: number;
  16116. /**
  16117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16118. */
  16119. beginAnimationTo: number;
  16120. /**
  16121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16122. */
  16123. beginAnimationLoop: boolean;
  16124. /**
  16125. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16126. */
  16127. disposeOnStop: boolean;
  16128. /**
  16129. * Gets the maximum number of particles active at the same time.
  16130. * @returns The max number of active particles.
  16131. */
  16132. getCapacity(): number;
  16133. /**
  16134. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16135. * @returns True if it has been started, otherwise false.
  16136. */
  16137. isStarted(): boolean;
  16138. /**
  16139. * Animates the particle system for this frame.
  16140. */
  16141. animate(): void;
  16142. /**
  16143. * Renders the particle system in its current state.
  16144. * @returns the current number of particles
  16145. */
  16146. render(): number;
  16147. /**
  16148. * Dispose the particle system and frees its associated resources.
  16149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16150. */
  16151. dispose(disposeTexture?: boolean): void;
  16152. /**
  16153. * Clones the particle system.
  16154. * @param name The name of the cloned object
  16155. * @param newEmitter The new emitter to use
  16156. * @returns the cloned particle system
  16157. */
  16158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16159. /**
  16160. * Serializes the particle system to a JSON object.
  16161. * @returns the JSON object
  16162. */
  16163. serialize(): any;
  16164. /**
  16165. * Rebuild the particle system
  16166. */
  16167. rebuild(): void;
  16168. /**
  16169. * Starts the particle system and begins to emit
  16170. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16171. */
  16172. start(delay?: number): void;
  16173. /**
  16174. * Stops the particle system.
  16175. */
  16176. stop(): void;
  16177. /**
  16178. * Remove all active particles
  16179. */
  16180. reset(): void;
  16181. /**
  16182. * Is this system ready to be used/rendered
  16183. * @return true if the system is ready
  16184. */
  16185. isReady(): boolean;
  16186. /**
  16187. * Adds a new color gradient
  16188. * @param gradient defines the gradient to use (between 0 and 1)
  16189. * @param color1 defines the color to affect to the specified gradient
  16190. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16191. * @returns the current particle system
  16192. */
  16193. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16194. /**
  16195. * Remove a specific color gradient
  16196. * @param gradient defines the gradient to remove
  16197. * @returns the current particle system
  16198. */
  16199. removeColorGradient(gradient: number): IParticleSystem;
  16200. /**
  16201. * Adds a new size gradient
  16202. * @param gradient defines the gradient to use (between 0 and 1)
  16203. * @param factor defines the size factor to affect to the specified gradient
  16204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16205. * @returns the current particle system
  16206. */
  16207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16208. /**
  16209. * Remove a specific size gradient
  16210. * @param gradient defines the gradient to remove
  16211. * @returns the current particle system
  16212. */
  16213. removeSizeGradient(gradient: number): IParticleSystem;
  16214. /**
  16215. * Gets the current list of color gradients.
  16216. * You must use addColorGradient and removeColorGradient to udpate this list
  16217. * @returns the list of color gradients
  16218. */
  16219. getColorGradients(): Nullable<Array<ColorGradient>>;
  16220. /**
  16221. * Gets the current list of size gradients.
  16222. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16223. * @returns the list of size gradients
  16224. */
  16225. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16226. /**
  16227. * Gets the current list of angular speed gradients.
  16228. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16229. * @returns the list of angular speed gradients
  16230. */
  16231. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16232. /**
  16233. * Adds a new angular speed gradient
  16234. * @param gradient defines the gradient to use (between 0 and 1)
  16235. * @param factor defines the angular speed to affect to the specified gradient
  16236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16237. * @returns the current particle system
  16238. */
  16239. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16240. /**
  16241. * Remove a specific angular speed gradient
  16242. * @param gradient defines the gradient to remove
  16243. * @returns the current particle system
  16244. */
  16245. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16246. /**
  16247. * Gets the current list of velocity gradients.
  16248. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16249. * @returns the list of velocity gradients
  16250. */
  16251. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16252. /**
  16253. * Adds a new velocity gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param factor defines the velocity to affect to the specified gradient
  16256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16257. * @returns the current particle system
  16258. */
  16259. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16260. /**
  16261. * Remove a specific velocity gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeVelocityGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Gets the current list of limit velocity gradients.
  16268. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16269. * @returns the list of limit velocity gradients
  16270. */
  16271. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16272. /**
  16273. * Adds a new limit velocity gradient
  16274. * @param gradient defines the gradient to use (between 0 and 1)
  16275. * @param factor defines the limit velocity to affect to the specified gradient
  16276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16277. * @returns the current particle system
  16278. */
  16279. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16280. /**
  16281. * Remove a specific limit velocity gradient
  16282. * @param gradient defines the gradient to remove
  16283. * @returns the current particle system
  16284. */
  16285. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16286. /**
  16287. * Adds a new drag gradient
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the drag to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific drag gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeDragGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Gets the current list of drag gradients.
  16302. * You must use addDragGradient and removeDragGradient to udpate this list
  16303. * @returns the list of drag gradients
  16304. */
  16305. getDragGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16308. * @param gradient defines the gradient to use (between 0 and 1)
  16309. * @param factor defines the emit rate to affect to the specified gradient
  16310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16311. * @returns the current particle system
  16312. */
  16313. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16314. /**
  16315. * Remove a specific emit rate gradient
  16316. * @param gradient defines the gradient to remove
  16317. * @returns the current particle system
  16318. */
  16319. removeEmitRateGradient(gradient: number): IParticleSystem;
  16320. /**
  16321. * Gets the current list of emit rate gradients.
  16322. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16323. * @returns the list of emit rate gradients
  16324. */
  16325. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16326. /**
  16327. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16328. * @param gradient defines the gradient to use (between 0 and 1)
  16329. * @param factor defines the start size to affect to the specified gradient
  16330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16331. * @returns the current particle system
  16332. */
  16333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16334. /**
  16335. * Remove a specific start size gradient
  16336. * @param gradient defines the gradient to remove
  16337. * @returns the current particle system
  16338. */
  16339. removeStartSizeGradient(gradient: number): IParticleSystem;
  16340. /**
  16341. * Gets the current list of start size gradients.
  16342. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16343. * @returns the list of start size gradients
  16344. */
  16345. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16346. /**
  16347. * Adds a new life time gradient
  16348. * @param gradient defines the gradient to use (between 0 and 1)
  16349. * @param factor defines the life time factor to affect to the specified gradient
  16350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16351. * @returns the current particle system
  16352. */
  16353. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16354. /**
  16355. * Remove a specific life time gradient
  16356. * @param gradient defines the gradient to remove
  16357. * @returns the current particle system
  16358. */
  16359. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16360. /**
  16361. * Gets the current list of life time gradients.
  16362. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16363. * @returns the list of life time gradients
  16364. */
  16365. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16366. /**
  16367. * Gets the current list of color gradients.
  16368. * You must use addColorGradient and removeColorGradient to udpate this list
  16369. * @returns the list of color gradients
  16370. */
  16371. getColorGradients(): Nullable<Array<ColorGradient>>;
  16372. /**
  16373. * Adds a new ramp gradient used to remap particle colors
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param color defines the color to affect to the specified gradient
  16376. * @returns the current particle system
  16377. */
  16378. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16379. /**
  16380. * Gets the current list of ramp gradients.
  16381. * You must use addRampGradient and removeRampGradient to udpate this list
  16382. * @returns the list of ramp gradients
  16383. */
  16384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16385. /** Gets or sets a boolean indicating that ramp gradients must be used
  16386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16387. */
  16388. useRampGradients: boolean;
  16389. /**
  16390. * Adds a new color remap gradient
  16391. * @param gradient defines the gradient to use (between 0 and 1)
  16392. * @param min defines the color remap minimal range
  16393. * @param max defines the color remap maximal range
  16394. * @returns the current particle system
  16395. */
  16396. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16397. /**
  16398. * Gets the current list of color remap gradients.
  16399. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16400. * @returns the list of color remap gradients
  16401. */
  16402. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16403. /**
  16404. * Adds a new alpha remap gradient
  16405. * @param gradient defines the gradient to use (between 0 and 1)
  16406. * @param min defines the alpha remap minimal range
  16407. * @param max defines the alpha remap maximal range
  16408. * @returns the current particle system
  16409. */
  16410. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16411. /**
  16412. * Gets the current list of alpha remap gradients.
  16413. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16414. * @returns the list of alpha remap gradients
  16415. */
  16416. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16417. /**
  16418. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16421. * @returns the emitter
  16422. */
  16423. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16424. /**
  16425. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16426. * @param radius The radius of the hemisphere to emit from
  16427. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16428. * @returns the emitter
  16429. */
  16430. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16431. /**
  16432. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16433. * @param radius The radius of the sphere to emit from
  16434. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16435. * @returns the emitter
  16436. */
  16437. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16438. /**
  16439. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16440. * @param radius The radius of the sphere to emit from
  16441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16443. * @returns the emitter
  16444. */
  16445. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16446. /**
  16447. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16448. * @param radius The radius of the emission cylinder
  16449. * @param height The height of the emission cylinder
  16450. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16451. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16452. * @returns the emitter
  16453. */
  16454. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16455. /**
  16456. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16457. * @param radius The radius of the cylinder to emit from
  16458. * @param height The height of the emission cylinder
  16459. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16462. * @returns the emitter
  16463. */
  16464. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16465. /**
  16466. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16467. * @param radius The radius of the cone to emit from
  16468. * @param angle The base angle of the cone
  16469. * @returns the emitter
  16470. */
  16471. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16472. /**
  16473. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16476. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16477. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16478. * @returns the emitter
  16479. */
  16480. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16481. /**
  16482. * Get hosting scene
  16483. * @returns the scene
  16484. */
  16485. getScene(): Scene;
  16486. }
  16487. }
  16488. declare module "babylonjs/Meshes/instancedMesh" {
  16489. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16490. import { Vector3 } from "babylonjs/Maths/math";
  16491. import { Camera } from "babylonjs/Cameras/camera";
  16492. import { Node } from "babylonjs/node";
  16493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16494. import { Mesh } from "babylonjs/Meshes/mesh";
  16495. import { Material } from "babylonjs/Materials/material";
  16496. import { Skeleton } from "babylonjs/Bones/skeleton";
  16497. /**
  16498. * Creates an instance based on a source mesh.
  16499. */
  16500. export class InstancedMesh extends AbstractMesh {
  16501. private _sourceMesh;
  16502. private _currentLOD;
  16503. /** @hidden */
  16504. _indexInSourceMeshInstanceArray: number;
  16505. constructor(name: string, source: Mesh);
  16506. /**
  16507. * Returns the string "InstancedMesh".
  16508. */
  16509. getClassName(): string;
  16510. /**
  16511. * If the source mesh receives shadows
  16512. */
  16513. readonly receiveShadows: boolean;
  16514. /**
  16515. * The material of the source mesh
  16516. */
  16517. readonly material: Nullable<Material>;
  16518. /**
  16519. * Visibility of the source mesh
  16520. */
  16521. readonly visibility: number;
  16522. /**
  16523. * Skeleton of the source mesh
  16524. */
  16525. readonly skeleton: Nullable<Skeleton>;
  16526. /**
  16527. * Rendering ground id of the source mesh
  16528. */
  16529. renderingGroupId: number;
  16530. /**
  16531. * Returns the total number of vertices (integer).
  16532. */
  16533. getTotalVertices(): number;
  16534. /**
  16535. * Returns a positive integer : the total number of indices in this mesh geometry.
  16536. * @returns the numner of indices or zero if the mesh has no geometry.
  16537. */
  16538. getTotalIndices(): number;
  16539. /**
  16540. * The source mesh of the instance
  16541. */
  16542. readonly sourceMesh: Mesh;
  16543. /**
  16544. * Is this node ready to be used/rendered
  16545. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16546. * @return {boolean} is it ready
  16547. */
  16548. isReady(completeCheck?: boolean): boolean;
  16549. /**
  16550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16551. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16552. * @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.
  16553. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16554. */
  16555. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16556. /**
  16557. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16558. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16559. * The `data` are either a numeric array either a Float32Array.
  16560. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16561. * 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).
  16562. * Note that a new underlying VertexBuffer object is created each call.
  16563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16564. *
  16565. * Possible `kind` values :
  16566. * - VertexBuffer.PositionKind
  16567. * - VertexBuffer.UVKind
  16568. * - VertexBuffer.UV2Kind
  16569. * - VertexBuffer.UV3Kind
  16570. * - VertexBuffer.UV4Kind
  16571. * - VertexBuffer.UV5Kind
  16572. * - VertexBuffer.UV6Kind
  16573. * - VertexBuffer.ColorKind
  16574. * - VertexBuffer.MatricesIndicesKind
  16575. * - VertexBuffer.MatricesIndicesExtraKind
  16576. * - VertexBuffer.MatricesWeightsKind
  16577. * - VertexBuffer.MatricesWeightsExtraKind
  16578. *
  16579. * Returns the Mesh.
  16580. */
  16581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16582. /**
  16583. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16584. * If the mesh has no geometry, it is simply returned as it is.
  16585. * The `data` are either a numeric array either a Float32Array.
  16586. * No new underlying VertexBuffer object is created.
  16587. * 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.
  16588. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16589. *
  16590. * Possible `kind` values :
  16591. * - VertexBuffer.PositionKind
  16592. * - VertexBuffer.UVKind
  16593. * - VertexBuffer.UV2Kind
  16594. * - VertexBuffer.UV3Kind
  16595. * - VertexBuffer.UV4Kind
  16596. * - VertexBuffer.UV5Kind
  16597. * - VertexBuffer.UV6Kind
  16598. * - VertexBuffer.ColorKind
  16599. * - VertexBuffer.MatricesIndicesKind
  16600. * - VertexBuffer.MatricesIndicesExtraKind
  16601. * - VertexBuffer.MatricesWeightsKind
  16602. * - VertexBuffer.MatricesWeightsExtraKind
  16603. *
  16604. * Returns the Mesh.
  16605. */
  16606. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16607. /**
  16608. * Sets the mesh indices.
  16609. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16610. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16611. * This method creates a new index buffer each call.
  16612. * Returns the Mesh.
  16613. */
  16614. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16615. /**
  16616. * Boolean : True if the mesh owns the requested kind of data.
  16617. */
  16618. isVerticesDataPresent(kind: string): boolean;
  16619. /**
  16620. * Returns an array of indices (IndicesArray).
  16621. */
  16622. getIndices(): Nullable<IndicesArray>;
  16623. readonly _positions: Nullable<Vector3[]>;
  16624. /**
  16625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16626. * This means the mesh underlying bounding box and sphere are recomputed.
  16627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16628. * @returns the current mesh
  16629. */
  16630. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16631. /** @hidden */
  16632. _preActivate(): InstancedMesh;
  16633. /** @hidden */
  16634. _activate(renderId: number): InstancedMesh;
  16635. /**
  16636. * Returns the current associated LOD AbstractMesh.
  16637. */
  16638. getLOD(camera: Camera): AbstractMesh;
  16639. /** @hidden */
  16640. _syncSubMeshes(): InstancedMesh;
  16641. /** @hidden */
  16642. _generatePointsArray(): boolean;
  16643. /**
  16644. * Creates a new InstancedMesh from the current mesh.
  16645. * - name (string) : the cloned mesh name
  16646. * - newParent (optional Node) : the optional Node to parent the clone to.
  16647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16648. *
  16649. * Returns the clone.
  16650. */
  16651. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16652. /**
  16653. * Disposes the InstancedMesh.
  16654. * Returns nothing.
  16655. */
  16656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16657. }
  16658. }
  16659. declare module "babylonjs/Materials/shaderMaterial" {
  16660. import { Scene } from "babylonjs/scene";
  16661. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16663. import { Mesh } from "babylonjs/Meshes/mesh";
  16664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16665. import { Texture } from "babylonjs/Materials/Textures/texture";
  16666. import { Material } from "babylonjs/Materials/material";
  16667. /**
  16668. * Defines the options associated with the creation of a shader material.
  16669. */
  16670. export interface IShaderMaterialOptions {
  16671. /**
  16672. * Does the material work in alpha blend mode
  16673. */
  16674. needAlphaBlending: boolean;
  16675. /**
  16676. * Does the material work in alpha test mode
  16677. */
  16678. needAlphaTesting: boolean;
  16679. /**
  16680. * The list of attribute names used in the shader
  16681. */
  16682. attributes: string[];
  16683. /**
  16684. * The list of unifrom names used in the shader
  16685. */
  16686. uniforms: string[];
  16687. /**
  16688. * The list of UBO names used in the shader
  16689. */
  16690. uniformBuffers: string[];
  16691. /**
  16692. * The list of sampler names used in the shader
  16693. */
  16694. samplers: string[];
  16695. /**
  16696. * The list of defines used in the shader
  16697. */
  16698. defines: string[];
  16699. }
  16700. /**
  16701. * 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.
  16702. *
  16703. * This returned material effects how the mesh will look based on the code in the shaders.
  16704. *
  16705. * @see http://doc.babylonjs.com/how_to/shader_material
  16706. */
  16707. export class ShaderMaterial extends Material {
  16708. private _shaderPath;
  16709. private _options;
  16710. private _textures;
  16711. private _textureArrays;
  16712. private _floats;
  16713. private _ints;
  16714. private _floatsArrays;
  16715. private _colors3;
  16716. private _colors3Arrays;
  16717. private _colors4;
  16718. private _vectors2;
  16719. private _vectors3;
  16720. private _vectors4;
  16721. private _matrices;
  16722. private _matrices3x3;
  16723. private _matrices2x2;
  16724. private _vectors2Arrays;
  16725. private _vectors3Arrays;
  16726. private _cachedWorldViewMatrix;
  16727. private _renderId;
  16728. /**
  16729. * Instantiate a new shader material.
  16730. * 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.
  16731. * This returned material effects how the mesh will look based on the code in the shaders.
  16732. * @see http://doc.babylonjs.com/how_to/shader_material
  16733. * @param name Define the name of the material in the scene
  16734. * @param scene Define the scene the material belongs to
  16735. * @param shaderPath Defines the route to the shader code in one of three ways:
  16736. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16737. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16738. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16739. * @param options Define the options used to create the shader
  16740. */
  16741. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16742. /**
  16743. * Gets the current class name of the material e.g. "ShaderMaterial"
  16744. * Mainly use in serialization.
  16745. * @returns the class name
  16746. */
  16747. getClassName(): string;
  16748. /**
  16749. * Specifies if the material will require alpha blending
  16750. * @returns a boolean specifying if alpha blending is needed
  16751. */
  16752. needAlphaBlending(): boolean;
  16753. /**
  16754. * Specifies if this material should be rendered in alpha test mode
  16755. * @returns a boolean specifying if an alpha test is needed.
  16756. */
  16757. needAlphaTesting(): boolean;
  16758. private _checkUniform;
  16759. /**
  16760. * Set a texture in the shader.
  16761. * @param name Define the name of the uniform samplers as defined in the shader
  16762. * @param texture Define the texture to bind to this sampler
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setTexture(name: string, texture: Texture): ShaderMaterial;
  16766. /**
  16767. * Set a texture array in the shader.
  16768. * @param name Define the name of the uniform sampler array as defined in the shader
  16769. * @param textures Define the list of textures to bind to this sampler
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16773. /**
  16774. * Set a float in the shader.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setFloat(name: string, value: number): ShaderMaterial;
  16780. /**
  16781. * Set a int in the shader.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setInt(name: string, value: number): ShaderMaterial;
  16787. /**
  16788. * Set an array of floats in the shader.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setFloats(name: string, value: number[]): ShaderMaterial;
  16794. /**
  16795. * Set a vec3 in the shader from a Color3.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setColor3(name: string, value: Color3): ShaderMaterial;
  16801. /**
  16802. * Set a vec3 array in the shader from a Color3 array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16808. /**
  16809. * Set a vec4 in the shader from a Color4.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setColor4(name: string, value: Color4): ShaderMaterial;
  16815. /**
  16816. * Set a vec2 in the shader from a Vector2.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setVector2(name: string, value: Vector2): ShaderMaterial;
  16822. /**
  16823. * Set a vec3 in the shader from a Vector3.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setVector3(name: string, value: Vector3): ShaderMaterial;
  16829. /**
  16830. * Set a vec4 in the shader from a Vector4.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setVector4(name: string, value: Vector4): ShaderMaterial;
  16836. /**
  16837. * Set a mat4 in the shader from a Matrix.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16843. /**
  16844. * Set a mat3 in the shader from a Float32Array.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the material itself allowing "fluent" like uniform updates
  16848. */
  16849. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16850. /**
  16851. * Set a mat2 in the shader from a Float32Array.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the material itself allowing "fluent" like uniform updates
  16855. */
  16856. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16857. /**
  16858. * Set a vec2 array in the shader from a number array.
  16859. * @param name Define the name of the uniform as defined in the shader
  16860. * @param value Define the value to give to the uniform
  16861. * @return the material itself allowing "fluent" like uniform updates
  16862. */
  16863. setArray2(name: string, value: number[]): ShaderMaterial;
  16864. /**
  16865. * Set a vec3 array in the shader from a number array.
  16866. * @param name Define the name of the uniform as defined in the shader
  16867. * @param value Define the value to give to the uniform
  16868. * @return the material itself allowing "fluent" like uniform updates
  16869. */
  16870. setArray3(name: string, value: number[]): ShaderMaterial;
  16871. private _checkCache;
  16872. /**
  16873. * Checks if the material is ready to render the requested mesh
  16874. * @param mesh Define the mesh to render
  16875. * @param useInstances Define whether or not the material is used with instances
  16876. * @returns true if ready, otherwise false
  16877. */
  16878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16879. /**
  16880. * Binds the world matrix to the material
  16881. * @param world defines the world transformation matrix
  16882. */
  16883. bindOnlyWorldMatrix(world: Matrix): void;
  16884. /**
  16885. * Binds the material to the mesh
  16886. * @param world defines the world transformation matrix
  16887. * @param mesh defines the mesh to bind the material to
  16888. */
  16889. bind(world: Matrix, mesh?: Mesh): void;
  16890. /**
  16891. * Gets the active textures from the material
  16892. * @returns an array of textures
  16893. */
  16894. getActiveTextures(): BaseTexture[];
  16895. /**
  16896. * Specifies if the material uses a texture
  16897. * @param texture defines the texture to check against the material
  16898. * @returns a boolean specifying if the material uses the texture
  16899. */
  16900. hasTexture(texture: BaseTexture): boolean;
  16901. /**
  16902. * Makes a duplicate of the material, and gives it a new name
  16903. * @param name defines the new name for the duplicated material
  16904. * @returns the cloned material
  16905. */
  16906. clone(name: string): ShaderMaterial;
  16907. /**
  16908. * Disposes the material
  16909. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16910. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16911. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16912. */
  16913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16914. /**
  16915. * Serializes this material in a JSON representation
  16916. * @returns the serialized material object
  16917. */
  16918. serialize(): any;
  16919. /**
  16920. * Creates a shader material from parsed shader material data
  16921. * @param source defines the JSON represnetation of the material
  16922. * @param scene defines the hosting scene
  16923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16924. * @returns a new material
  16925. */
  16926. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16927. }
  16928. }
  16929. declare module "babylonjs/Shaders/color.fragment" {
  16930. /** @hidden */
  16931. export var colorPixelShader: {
  16932. name: string;
  16933. shader: string;
  16934. };
  16935. }
  16936. declare module "babylonjs/Shaders/color.vertex" {
  16937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16941. /** @hidden */
  16942. export var colorVertexShader: {
  16943. name: string;
  16944. shader: string;
  16945. };
  16946. }
  16947. declare module "babylonjs/Meshes/linesMesh" {
  16948. import { Nullable } from "babylonjs/types";
  16949. import { Scene } from "babylonjs/scene";
  16950. import { Color3 } from "babylonjs/Maths/math";
  16951. import { Node } from "babylonjs/node";
  16952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16953. import { Mesh } from "babylonjs/Meshes/mesh";
  16954. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16955. import { Effect } from "babylonjs/Materials/effect";
  16956. import { Material } from "babylonjs/Materials/material";
  16957. import "babylonjs/Shaders/color.fragment";
  16958. import "babylonjs/Shaders/color.vertex";
  16959. /**
  16960. * Line mesh
  16961. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16962. */
  16963. export class LinesMesh extends Mesh {
  16964. /**
  16965. * If vertex color should be applied to the mesh
  16966. */
  16967. useVertexColor?: boolean | undefined;
  16968. /**
  16969. * If vertex alpha should be applied to the mesh
  16970. */
  16971. useVertexAlpha?: boolean | undefined;
  16972. /**
  16973. * Color of the line (Default: White)
  16974. */
  16975. color: Color3;
  16976. /**
  16977. * Alpha of the line (Default: 1)
  16978. */
  16979. alpha: number;
  16980. /**
  16981. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16982. * This margin is expressed in world space coordinates, so its value may vary.
  16983. * Default value is 0.1
  16984. */
  16985. intersectionThreshold: number;
  16986. private _colorShader;
  16987. /**
  16988. * Creates a new LinesMesh
  16989. * @param name defines the name
  16990. * @param scene defines the hosting scene
  16991. * @param parent defines the parent mesh if any
  16992. * @param source defines the optional source LinesMesh used to clone data from
  16993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16994. * When false, achieved by calling a clone(), also passing False.
  16995. * This will make creation of children, recursive.
  16996. * @param useVertexColor defines if this LinesMesh supports vertex color
  16997. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16998. */
  16999. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17000. /**
  17001. * If vertex color should be applied to the mesh
  17002. */
  17003. useVertexColor?: boolean | undefined,
  17004. /**
  17005. * If vertex alpha should be applied to the mesh
  17006. */
  17007. useVertexAlpha?: boolean | undefined);
  17008. /**
  17009. * Returns the string "LineMesh"
  17010. */
  17011. getClassName(): string;
  17012. /**
  17013. * @hidden
  17014. */
  17015. /**
  17016. * @hidden
  17017. */
  17018. material: Material;
  17019. /**
  17020. * @hidden
  17021. */
  17022. readonly checkCollisions: boolean;
  17023. /** @hidden */
  17024. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17025. /** @hidden */
  17026. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17027. /**
  17028. * Disposes of the line mesh
  17029. * @param doNotRecurse If children should be disposed
  17030. */
  17031. dispose(doNotRecurse?: boolean): void;
  17032. /**
  17033. * Returns a new LineMesh object cloned from the current one.
  17034. */
  17035. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17036. /**
  17037. * Creates a new InstancedLinesMesh object from the mesh model.
  17038. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17039. * @param name defines the name of the new instance
  17040. * @returns a new InstancedLinesMesh
  17041. */
  17042. createInstance(name: string): InstancedLinesMesh;
  17043. }
  17044. /**
  17045. * Creates an instance based on a source LinesMesh
  17046. */
  17047. export class InstancedLinesMesh extends InstancedMesh {
  17048. /**
  17049. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17050. * This margin is expressed in world space coordinates, so its value may vary.
  17051. * Initilized with the intersectionThreshold value of the source LinesMesh
  17052. */
  17053. intersectionThreshold: number;
  17054. constructor(name: string, source: LinesMesh);
  17055. /**
  17056. * Returns the string "InstancedLinesMesh".
  17057. */
  17058. getClassName(): string;
  17059. }
  17060. }
  17061. declare module "babylonjs/Shaders/line.fragment" {
  17062. /** @hidden */
  17063. export var linePixelShader: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module "babylonjs/Shaders/line.vertex" {
  17069. /** @hidden */
  17070. export var lineVertexShader: {
  17071. name: string;
  17072. shader: string;
  17073. };
  17074. }
  17075. declare module "babylonjs/Rendering/edgesRenderer" {
  17076. import { Nullable } from "babylonjs/types";
  17077. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17079. import { Vector3 } from "babylonjs/Maths/math";
  17080. import { IDisposable } from "babylonjs/scene";
  17081. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17082. import "babylonjs/Shaders/line.fragment";
  17083. import "babylonjs/Shaders/line.vertex";
  17084. module "babylonjs/Meshes/abstractMesh" {
  17085. interface AbstractMesh {
  17086. /**
  17087. * Disables the mesh edge rendering mode
  17088. * @returns the currentAbstractMesh
  17089. */
  17090. disableEdgesRendering(): AbstractMesh;
  17091. /**
  17092. * Enables the edge rendering mode on the mesh.
  17093. * This mode makes the mesh edges visible
  17094. * @param epsilon defines the maximal distance between two angles to detect a face
  17095. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17096. * @returns the currentAbstractMesh
  17097. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17098. */
  17099. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17100. /**
  17101. * Gets the edgesRenderer associated with the mesh
  17102. */
  17103. edgesRenderer: Nullable<EdgesRenderer>;
  17104. }
  17105. }
  17106. module "babylonjs/Meshes/linesMesh" {
  17107. interface LinesMesh {
  17108. /**
  17109. * Enables the edge rendering mode on the mesh.
  17110. * This mode makes the mesh edges visible
  17111. * @param epsilon defines the maximal distance between two angles to detect a face
  17112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17113. * @returns the currentAbstractMesh
  17114. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17115. */
  17116. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17117. }
  17118. }
  17119. module "babylonjs/Meshes/linesMesh" {
  17120. interface InstancedLinesMesh {
  17121. /**
  17122. * Enables the edge rendering mode on the mesh.
  17123. * This mode makes the mesh edges visible
  17124. * @param epsilon defines the maximal distance between two angles to detect a face
  17125. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17126. * @returns the current InstancedLinesMesh
  17127. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17128. */
  17129. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17130. }
  17131. }
  17132. /**
  17133. * Defines the minimum contract an Edges renderer should follow.
  17134. */
  17135. export interface IEdgesRenderer extends IDisposable {
  17136. /**
  17137. * Gets or sets a boolean indicating if the edgesRenderer is active
  17138. */
  17139. isEnabled: boolean;
  17140. /**
  17141. * Renders the edges of the attached mesh,
  17142. */
  17143. render(): void;
  17144. /**
  17145. * Checks wether or not the edges renderer is ready to render.
  17146. * @return true if ready, otherwise false.
  17147. */
  17148. isReady(): boolean;
  17149. }
  17150. /**
  17151. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17152. */
  17153. export class EdgesRenderer implements IEdgesRenderer {
  17154. /**
  17155. * Define the size of the edges with an orthographic camera
  17156. */
  17157. edgesWidthScalerForOrthographic: number;
  17158. /**
  17159. * Define the size of the edges with a perspective camera
  17160. */
  17161. edgesWidthScalerForPerspective: number;
  17162. protected _source: AbstractMesh;
  17163. protected _linesPositions: number[];
  17164. protected _linesNormals: number[];
  17165. protected _linesIndices: number[];
  17166. protected _epsilon: number;
  17167. protected _indicesCount: number;
  17168. protected _lineShader: ShaderMaterial;
  17169. protected _ib: WebGLBuffer;
  17170. protected _buffers: {
  17171. [key: string]: Nullable<VertexBuffer>;
  17172. };
  17173. protected _checkVerticesInsteadOfIndices: boolean;
  17174. private _meshRebuildObserver;
  17175. private _meshDisposeObserver;
  17176. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17177. isEnabled: boolean;
  17178. /**
  17179. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17180. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17181. * @param source Mesh used to create edges
  17182. * @param epsilon sum of angles in adjacency to check for edge
  17183. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17184. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17185. */
  17186. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17187. protected _prepareRessources(): void;
  17188. /** @hidden */
  17189. _rebuild(): void;
  17190. /**
  17191. * Releases the required resources for the edges renderer
  17192. */
  17193. dispose(): void;
  17194. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17195. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17196. /**
  17197. * Checks if the pair of p0 and p1 is en edge
  17198. * @param faceIndex
  17199. * @param edge
  17200. * @param faceNormals
  17201. * @param p0
  17202. * @param p1
  17203. * @private
  17204. */
  17205. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17206. /**
  17207. * push line into the position, normal and index buffer
  17208. * @protected
  17209. */
  17210. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17211. /**
  17212. * Generates lines edges from adjacencjes
  17213. * @private
  17214. */
  17215. _generateEdgesLines(): void;
  17216. /**
  17217. * Checks wether or not the edges renderer is ready to render.
  17218. * @return true if ready, otherwise false.
  17219. */
  17220. isReady(): boolean;
  17221. /**
  17222. * Renders the edges of the attached mesh,
  17223. */
  17224. render(): void;
  17225. }
  17226. /**
  17227. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17228. */
  17229. export class LineEdgesRenderer extends EdgesRenderer {
  17230. /**
  17231. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17232. * @param source LineMesh used to generate edges
  17233. * @param epsilon not important (specified angle for edge detection)
  17234. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17235. */
  17236. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17237. /**
  17238. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17239. */
  17240. _generateEdgesLines(): void;
  17241. }
  17242. }
  17243. declare module "babylonjs/Rendering/renderingGroup" {
  17244. import { SmartArray } from "babylonjs/Misc/smartArray";
  17245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17247. import { Nullable } from "babylonjs/types";
  17248. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17249. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17250. import { Material } from "babylonjs/Materials/material";
  17251. import { Scene } from "babylonjs/scene";
  17252. /**
  17253. * This represents the object necessary to create a rendering group.
  17254. * This is exclusively used and created by the rendering manager.
  17255. * To modify the behavior, you use the available helpers in your scene or meshes.
  17256. * @hidden
  17257. */
  17258. export class RenderingGroup {
  17259. index: number;
  17260. private _scene;
  17261. private _opaqueSubMeshes;
  17262. private _transparentSubMeshes;
  17263. private _alphaTestSubMeshes;
  17264. private _depthOnlySubMeshes;
  17265. private _particleSystems;
  17266. private _spriteManagers;
  17267. private _opaqueSortCompareFn;
  17268. private _alphaTestSortCompareFn;
  17269. private _transparentSortCompareFn;
  17270. private _renderOpaque;
  17271. private _renderAlphaTest;
  17272. private _renderTransparent;
  17273. private _edgesRenderers;
  17274. onBeforeTransparentRendering: () => void;
  17275. /**
  17276. * Set the opaque sort comparison function.
  17277. * If null the sub meshes will be render in the order they were created
  17278. */
  17279. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17280. /**
  17281. * Set the alpha test sort comparison function.
  17282. * If null the sub meshes will be render in the order they were created
  17283. */
  17284. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17285. /**
  17286. * Set the transparent sort comparison function.
  17287. * If null the sub meshes will be render in the order they were created
  17288. */
  17289. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17290. /**
  17291. * Creates a new rendering group.
  17292. * @param index The rendering group index
  17293. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17294. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17295. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17296. */
  17297. 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>);
  17298. /**
  17299. * Render all the sub meshes contained in the group.
  17300. * @param customRenderFunction Used to override the default render behaviour of the group.
  17301. * @returns true if rendered some submeshes.
  17302. */
  17303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17304. /**
  17305. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17306. * @param subMeshes The submeshes to render
  17307. */
  17308. private renderOpaqueSorted;
  17309. /**
  17310. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17311. * @param subMeshes The submeshes to render
  17312. */
  17313. private renderAlphaTestSorted;
  17314. /**
  17315. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17316. * @param subMeshes The submeshes to render
  17317. */
  17318. private renderTransparentSorted;
  17319. /**
  17320. * Renders the submeshes in a specified order.
  17321. * @param subMeshes The submeshes to sort before render
  17322. * @param sortCompareFn The comparison function use to sort
  17323. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17324. * @param transparent Specifies to activate blending if true
  17325. */
  17326. private static renderSorted;
  17327. /**
  17328. * Renders the submeshes in the order they were dispatched (no sort applied).
  17329. * @param subMeshes The submeshes to render
  17330. */
  17331. private static renderUnsorted;
  17332. /**
  17333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17334. * are rendered back to front if in the same alpha index.
  17335. *
  17336. * @param a The first submesh
  17337. * @param b The second submesh
  17338. * @returns The result of the comparison
  17339. */
  17340. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17341. /**
  17342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17343. * are rendered back to front.
  17344. *
  17345. * @param a The first submesh
  17346. * @param b The second submesh
  17347. * @returns The result of the comparison
  17348. */
  17349. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17350. /**
  17351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17352. * are rendered front to back (prevent overdraw).
  17353. *
  17354. * @param a The first submesh
  17355. * @param b The second submesh
  17356. * @returns The result of the comparison
  17357. */
  17358. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17359. /**
  17360. * Resets the different lists of submeshes to prepare a new frame.
  17361. */
  17362. prepare(): void;
  17363. dispose(): void;
  17364. /**
  17365. * Inserts the submesh in its correct queue depending on its material.
  17366. * @param subMesh The submesh to dispatch
  17367. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17368. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17369. */
  17370. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17371. dispatchSprites(spriteManager: ISpriteManager): void;
  17372. dispatchParticles(particleSystem: IParticleSystem): void;
  17373. private _renderParticles;
  17374. private _renderSprites;
  17375. }
  17376. }
  17377. declare module "babylonjs/Rendering/renderingManager" {
  17378. import { Nullable } from "babylonjs/types";
  17379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17381. import { SmartArray } from "babylonjs/Misc/smartArray";
  17382. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17384. import { Material } from "babylonjs/Materials/material";
  17385. import { Scene } from "babylonjs/scene";
  17386. import { Camera } from "babylonjs/Cameras/camera";
  17387. /**
  17388. * Interface describing the different options available in the rendering manager
  17389. * regarding Auto Clear between groups.
  17390. */
  17391. export interface IRenderingManagerAutoClearSetup {
  17392. /**
  17393. * Defines whether or not autoclear is enable.
  17394. */
  17395. autoClear: boolean;
  17396. /**
  17397. * Defines whether or not to autoclear the depth buffer.
  17398. */
  17399. depth: boolean;
  17400. /**
  17401. * Defines whether or not to autoclear the stencil buffer.
  17402. */
  17403. stencil: boolean;
  17404. }
  17405. /**
  17406. * This class is used by the onRenderingGroupObservable
  17407. */
  17408. export class RenderingGroupInfo {
  17409. /**
  17410. * The Scene that being rendered
  17411. */
  17412. scene: Scene;
  17413. /**
  17414. * The camera currently used for the rendering pass
  17415. */
  17416. camera: Nullable<Camera>;
  17417. /**
  17418. * The ID of the renderingGroup being processed
  17419. */
  17420. renderingGroupId: number;
  17421. }
  17422. /**
  17423. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17424. * It is enable to manage the different groups as well as the different necessary sort functions.
  17425. * This should not be used directly aside of the few static configurations
  17426. */
  17427. export class RenderingManager {
  17428. /**
  17429. * The max id used for rendering groups (not included)
  17430. */
  17431. static MAX_RENDERINGGROUPS: number;
  17432. /**
  17433. * The min id used for rendering groups (included)
  17434. */
  17435. static MIN_RENDERINGGROUPS: number;
  17436. /**
  17437. * Used to globally prevent autoclearing scenes.
  17438. */
  17439. static AUTOCLEAR: boolean;
  17440. /**
  17441. * @hidden
  17442. */
  17443. _useSceneAutoClearSetup: boolean;
  17444. private _scene;
  17445. private _renderingGroups;
  17446. private _depthStencilBufferAlreadyCleaned;
  17447. private _autoClearDepthStencil;
  17448. private _customOpaqueSortCompareFn;
  17449. private _customAlphaTestSortCompareFn;
  17450. private _customTransparentSortCompareFn;
  17451. private _renderingGroupInfo;
  17452. /**
  17453. * Instantiates a new rendering group for a particular scene
  17454. * @param scene Defines the scene the groups belongs to
  17455. */
  17456. constructor(scene: Scene);
  17457. private _clearDepthStencilBuffer;
  17458. /**
  17459. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17460. * @hidden
  17461. */
  17462. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17463. /**
  17464. * Resets the different information of the group to prepare a new frame
  17465. * @hidden
  17466. */
  17467. reset(): void;
  17468. /**
  17469. * Dispose and release the group and its associated resources.
  17470. * @hidden
  17471. */
  17472. dispose(): void;
  17473. /**
  17474. * Clear the info related to rendering groups preventing retention points during dispose.
  17475. */
  17476. freeRenderingGroups(): void;
  17477. private _prepareRenderingGroup;
  17478. /**
  17479. * Add a sprite manager to the rendering manager in order to render it this frame.
  17480. * @param spriteManager Define the sprite manager to render
  17481. */
  17482. dispatchSprites(spriteManager: ISpriteManager): void;
  17483. /**
  17484. * Add a particle system to the rendering manager in order to render it this frame.
  17485. * @param particleSystem Define the particle system to render
  17486. */
  17487. dispatchParticles(particleSystem: IParticleSystem): void;
  17488. /**
  17489. * Add a submesh to the manager in order to render it this frame
  17490. * @param subMesh The submesh to dispatch
  17491. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17492. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17493. */
  17494. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17495. /**
  17496. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17497. * This allowed control for front to back rendering or reversly depending of the special needs.
  17498. *
  17499. * @param renderingGroupId The rendering group id corresponding to its index
  17500. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17501. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17502. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17503. */
  17504. 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;
  17505. /**
  17506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17507. *
  17508. * @param renderingGroupId The rendering group id corresponding to its index
  17509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17510. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17511. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17512. */
  17513. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17514. /**
  17515. * Gets the current auto clear configuration for one rendering group of the rendering
  17516. * manager.
  17517. * @param index the rendering group index to get the information for
  17518. * @returns The auto clear setup for the requested rendering group
  17519. */
  17520. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17521. }
  17522. }
  17523. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17524. import { Observable } from "babylonjs/Misc/observable";
  17525. import { SmartArray } from "babylonjs/Misc/smartArray";
  17526. import { Nullable } from "babylonjs/types";
  17527. import { Camera } from "babylonjs/Cameras/camera";
  17528. import { Scene } from "babylonjs/scene";
  17529. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17530. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17534. import { Texture } from "babylonjs/Materials/Textures/texture";
  17535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17536. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17537. import { Engine } from "babylonjs/Engines/engine";
  17538. /**
  17539. * This Helps creating a texture that will be created from a camera in your scene.
  17540. * It is basically a dynamic texture that could be used to create special effects for instance.
  17541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17542. */
  17543. export class RenderTargetTexture extends Texture {
  17544. isCube: boolean;
  17545. /**
  17546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17547. */
  17548. static readonly REFRESHRATE_RENDER_ONCE: number;
  17549. /**
  17550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17551. */
  17552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17553. /**
  17554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17555. * the central point of your effect and can save a lot of performances.
  17556. */
  17557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17558. /**
  17559. * Use this predicate to dynamically define the list of mesh you want to render.
  17560. * If set, the renderList property will be overwritten.
  17561. */
  17562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17563. private _renderList;
  17564. /**
  17565. * Use this list to define the list of mesh you want to render.
  17566. */
  17567. renderList: Nullable<Array<AbstractMesh>>;
  17568. private _hookArray;
  17569. /**
  17570. * Define if particles should be rendered in your texture.
  17571. */
  17572. renderParticles: boolean;
  17573. /**
  17574. * Define if sprites should be rendered in your texture.
  17575. */
  17576. renderSprites: boolean;
  17577. /**
  17578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17579. */
  17580. coordinatesMode: number;
  17581. /**
  17582. * Define the camera used to render the texture.
  17583. */
  17584. activeCamera: Nullable<Camera>;
  17585. /**
  17586. * Override the render function of the texture with your own one.
  17587. */
  17588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17589. /**
  17590. * Define if camera post processes should be use while rendering the texture.
  17591. */
  17592. useCameraPostProcesses: boolean;
  17593. /**
  17594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17595. */
  17596. ignoreCameraViewport: boolean;
  17597. private _postProcessManager;
  17598. private _postProcesses;
  17599. private _resizeObserver;
  17600. /**
  17601. * An event triggered when the texture is unbind.
  17602. */
  17603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17604. /**
  17605. * An event triggered when the texture is unbind.
  17606. */
  17607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17608. private _onAfterUnbindObserver;
  17609. /**
  17610. * Set a after unbind callback in the texture.
  17611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17612. */
  17613. onAfterUnbind: () => void;
  17614. /**
  17615. * An event triggered before rendering the texture
  17616. */
  17617. onBeforeRenderObservable: Observable<number>;
  17618. private _onBeforeRenderObserver;
  17619. /**
  17620. * Set a before render callback in the texture.
  17621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17622. */
  17623. onBeforeRender: (faceIndex: number) => void;
  17624. /**
  17625. * An event triggered after rendering the texture
  17626. */
  17627. onAfterRenderObservable: Observable<number>;
  17628. private _onAfterRenderObserver;
  17629. /**
  17630. * Set a after render callback in the texture.
  17631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17632. */
  17633. onAfterRender: (faceIndex: number) => void;
  17634. /**
  17635. * An event triggered after the texture clear
  17636. */
  17637. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17638. private _onClearObserver;
  17639. /**
  17640. * Set a clear callback in the texture.
  17641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17642. */
  17643. onClear: (Engine: Engine) => void;
  17644. /**
  17645. * Define the clear color of the Render Target if it should be different from the scene.
  17646. */
  17647. clearColor: Color4;
  17648. protected _size: number | {
  17649. width: number;
  17650. height: number;
  17651. };
  17652. protected _initialSizeParameter: number | {
  17653. width: number;
  17654. height: number;
  17655. } | {
  17656. ratio: number;
  17657. };
  17658. protected _sizeRatio: Nullable<number>;
  17659. /** @hidden */
  17660. _generateMipMaps: boolean;
  17661. protected _renderingManager: RenderingManager;
  17662. /** @hidden */
  17663. _waitingRenderList: string[];
  17664. protected _doNotChangeAspectRatio: boolean;
  17665. protected _currentRefreshId: number;
  17666. protected _refreshRate: number;
  17667. protected _textureMatrix: Matrix;
  17668. protected _samples: number;
  17669. protected _renderTargetOptions: RenderTargetCreationOptions;
  17670. /**
  17671. * Gets render target creation options that were used.
  17672. */
  17673. readonly renderTargetOptions: RenderTargetCreationOptions;
  17674. protected _engine: Engine;
  17675. protected _onRatioRescale(): void;
  17676. /**
  17677. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17678. * It must define where the camera used to render the texture is set
  17679. */
  17680. boundingBoxPosition: Vector3;
  17681. private _boundingBoxSize;
  17682. /**
  17683. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17684. * When defined, the cubemap will switch to local mode
  17685. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17686. * @example https://www.babylonjs-playground.com/#RNASML
  17687. */
  17688. boundingBoxSize: Vector3;
  17689. /**
  17690. * In case the RTT has been created with a depth texture, get the associated
  17691. * depth texture.
  17692. * Otherwise, return null.
  17693. */
  17694. depthStencilTexture: Nullable<InternalTexture>;
  17695. /**
  17696. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17697. * or used a shadow, depth texture...
  17698. * @param name The friendly name of the texture
  17699. * @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)
  17700. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17701. * @param generateMipMaps True if mip maps need to be generated after render.
  17702. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17703. * @param type The type of the buffer in the RTT (int, half float, float...)
  17704. * @param isCube True if a cube texture needs to be created
  17705. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17706. * @param generateDepthBuffer True to generate a depth buffer
  17707. * @param generateStencilBuffer True to generate a stencil buffer
  17708. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17709. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17710. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17711. */
  17712. constructor(name: string, size: number | {
  17713. width: number;
  17714. height: number;
  17715. } | {
  17716. ratio: number;
  17717. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17718. /**
  17719. * Creates a depth stencil texture.
  17720. * This is only available in WebGL 2 or with the depth texture extension available.
  17721. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17722. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17723. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17724. */
  17725. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17726. private _processSizeParameter;
  17727. /**
  17728. * Define the number of samples to use in case of MSAA.
  17729. * It defaults to one meaning no MSAA has been enabled.
  17730. */
  17731. samples: number;
  17732. /**
  17733. * Resets the refresh counter of the texture and start bak from scratch.
  17734. * Could be useful to regenerate the texture if it is setup to render only once.
  17735. */
  17736. resetRefreshCounter(): void;
  17737. /**
  17738. * Define the refresh rate of the texture or the rendering frequency.
  17739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17740. */
  17741. refreshRate: number;
  17742. /**
  17743. * Adds a post process to the render target rendering passes.
  17744. * @param postProcess define the post process to add
  17745. */
  17746. addPostProcess(postProcess: PostProcess): void;
  17747. /**
  17748. * Clear all the post processes attached to the render target
  17749. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17750. */
  17751. clearPostProcesses(dispose?: boolean): void;
  17752. /**
  17753. * Remove one of the post process from the list of attached post processes to the texture
  17754. * @param postProcess define the post process to remove from the list
  17755. */
  17756. removePostProcess(postProcess: PostProcess): void;
  17757. /** @hidden */
  17758. _shouldRender(): boolean;
  17759. /**
  17760. * Gets the actual render size of the texture.
  17761. * @returns the width of the render size
  17762. */
  17763. getRenderSize(): number;
  17764. /**
  17765. * Gets the actual render width of the texture.
  17766. * @returns the width of the render size
  17767. */
  17768. getRenderWidth(): number;
  17769. /**
  17770. * Gets the actual render height of the texture.
  17771. * @returns the height of the render size
  17772. */
  17773. getRenderHeight(): number;
  17774. /**
  17775. * Get if the texture can be rescaled or not.
  17776. */
  17777. readonly canRescale: boolean;
  17778. /**
  17779. * Resize the texture using a ratio.
  17780. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17781. */
  17782. scale(ratio: number): void;
  17783. /**
  17784. * Get the texture reflection matrix used to rotate/transform the reflection.
  17785. * @returns the reflection matrix
  17786. */
  17787. getReflectionTextureMatrix(): Matrix;
  17788. /**
  17789. * Resize the texture to a new desired size.
  17790. * Be carrefull as it will recreate all the data in the new texture.
  17791. * @param size Define the new size. It can be:
  17792. * - a number for squared texture,
  17793. * - an object containing { width: number, height: number }
  17794. * - or an object containing a ratio { ratio: number }
  17795. */
  17796. resize(size: number | {
  17797. width: number;
  17798. height: number;
  17799. } | {
  17800. ratio: number;
  17801. }): void;
  17802. /**
  17803. * Renders all the objects from the render list into the texture.
  17804. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17805. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17806. */
  17807. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17808. private _bestReflectionRenderTargetDimension;
  17809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17810. private renderToTarget;
  17811. /**
  17812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17813. * This allowed control for front to back rendering or reversly depending of the special needs.
  17814. *
  17815. * @param renderingGroupId The rendering group id corresponding to its index
  17816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17819. */
  17820. 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;
  17821. /**
  17822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17823. *
  17824. * @param renderingGroupId The rendering group id corresponding to its index
  17825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17826. */
  17827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17828. /**
  17829. * Clones the texture.
  17830. * @returns the cloned texture
  17831. */
  17832. clone(): RenderTargetTexture;
  17833. /**
  17834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17835. * @returns The JSON representation of the texture
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17840. */
  17841. disposeFramebufferObjects(): void;
  17842. /**
  17843. * Dispose the texture and release its associated resources.
  17844. */
  17845. dispose(): void;
  17846. /** @hidden */
  17847. _rebuild(): void;
  17848. /**
  17849. * Clear the info related to rendering groups preventing retention point in material dispose.
  17850. */
  17851. freeRenderingGroups(): void;
  17852. }
  17853. }
  17854. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17855. import { Scene } from "babylonjs/scene";
  17856. import { Plane } from "babylonjs/Maths/math";
  17857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17858. /**
  17859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17861. * You can then easily use it as a reflectionTexture on a flat surface.
  17862. * In case the surface is not a plane, please consider relying on reflection probes.
  17863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17864. */
  17865. export class MirrorTexture extends RenderTargetTexture {
  17866. private scene;
  17867. /**
  17868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17869. * 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.
  17870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17871. */
  17872. mirrorPlane: Plane;
  17873. /**
  17874. * Define the blur ratio used to blur the reflection if needed.
  17875. */
  17876. blurRatio: number;
  17877. /**
  17878. * Define the adaptive blur kernel used to blur the reflection if needed.
  17879. * This will autocompute the closest best match for the `blurKernel`
  17880. */
  17881. adaptiveBlurKernel: number;
  17882. /**
  17883. * Define the blur kernel used to blur the reflection if needed.
  17884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17885. */
  17886. blurKernel: number;
  17887. /**
  17888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17890. */
  17891. blurKernelX: number;
  17892. /**
  17893. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17894. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17895. */
  17896. blurKernelY: number;
  17897. private _autoComputeBlurKernel;
  17898. protected _onRatioRescale(): void;
  17899. private _updateGammaSpace;
  17900. private _imageProcessingConfigChangeObserver;
  17901. private _transformMatrix;
  17902. private _mirrorMatrix;
  17903. private _savedViewMatrix;
  17904. private _blurX;
  17905. private _blurY;
  17906. private _adaptiveBlurKernel;
  17907. private _blurKernelX;
  17908. private _blurKernelY;
  17909. private _blurRatio;
  17910. /**
  17911. * Instantiates a Mirror Texture.
  17912. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17913. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17914. * You can then easily use it as a reflectionTexture on a flat surface.
  17915. * In case the surface is not a plane, please consider relying on reflection probes.
  17916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17917. * @param name
  17918. * @param size
  17919. * @param scene
  17920. * @param generateMipMaps
  17921. * @param type
  17922. * @param samplingMode
  17923. * @param generateDepthBuffer
  17924. */
  17925. constructor(name: string, size: number | {
  17926. width: number;
  17927. height: number;
  17928. } | {
  17929. ratio: number;
  17930. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17931. private _preparePostProcesses;
  17932. /**
  17933. * Clone the mirror texture.
  17934. * @returns the cloned texture
  17935. */
  17936. clone(): MirrorTexture;
  17937. /**
  17938. * Serialize the texture to a JSON representation you could use in Parse later on
  17939. * @returns the serialized JSON representation
  17940. */
  17941. serialize(): any;
  17942. /**
  17943. * Dispose the texture and release its associated resources.
  17944. */
  17945. dispose(): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Materials/Textures/texture" {
  17949. import { Observable } from "babylonjs/Misc/observable";
  17950. import { Nullable } from "babylonjs/types";
  17951. import { Scene } from "babylonjs/scene";
  17952. import { Matrix } from "babylonjs/Maths/math";
  17953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17954. /**
  17955. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17956. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17957. */
  17958. export class Texture extends BaseTexture {
  17959. /** @hidden */
  17960. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17961. /** @hidden */
  17962. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17963. /** @hidden */
  17964. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17965. /** nearest is mag = nearest and min = nearest and mip = linear */
  17966. static readonly NEAREST_SAMPLINGMODE: number;
  17967. /** nearest is mag = nearest and min = nearest and mip = linear */
  17968. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17970. static readonly BILINEAR_SAMPLINGMODE: number;
  17971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17972. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17973. /** Trilinear is mag = linear and min = linear and mip = linear */
  17974. static readonly TRILINEAR_SAMPLINGMODE: number;
  17975. /** Trilinear is mag = linear and min = linear and mip = linear */
  17976. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17977. /** mag = nearest and min = nearest and mip = nearest */
  17978. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17979. /** mag = nearest and min = linear and mip = nearest */
  17980. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17981. /** mag = nearest and min = linear and mip = linear */
  17982. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17983. /** mag = nearest and min = linear and mip = none */
  17984. static readonly NEAREST_LINEAR: number;
  17985. /** mag = nearest and min = nearest and mip = none */
  17986. static readonly NEAREST_NEAREST: number;
  17987. /** mag = linear and min = nearest and mip = nearest */
  17988. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17989. /** mag = linear and min = nearest and mip = linear */
  17990. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17991. /** mag = linear and min = linear and mip = none */
  17992. static readonly LINEAR_LINEAR: number;
  17993. /** mag = linear and min = nearest and mip = none */
  17994. static readonly LINEAR_NEAREST: number;
  17995. /** Explicit coordinates mode */
  17996. static readonly EXPLICIT_MODE: number;
  17997. /** Spherical coordinates mode */
  17998. static readonly SPHERICAL_MODE: number;
  17999. /** Planar coordinates mode */
  18000. static readonly PLANAR_MODE: number;
  18001. /** Cubic coordinates mode */
  18002. static readonly CUBIC_MODE: number;
  18003. /** Projection coordinates mode */
  18004. static readonly PROJECTION_MODE: number;
  18005. /** Inverse Cubic coordinates mode */
  18006. static readonly SKYBOX_MODE: number;
  18007. /** Inverse Cubic coordinates mode */
  18008. static readonly INVCUBIC_MODE: number;
  18009. /** Equirectangular coordinates mode */
  18010. static readonly EQUIRECTANGULAR_MODE: number;
  18011. /** Equirectangular Fixed coordinates mode */
  18012. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18013. /** Equirectangular Fixed Mirrored coordinates mode */
  18014. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18015. /** Texture is not repeating outside of 0..1 UVs */
  18016. static readonly CLAMP_ADDRESSMODE: number;
  18017. /** Texture is repeating outside of 0..1 UVs */
  18018. static readonly WRAP_ADDRESSMODE: number;
  18019. /** Texture is repeating and mirrored */
  18020. static readonly MIRROR_ADDRESSMODE: number;
  18021. /**
  18022. * 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
  18023. */
  18024. static UseSerializedUrlIfAny: boolean;
  18025. /**
  18026. * Define the url of the texture.
  18027. */
  18028. url: Nullable<string>;
  18029. /**
  18030. * Define an offset on the texture to offset the u coordinates of the UVs
  18031. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18032. */
  18033. uOffset: number;
  18034. /**
  18035. * Define an offset on the texture to offset the v coordinates of the UVs
  18036. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18037. */
  18038. vOffset: number;
  18039. /**
  18040. * Define an offset on the texture to scale the u coordinates of the UVs
  18041. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18042. */
  18043. uScale: number;
  18044. /**
  18045. * Define an offset on the texture to scale the v coordinates of the UVs
  18046. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18047. */
  18048. vScale: number;
  18049. /**
  18050. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18051. * @see http://doc.babylonjs.com/how_to/more_materials
  18052. */
  18053. uAng: number;
  18054. /**
  18055. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18056. * @see http://doc.babylonjs.com/how_to/more_materials
  18057. */
  18058. vAng: number;
  18059. /**
  18060. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18061. * @see http://doc.babylonjs.com/how_to/more_materials
  18062. */
  18063. wAng: number;
  18064. /**
  18065. * Defines the center of rotation (U)
  18066. */
  18067. uRotationCenter: number;
  18068. /**
  18069. * Defines the center of rotation (V)
  18070. */
  18071. vRotationCenter: number;
  18072. /**
  18073. * Defines the center of rotation (W)
  18074. */
  18075. wRotationCenter: number;
  18076. /**
  18077. * Are mip maps generated for this texture or not.
  18078. */
  18079. readonly noMipmap: boolean;
  18080. private _noMipmap;
  18081. /** @hidden */
  18082. _invertY: boolean;
  18083. private _rowGenerationMatrix;
  18084. private _cachedTextureMatrix;
  18085. private _projectionModeMatrix;
  18086. private _t0;
  18087. private _t1;
  18088. private _t2;
  18089. private _cachedUOffset;
  18090. private _cachedVOffset;
  18091. private _cachedUScale;
  18092. private _cachedVScale;
  18093. private _cachedUAng;
  18094. private _cachedVAng;
  18095. private _cachedWAng;
  18096. private _cachedProjectionMatrixId;
  18097. private _cachedCoordinatesMode;
  18098. /** @hidden */
  18099. protected _initialSamplingMode: number;
  18100. /** @hidden */
  18101. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18102. private _deleteBuffer;
  18103. protected _format: Nullable<number>;
  18104. private _delayedOnLoad;
  18105. private _delayedOnError;
  18106. /**
  18107. * Observable triggered once the texture has been loaded.
  18108. */
  18109. onLoadObservable: Observable<Texture>;
  18110. protected _isBlocking: boolean;
  18111. /**
  18112. * Is the texture preventing material to render while loading.
  18113. * If false, a default texture will be used instead of the loading one during the preparation step.
  18114. */
  18115. isBlocking: boolean;
  18116. /**
  18117. * Get the current sampling mode associated with the texture.
  18118. */
  18119. readonly samplingMode: number;
  18120. /**
  18121. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18122. */
  18123. readonly invertY: boolean;
  18124. /**
  18125. * Instantiates a new texture.
  18126. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18127. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18128. * @param url define the url of the picture to load as a texture
  18129. * @param scene define the scene the texture will belong to
  18130. * @param noMipmap define if the texture will require mip maps or not
  18131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18133. * @param onLoad define a callback triggered when the texture has been loaded
  18134. * @param onError define a callback triggered when an error occurred during the loading session
  18135. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18136. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18137. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18138. */
  18139. 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);
  18140. /**
  18141. * Update the url (and optional buffer) of this texture if url was null during construction.
  18142. * @param url the url of the texture
  18143. * @param buffer the buffer of the texture (defaults to null)
  18144. * @param onLoad callback called when the texture is loaded (defaults to null)
  18145. */
  18146. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18147. /**
  18148. * Finish the loading sequence of a texture flagged as delayed load.
  18149. * @hidden
  18150. */
  18151. delayLoad(): void;
  18152. private _prepareRowForTextureGeneration;
  18153. /**
  18154. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18155. * @returns the transform matrix of the texture.
  18156. */
  18157. getTextureMatrix(): Matrix;
  18158. /**
  18159. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18160. * @returns The reflection texture transform
  18161. */
  18162. getReflectionTextureMatrix(): Matrix;
  18163. /**
  18164. * Clones the texture.
  18165. * @returns the cloned texture
  18166. */
  18167. clone(): Texture;
  18168. /**
  18169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18170. * @returns The JSON representation of the texture
  18171. */
  18172. serialize(): any;
  18173. /**
  18174. * Get the current class name of the texture useful for serialization or dynamic coding.
  18175. * @returns "Texture"
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Dispose the texture and release its associated resources.
  18180. */
  18181. dispose(): void;
  18182. /**
  18183. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18184. * @param parsedTexture Define the JSON representation of the texture
  18185. * @param scene Define the scene the parsed texture should be instantiated in
  18186. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18187. * @returns The parsed texture if successful
  18188. */
  18189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18190. /**
  18191. * Creates a texture from its base 64 representation.
  18192. * @param data Define the base64 payload without the data: prefix
  18193. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18194. * @param scene Define the scene the texture should belong to
  18195. * @param noMipmap Forces the texture to not create mip map information if true
  18196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18197. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18198. * @param onLoad define a callback triggered when the texture has been loaded
  18199. * @param onError define a callback triggered when an error occurred during the loading session
  18200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18201. * @returns the created texture
  18202. */
  18203. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18204. /**
  18205. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18206. * @param data Define the base64 payload without the data: prefix
  18207. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18209. * @param scene Define the scene the texture should belong to
  18210. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18211. * @param noMipmap Forces the texture to not create mip map information if true
  18212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18214. * @param onLoad define a callback triggered when the texture has been loaded
  18215. * @param onError define a callback triggered when an error occurred during the loading session
  18216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18217. * @returns the created texture
  18218. */
  18219. 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;
  18220. }
  18221. }
  18222. declare module "babylonjs/Materials/Textures/rawTexture" {
  18223. import { Scene } from "babylonjs/scene";
  18224. import { Texture } from "babylonjs/Materials/Textures/texture";
  18225. /**
  18226. * Raw texture can help creating a texture directly from an array of data.
  18227. * This can be super useful if you either get the data from an uncompressed source or
  18228. * if you wish to create your texture pixel by pixel.
  18229. */
  18230. export class RawTexture extends Texture {
  18231. /**
  18232. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18233. */
  18234. format: number;
  18235. private _engine;
  18236. /**
  18237. * Instantiates a new RawTexture.
  18238. * Raw texture can help creating a texture directly from an array of data.
  18239. * This can be super useful if you either get the data from an uncompressed source or
  18240. * if you wish to create your texture pixel by pixel.
  18241. * @param data define the array of data to use to create the texture
  18242. * @param width define the width of the texture
  18243. * @param height define the height of the texture
  18244. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18245. * @param scene define the scene the texture belongs to
  18246. * @param generateMipMaps define whether mip maps should be generated or not
  18247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18250. */
  18251. constructor(data: ArrayBufferView, width: number, height: number,
  18252. /**
  18253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18254. */
  18255. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18256. /**
  18257. * Updates the texture underlying data.
  18258. * @param data Define the new data of the texture
  18259. */
  18260. update(data: ArrayBufferView): void;
  18261. /**
  18262. * Creates a luminance texture from some data.
  18263. * @param data Define the texture data
  18264. * @param width Define the width of the texture
  18265. * @param height Define the height of the texture
  18266. * @param scene Define the scene the texture belongs to
  18267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18270. * @returns the luminance texture
  18271. */
  18272. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18273. /**
  18274. * Creates a luminance alpha texture from some data.
  18275. * @param data Define the texture data
  18276. * @param width Define the width of the texture
  18277. * @param height Define the height of the texture
  18278. * @param scene Define the scene the texture belongs to
  18279. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18280. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18281. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18282. * @returns the luminance alpha texture
  18283. */
  18284. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18285. /**
  18286. * Creates an alpha texture from some data.
  18287. * @param data Define the texture data
  18288. * @param width Define the width of the texture
  18289. * @param height Define the height of the texture
  18290. * @param scene Define the scene the texture belongs to
  18291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18294. * @returns the alpha texture
  18295. */
  18296. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18297. /**
  18298. * Creates a RGB texture from some data.
  18299. * @param data Define the texture data
  18300. * @param width Define the width of the texture
  18301. * @param height Define the height of the texture
  18302. * @param scene Define the scene the texture belongs to
  18303. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18307. * @returns the RGB alpha texture
  18308. */
  18309. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18310. /**
  18311. * Creates a RGBA texture from some data.
  18312. * @param data Define the texture data
  18313. * @param width Define the width of the texture
  18314. * @param height Define the height of the texture
  18315. * @param scene Define the scene the texture belongs to
  18316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18319. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18320. * @returns the RGBA texture
  18321. */
  18322. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18323. /**
  18324. * Creates a R texture from some data.
  18325. * @param data Define the texture data
  18326. * @param width Define the width of the texture
  18327. * @param height Define the height of the texture
  18328. * @param scene Define the scene the texture belongs to
  18329. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18330. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18331. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18332. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18333. * @returns the R texture
  18334. */
  18335. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18336. }
  18337. }
  18338. declare module "babylonjs/Animations/runtimeAnimation" {
  18339. import { Animation } from "babylonjs/Animations/animation";
  18340. import { Animatable } from "babylonjs/Animations/animatable";
  18341. import { Scene } from "babylonjs/scene";
  18342. /**
  18343. * Defines a runtime animation
  18344. */
  18345. export class RuntimeAnimation {
  18346. private _events;
  18347. /**
  18348. * The current frame of the runtime animation
  18349. */
  18350. private _currentFrame;
  18351. /**
  18352. * The animation used by the runtime animation
  18353. */
  18354. private _animation;
  18355. /**
  18356. * The target of the runtime animation
  18357. */
  18358. private _target;
  18359. /**
  18360. * The initiating animatable
  18361. */
  18362. private _host;
  18363. /**
  18364. * The original value of the runtime animation
  18365. */
  18366. private _originalValue;
  18367. /**
  18368. * The original blend value of the runtime animation
  18369. */
  18370. private _originalBlendValue;
  18371. /**
  18372. * The offsets cache of the runtime animation
  18373. */
  18374. private _offsetsCache;
  18375. /**
  18376. * The high limits cache of the runtime animation
  18377. */
  18378. private _highLimitsCache;
  18379. /**
  18380. * Specifies if the runtime animation has been stopped
  18381. */
  18382. private _stopped;
  18383. /**
  18384. * The blending factor of the runtime animation
  18385. */
  18386. private _blendingFactor;
  18387. /**
  18388. * The BabylonJS scene
  18389. */
  18390. private _scene;
  18391. /**
  18392. * The current value of the runtime animation
  18393. */
  18394. private _currentValue;
  18395. /** @hidden */
  18396. _workValue: any;
  18397. /**
  18398. * The active target of the runtime animation
  18399. */
  18400. private _activeTarget;
  18401. /**
  18402. * The target path of the runtime animation
  18403. */
  18404. private _targetPath;
  18405. /**
  18406. * The weight of the runtime animation
  18407. */
  18408. private _weight;
  18409. /**
  18410. * The ratio offset of the runtime animation
  18411. */
  18412. private _ratioOffset;
  18413. /**
  18414. * The previous delay of the runtime animation
  18415. */
  18416. private _previousDelay;
  18417. /**
  18418. * The previous ratio of the runtime animation
  18419. */
  18420. private _previousRatio;
  18421. /**
  18422. * Gets the current frame of the runtime animation
  18423. */
  18424. readonly currentFrame: number;
  18425. /**
  18426. * Gets the weight of the runtime animation
  18427. */
  18428. readonly weight: number;
  18429. /**
  18430. * Gets the current value of the runtime animation
  18431. */
  18432. readonly currentValue: any;
  18433. /**
  18434. * Gets the target path of the runtime animation
  18435. */
  18436. readonly targetPath: string;
  18437. /**
  18438. * Gets the actual target of the runtime animation
  18439. */
  18440. readonly target: any;
  18441. /**
  18442. * Create a new RuntimeAnimation object
  18443. * @param target defines the target of the animation
  18444. * @param animation defines the source animation object
  18445. * @param scene defines the hosting scene
  18446. * @param host defines the initiating Animatable
  18447. */
  18448. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18449. /**
  18450. * Gets the animation from the runtime animation
  18451. */
  18452. readonly animation: Animation;
  18453. /**
  18454. * Resets the runtime animation to the beginning
  18455. * @param restoreOriginal defines whether to restore the target property to the original value
  18456. */
  18457. reset(restoreOriginal?: boolean): void;
  18458. /**
  18459. * Specifies if the runtime animation is stopped
  18460. * @returns Boolean specifying if the runtime animation is stopped
  18461. */
  18462. isStopped(): boolean;
  18463. /**
  18464. * Disposes of the runtime animation
  18465. */
  18466. dispose(): void;
  18467. /**
  18468. * Interpolates the animation from the current frame
  18469. * @param currentFrame The frame to interpolate the animation to
  18470. * @param repeatCount The number of times that the animation should loop
  18471. * @param loopMode The type of looping mode to use
  18472. * @param offsetValue Animation offset value
  18473. * @param highLimitValue The high limit value
  18474. * @returns The interpolated value
  18475. */
  18476. private _interpolate;
  18477. /**
  18478. * Apply the interpolated value to the target
  18479. * @param currentValue defines the value computed by the animation
  18480. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18481. */
  18482. setValue(currentValue: any, weight?: number): void;
  18483. private _setValue;
  18484. /**
  18485. * Gets the loop pmode of the runtime animation
  18486. * @returns Loop Mode
  18487. */
  18488. private _getCorrectLoopMode;
  18489. /**
  18490. * Move the current animation to a given frame
  18491. * @param frame defines the frame to move to
  18492. */
  18493. goToFrame(frame: number): void;
  18494. /**
  18495. * @hidden Internal use only
  18496. */
  18497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18498. /**
  18499. * Execute the current animation
  18500. * @param delay defines the delay to add to the current frame
  18501. * @param from defines the lower bound of the animation range
  18502. * @param to defines the upper bound of the animation range
  18503. * @param loop defines if the current animation must loop
  18504. * @param speedRatio defines the current speed ratio
  18505. * @param weight defines the weight of the animation (default is -1 so no weight)
  18506. * @param onLoop optional callback called when animation loops
  18507. * @returns a boolean indicating if the animation is running
  18508. */
  18509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18510. }
  18511. }
  18512. declare module "babylonjs/Animations/animatable" {
  18513. import { Animation } from "babylonjs/Animations/animation";
  18514. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18515. import { Nullable } from "babylonjs/types";
  18516. import { Observable } from "babylonjs/Misc/observable";
  18517. import { Scene } from "babylonjs/scene";
  18518. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18519. import { Node } from "babylonjs/node";
  18520. /**
  18521. * Class used to store an actual running animation
  18522. */
  18523. export class Animatable {
  18524. /** defines the target object */
  18525. target: any;
  18526. /** defines the starting frame number (default is 0) */
  18527. fromFrame: number;
  18528. /** defines the ending frame number (default is 100) */
  18529. toFrame: number;
  18530. /** defines if the animation must loop (default is false) */
  18531. loopAnimation: boolean;
  18532. /** defines a callback to call when animation ends if it is not looping */
  18533. onAnimationEnd?: (() => void) | null | undefined;
  18534. /** defines a callback to call when animation loops */
  18535. onAnimationLoop?: (() => void) | null | undefined;
  18536. private _localDelayOffset;
  18537. private _pausedDelay;
  18538. private _runtimeAnimations;
  18539. private _paused;
  18540. private _scene;
  18541. private _speedRatio;
  18542. private _weight;
  18543. private _syncRoot;
  18544. /**
  18545. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18546. * This will only apply for non looping animation (default is true)
  18547. */
  18548. disposeOnEnd: boolean;
  18549. /**
  18550. * Gets a boolean indicating if the animation has started
  18551. */
  18552. animationStarted: boolean;
  18553. /**
  18554. * Observer raised when the animation ends
  18555. */
  18556. onAnimationEndObservable: Observable<Animatable>;
  18557. /**
  18558. * Observer raised when the animation loops
  18559. */
  18560. onAnimationLoopObservable: Observable<Animatable>;
  18561. /**
  18562. * Gets the root Animatable used to synchronize and normalize animations
  18563. */
  18564. readonly syncRoot: Animatable;
  18565. /**
  18566. * Gets the current frame of the first RuntimeAnimation
  18567. * Used to synchronize Animatables
  18568. */
  18569. readonly masterFrame: number;
  18570. /**
  18571. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18572. */
  18573. weight: number;
  18574. /**
  18575. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18576. */
  18577. speedRatio: number;
  18578. /**
  18579. * Creates a new Animatable
  18580. * @param scene defines the hosting scene
  18581. * @param target defines the target object
  18582. * @param fromFrame defines the starting frame number (default is 0)
  18583. * @param toFrame defines the ending frame number (default is 100)
  18584. * @param loopAnimation defines if the animation must loop (default is false)
  18585. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18586. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18587. * @param animations defines a group of animation to add to the new Animatable
  18588. * @param onAnimationLoop defines a callback to call when animation loops
  18589. */
  18590. constructor(scene: Scene,
  18591. /** defines the target object */
  18592. target: any,
  18593. /** defines the starting frame number (default is 0) */
  18594. fromFrame?: number,
  18595. /** defines the ending frame number (default is 100) */
  18596. toFrame?: number,
  18597. /** defines if the animation must loop (default is false) */
  18598. loopAnimation?: boolean, speedRatio?: number,
  18599. /** defines a callback to call when animation ends if it is not looping */
  18600. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18601. /** defines a callback to call when animation loops */
  18602. onAnimationLoop?: (() => void) | null | undefined);
  18603. /**
  18604. * Synchronize and normalize current Animatable with a source Animatable
  18605. * This is useful when using animation weights and when animations are not of the same length
  18606. * @param root defines the root Animatable to synchronize with
  18607. * @returns the current Animatable
  18608. */
  18609. syncWith(root: Animatable): Animatable;
  18610. /**
  18611. * Gets the list of runtime animations
  18612. * @returns an array of RuntimeAnimation
  18613. */
  18614. getAnimations(): RuntimeAnimation[];
  18615. /**
  18616. * Adds more animations to the current animatable
  18617. * @param target defines the target of the animations
  18618. * @param animations defines the new animations to add
  18619. */
  18620. appendAnimations(target: any, animations: Animation[]): void;
  18621. /**
  18622. * Gets the source animation for a specific property
  18623. * @param property defines the propertyu to look for
  18624. * @returns null or the source animation for the given property
  18625. */
  18626. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18627. /**
  18628. * Gets the runtime animation for a specific property
  18629. * @param property defines the propertyu to look for
  18630. * @returns null or the runtime animation for the given property
  18631. */
  18632. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18633. /**
  18634. * Resets the animatable to its original state
  18635. */
  18636. reset(): void;
  18637. /**
  18638. * Allows the animatable to blend with current running animations
  18639. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18640. * @param blendingSpeed defines the blending speed to use
  18641. */
  18642. enableBlending(blendingSpeed: number): void;
  18643. /**
  18644. * Disable animation blending
  18645. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18646. */
  18647. disableBlending(): void;
  18648. /**
  18649. * Jump directly to a given frame
  18650. * @param frame defines the frame to jump to
  18651. */
  18652. goToFrame(frame: number): void;
  18653. /**
  18654. * Pause the animation
  18655. */
  18656. pause(): void;
  18657. /**
  18658. * Restart the animation
  18659. */
  18660. restart(): void;
  18661. private _raiseOnAnimationEnd;
  18662. /**
  18663. * Stop and delete the current animation
  18664. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18665. * @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)
  18666. */
  18667. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18668. /**
  18669. * Wait asynchronously for the animation to end
  18670. * @returns a promise which will be fullfilled when the animation ends
  18671. */
  18672. waitAsync(): Promise<Animatable>;
  18673. /** @hidden */
  18674. _animate(delay: number): boolean;
  18675. }
  18676. module "babylonjs/scene" {
  18677. interface Scene {
  18678. /** @hidden */
  18679. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18680. /** @hidden */
  18681. _processLateAnimationBindingsForMatrices(holder: {
  18682. totalWeight: number;
  18683. animations: RuntimeAnimation[];
  18684. originalValue: Matrix;
  18685. }): any;
  18686. /** @hidden */
  18687. _processLateAnimationBindingsForQuaternions(holder: {
  18688. totalWeight: number;
  18689. animations: RuntimeAnimation[];
  18690. originalValue: Quaternion;
  18691. }, refQuaternion: Quaternion): Quaternion;
  18692. /** @hidden */
  18693. _processLateAnimationBindings(): void;
  18694. /**
  18695. * Will start the animation sequence of a given target
  18696. * @param target defines the target
  18697. * @param from defines from which frame should animation start
  18698. * @param to defines until which frame should animation run.
  18699. * @param weight defines the weight to apply to the animation (1.0 by default)
  18700. * @param loop defines if the animation loops
  18701. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18702. * @param onAnimationEnd defines the function to be executed when the animation ends
  18703. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18704. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18705. * @param onAnimationLoop defines the callback to call when an animation loops
  18706. * @returns the animatable object created for this animation
  18707. */
  18708. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18709. /**
  18710. * Will start the animation sequence of a given target
  18711. * @param target defines the target
  18712. * @param from defines from which frame should animation start
  18713. * @param to defines until which frame should animation run.
  18714. * @param loop defines if the animation loops
  18715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18716. * @param onAnimationEnd defines the function to be executed when the animation ends
  18717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18718. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18719. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18720. * @param onAnimationLoop defines the callback to call when an animation loops
  18721. * @returns the animatable object created for this animation
  18722. */
  18723. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18724. /**
  18725. * Will start the animation sequence of a given target and its hierarchy
  18726. * @param target defines the target
  18727. * @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.
  18728. * @param from defines from which frame should animation start
  18729. * @param to defines until which frame should animation run.
  18730. * @param loop defines if the animation loops
  18731. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18732. * @param onAnimationEnd defines the function to be executed when the animation ends
  18733. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18734. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18736. * @param onAnimationLoop defines the callback to call when an animation loops
  18737. * @returns the list of created animatables
  18738. */
  18739. 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[];
  18740. /**
  18741. * Begin a new animation on a given node
  18742. * @param target defines the target where the animation will take place
  18743. * @param animations defines the list of animations to start
  18744. * @param from defines the initial value
  18745. * @param to defines the final value
  18746. * @param loop defines if you want animation to loop (off by default)
  18747. * @param speedRatio defines the speed ratio to apply to all animations
  18748. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18749. * @param onAnimationLoop defines the callback to call when an animation loops
  18750. * @returns the list of created animatables
  18751. */
  18752. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18753. /**
  18754. * Begin a new animation on a given node and its hierarchy
  18755. * @param target defines the root node where the animation will take place
  18756. * @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.
  18757. * @param animations defines the list of animations to start
  18758. * @param from defines the initial value
  18759. * @param to defines the final value
  18760. * @param loop defines if you want animation to loop (off by default)
  18761. * @param speedRatio defines the speed ratio to apply to all animations
  18762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18763. * @param onAnimationLoop defines the callback to call when an animation loops
  18764. * @returns the list of animatables created for all nodes
  18765. */
  18766. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18767. /**
  18768. * Gets the animatable associated with a specific target
  18769. * @param target defines the target of the animatable
  18770. * @returns the required animatable if found
  18771. */
  18772. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18773. /**
  18774. * Gets all animatables associated with a given target
  18775. * @param target defines the target to look animatables for
  18776. * @returns an array of Animatables
  18777. */
  18778. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18779. /**
  18780. * Will stop the animation of the given target
  18781. * @param target - the target
  18782. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18783. * @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)
  18784. */
  18785. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18786. /**
  18787. * Stops and removes all animations that have been applied to the scene
  18788. */
  18789. stopAllAnimations(): void;
  18790. }
  18791. }
  18792. module "babylonjs/Bones/bone" {
  18793. interface Bone {
  18794. /**
  18795. * Copy an animation range from another bone
  18796. * @param source defines the source bone
  18797. * @param rangeName defines the range name to copy
  18798. * @param frameOffset defines the frame offset
  18799. * @param rescaleAsRequired defines if rescaling must be applied if required
  18800. * @param skelDimensionsRatio defines the scaling ratio
  18801. * @returns true if operation was successful
  18802. */
  18803. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18804. }
  18805. }
  18806. }
  18807. declare module "babylonjs/Bones/skeleton" {
  18808. import { Bone } from "babylonjs/Bones/bone";
  18809. import { IAnimatable } from "babylonjs/Misc/tools";
  18810. import { Observable } from "babylonjs/Misc/observable";
  18811. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18812. import { Scene } from "babylonjs/scene";
  18813. import { Nullable } from "babylonjs/types";
  18814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18815. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18816. import { Animatable } from "babylonjs/Animations/animatable";
  18817. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18818. import { Animation } from "babylonjs/Animations/animation";
  18819. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18820. /**
  18821. * Class used to handle skinning animations
  18822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18823. */
  18824. export class Skeleton implements IAnimatable {
  18825. /** defines the skeleton name */
  18826. name: string;
  18827. /** defines the skeleton Id */
  18828. id: string;
  18829. /**
  18830. * Defines the list of child bones
  18831. */
  18832. bones: Bone[];
  18833. /**
  18834. * Defines an estimate of the dimension of the skeleton at rest
  18835. */
  18836. dimensionsAtRest: Vector3;
  18837. /**
  18838. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18839. */
  18840. needInitialSkinMatrix: boolean;
  18841. /**
  18842. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18843. */
  18844. overrideMesh: Nullable<AbstractMesh>;
  18845. /**
  18846. * Gets the list of animations attached to this skeleton
  18847. */
  18848. animations: Array<Animation>;
  18849. private _scene;
  18850. private _isDirty;
  18851. private _transformMatrices;
  18852. private _transformMatrixTexture;
  18853. private _meshesWithPoseMatrix;
  18854. private _animatables;
  18855. private _identity;
  18856. private _synchronizedWithMesh;
  18857. private _ranges;
  18858. private _lastAbsoluteTransformsUpdateId;
  18859. private _canUseTextureForBones;
  18860. /** @hidden */
  18861. _numBonesWithLinkedTransformNode: number;
  18862. /**
  18863. * Specifies if the skeleton should be serialized
  18864. */
  18865. doNotSerialize: boolean;
  18866. /**
  18867. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18868. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18869. */
  18870. useTextureToStoreBoneMatrices: boolean;
  18871. private _animationPropertiesOverride;
  18872. /**
  18873. * Gets or sets the animation properties override
  18874. */
  18875. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18876. /**
  18877. * An observable triggered before computing the skeleton's matrices
  18878. */
  18879. onBeforeComputeObservable: Observable<Skeleton>;
  18880. /**
  18881. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18882. */
  18883. readonly isUsingTextureForMatrices: boolean;
  18884. /**
  18885. * Creates a new skeleton
  18886. * @param name defines the skeleton name
  18887. * @param id defines the skeleton Id
  18888. * @param scene defines the hosting scene
  18889. */
  18890. constructor(
  18891. /** defines the skeleton name */
  18892. name: string,
  18893. /** defines the skeleton Id */
  18894. id: string, scene: Scene);
  18895. /**
  18896. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18897. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18898. * @returns a Float32Array containing matrices data
  18899. */
  18900. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18901. /**
  18902. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18903. * @returns a raw texture containing the data
  18904. */
  18905. getTransformMatrixTexture(): Nullable<RawTexture>;
  18906. /**
  18907. * Gets the current hosting scene
  18908. * @returns a scene object
  18909. */
  18910. getScene(): Scene;
  18911. /**
  18912. * Gets a string representing the current skeleton data
  18913. * @param fullDetails defines a boolean indicating if we want a verbose version
  18914. * @returns a string representing the current skeleton data
  18915. */
  18916. toString(fullDetails?: boolean): string;
  18917. /**
  18918. * Get bone's index searching by name
  18919. * @param name defines bone's name to search for
  18920. * @return the indice of the bone. Returns -1 if not found
  18921. */
  18922. getBoneIndexByName(name: string): number;
  18923. /**
  18924. * Creater a new animation range
  18925. * @param name defines the name of the range
  18926. * @param from defines the start key
  18927. * @param to defines the end key
  18928. */
  18929. createAnimationRange(name: string, from: number, to: number): void;
  18930. /**
  18931. * Delete a specific animation range
  18932. * @param name defines the name of the range
  18933. * @param deleteFrames defines if frames must be removed as well
  18934. */
  18935. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18936. /**
  18937. * Gets a specific animation range
  18938. * @param name defines the name of the range to look for
  18939. * @returns the requested animation range or null if not found
  18940. */
  18941. getAnimationRange(name: string): Nullable<AnimationRange>;
  18942. /**
  18943. * Gets the list of all animation ranges defined on this skeleton
  18944. * @returns an array
  18945. */
  18946. getAnimationRanges(): Nullable<AnimationRange>[];
  18947. /**
  18948. * Copy animation range from a source skeleton.
  18949. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18950. * @param source defines the source skeleton
  18951. * @param name defines the name of the range to copy
  18952. * @param rescaleAsRequired defines if rescaling must be applied if required
  18953. * @returns true if operation was successful
  18954. */
  18955. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18956. /**
  18957. * Forces the skeleton to go to rest pose
  18958. */
  18959. returnToRest(): void;
  18960. private _getHighestAnimationFrame;
  18961. /**
  18962. * Begin a specific animation range
  18963. * @param name defines the name of the range to start
  18964. * @param loop defines if looping must be turned on (false by default)
  18965. * @param speedRatio defines the speed ratio to apply (1 by default)
  18966. * @param onAnimationEnd defines a callback which will be called when animation will end
  18967. * @returns a new animatable
  18968. */
  18969. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18970. /** @hidden */
  18971. _markAsDirty(): void;
  18972. /** @hidden */
  18973. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18974. /** @hidden */
  18975. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18976. private _computeTransformMatrices;
  18977. /**
  18978. * Build all resources required to render a skeleton
  18979. */
  18980. prepare(): void;
  18981. /**
  18982. * Gets the list of animatables currently running for this skeleton
  18983. * @returns an array of animatables
  18984. */
  18985. getAnimatables(): IAnimatable[];
  18986. /**
  18987. * Clone the current skeleton
  18988. * @param name defines the name of the new skeleton
  18989. * @param id defines the id of the enw skeleton
  18990. * @returns the new skeleton
  18991. */
  18992. clone(name: string, id: string): Skeleton;
  18993. /**
  18994. * Enable animation blending for this skeleton
  18995. * @param blendingSpeed defines the blending speed to apply
  18996. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18997. */
  18998. enableBlending(blendingSpeed?: number): void;
  18999. /**
  19000. * Releases all resources associated with the current skeleton
  19001. */
  19002. dispose(): void;
  19003. /**
  19004. * Serialize the skeleton in a JSON object
  19005. * @returns a JSON object
  19006. */
  19007. serialize(): any;
  19008. /**
  19009. * Creates a new skeleton from serialized data
  19010. * @param parsedSkeleton defines the serialized data
  19011. * @param scene defines the hosting scene
  19012. * @returns a new skeleton
  19013. */
  19014. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19015. /**
  19016. * Compute all node absolute transforms
  19017. * @param forceUpdate defines if computation must be done even if cache is up to date
  19018. */
  19019. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19020. /**
  19021. * Gets the root pose matrix
  19022. * @returns a matrix
  19023. */
  19024. getPoseMatrix(): Nullable<Matrix>;
  19025. /**
  19026. * Sorts bones per internal index
  19027. */
  19028. sortBones(): void;
  19029. private _sortBones;
  19030. }
  19031. }
  19032. declare module "babylonjs/Morph/morphTarget" {
  19033. import { IAnimatable } from "babylonjs/Misc/tools";
  19034. import { Observable } from "babylonjs/Misc/observable";
  19035. import { Nullable, FloatArray } from "babylonjs/types";
  19036. import { Scene } from "babylonjs/scene";
  19037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19038. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19039. /**
  19040. * Defines a target to use with MorphTargetManager
  19041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19042. */
  19043. export class MorphTarget implements IAnimatable {
  19044. /** defines the name of the target */
  19045. name: string;
  19046. /**
  19047. * Gets or sets the list of animations
  19048. */
  19049. animations: import("babylonjs/Animations/animation").Animation[];
  19050. private _scene;
  19051. private _positions;
  19052. private _normals;
  19053. private _tangents;
  19054. private _influence;
  19055. /**
  19056. * Observable raised when the influence changes
  19057. */
  19058. onInfluenceChanged: Observable<boolean>;
  19059. /** @hidden */
  19060. _onDataLayoutChanged: Observable<void>;
  19061. /**
  19062. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19063. */
  19064. influence: number;
  19065. /**
  19066. * Gets or sets the id of the morph Target
  19067. */
  19068. id: string;
  19069. private _animationPropertiesOverride;
  19070. /**
  19071. * Gets or sets the animation properties override
  19072. */
  19073. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19074. /**
  19075. * Creates a new MorphTarget
  19076. * @param name defines the name of the target
  19077. * @param influence defines the influence to use
  19078. * @param scene defines the scene the morphtarget belongs to
  19079. */
  19080. constructor(
  19081. /** defines the name of the target */
  19082. name: string, influence?: number, scene?: Nullable<Scene>);
  19083. /**
  19084. * Gets a boolean defining if the target contains position data
  19085. */
  19086. readonly hasPositions: boolean;
  19087. /**
  19088. * Gets a boolean defining if the target contains normal data
  19089. */
  19090. readonly hasNormals: boolean;
  19091. /**
  19092. * Gets a boolean defining if the target contains tangent data
  19093. */
  19094. readonly hasTangents: boolean;
  19095. /**
  19096. * Affects position data to this target
  19097. * @param data defines the position data to use
  19098. */
  19099. setPositions(data: Nullable<FloatArray>): void;
  19100. /**
  19101. * Gets the position data stored in this target
  19102. * @returns a FloatArray containing the position data (or null if not present)
  19103. */
  19104. getPositions(): Nullable<FloatArray>;
  19105. /**
  19106. * Affects normal data to this target
  19107. * @param data defines the normal data to use
  19108. */
  19109. setNormals(data: Nullable<FloatArray>): void;
  19110. /**
  19111. * Gets the normal data stored in this target
  19112. * @returns a FloatArray containing the normal data (or null if not present)
  19113. */
  19114. getNormals(): Nullable<FloatArray>;
  19115. /**
  19116. * Affects tangent data to this target
  19117. * @param data defines the tangent data to use
  19118. */
  19119. setTangents(data: Nullable<FloatArray>): void;
  19120. /**
  19121. * Gets the tangent data stored in this target
  19122. * @returns a FloatArray containing the tangent data (or null if not present)
  19123. */
  19124. getTangents(): Nullable<FloatArray>;
  19125. /**
  19126. * Serializes the current target into a Serialization object
  19127. * @returns the serialized object
  19128. */
  19129. serialize(): any;
  19130. /**
  19131. * Returns the string "MorphTarget"
  19132. * @returns "MorphTarget"
  19133. */
  19134. getClassName(): string;
  19135. /**
  19136. * Creates a new target from serialized data
  19137. * @param serializationObject defines the serialized data to use
  19138. * @returns a new MorphTarget
  19139. */
  19140. static Parse(serializationObject: any): MorphTarget;
  19141. /**
  19142. * Creates a MorphTarget from mesh data
  19143. * @param mesh defines the source mesh
  19144. * @param name defines the name to use for the new target
  19145. * @param influence defines the influence to attach to the target
  19146. * @returns a new MorphTarget
  19147. */
  19148. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19149. }
  19150. }
  19151. declare module "babylonjs/Morph/morphTargetManager" {
  19152. import { Nullable } from "babylonjs/types";
  19153. import { Scene } from "babylonjs/scene";
  19154. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19155. /**
  19156. * This class is used to deform meshes using morphing between different targets
  19157. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19158. */
  19159. export class MorphTargetManager {
  19160. private _targets;
  19161. private _targetInfluenceChangedObservers;
  19162. private _targetDataLayoutChangedObservers;
  19163. private _activeTargets;
  19164. private _scene;
  19165. private _influences;
  19166. private _supportsNormals;
  19167. private _supportsTangents;
  19168. private _vertexCount;
  19169. private _uniqueId;
  19170. private _tempInfluences;
  19171. /**
  19172. * Creates a new MorphTargetManager
  19173. * @param scene defines the current scene
  19174. */
  19175. constructor(scene?: Nullable<Scene>);
  19176. /**
  19177. * Gets the unique ID of this manager
  19178. */
  19179. readonly uniqueId: number;
  19180. /**
  19181. * Gets the number of vertices handled by this manager
  19182. */
  19183. readonly vertexCount: number;
  19184. /**
  19185. * Gets a boolean indicating if this manager supports morphing of normals
  19186. */
  19187. readonly supportsNormals: boolean;
  19188. /**
  19189. * Gets a boolean indicating if this manager supports morphing of tangents
  19190. */
  19191. readonly supportsTangents: boolean;
  19192. /**
  19193. * Gets the number of targets stored in this manager
  19194. */
  19195. readonly numTargets: number;
  19196. /**
  19197. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19198. */
  19199. readonly numInfluencers: number;
  19200. /**
  19201. * Gets the list of influences (one per target)
  19202. */
  19203. readonly influences: Float32Array;
  19204. /**
  19205. * Gets the active target at specified index. An active target is a target with an influence > 0
  19206. * @param index defines the index to check
  19207. * @returns the requested target
  19208. */
  19209. getActiveTarget(index: number): MorphTarget;
  19210. /**
  19211. * Gets the target at specified index
  19212. * @param index defines the index to check
  19213. * @returns the requested target
  19214. */
  19215. getTarget(index: number): MorphTarget;
  19216. /**
  19217. * Add a new target to this manager
  19218. * @param target defines the target to add
  19219. */
  19220. addTarget(target: MorphTarget): void;
  19221. /**
  19222. * Removes a target from the manager
  19223. * @param target defines the target to remove
  19224. */
  19225. removeTarget(target: MorphTarget): void;
  19226. /**
  19227. * Serializes the current manager into a Serialization object
  19228. * @returns the serialized object
  19229. */
  19230. serialize(): any;
  19231. private _syncActiveTargets;
  19232. /**
  19233. * Syncrhonize the targets with all the meshes using this morph target manager
  19234. */
  19235. synchronize(): void;
  19236. /**
  19237. * Creates a new MorphTargetManager from serialized data
  19238. * @param serializationObject defines the serialized data
  19239. * @param scene defines the hosting scene
  19240. * @returns the new MorphTargetManager
  19241. */
  19242. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19243. }
  19244. }
  19245. declare module "babylonjs/Meshes/groundMesh" {
  19246. import { Scene } from "babylonjs/scene";
  19247. import { Vector3 } from "babylonjs/Maths/math";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. /**
  19250. * Mesh representing the gorund
  19251. */
  19252. export class GroundMesh extends Mesh {
  19253. /** If octree should be generated */
  19254. generateOctree: boolean;
  19255. private _heightQuads;
  19256. /** @hidden */
  19257. _subdivisionsX: number;
  19258. /** @hidden */
  19259. _subdivisionsY: number;
  19260. /** @hidden */
  19261. _width: number;
  19262. /** @hidden */
  19263. _height: number;
  19264. /** @hidden */
  19265. _minX: number;
  19266. /** @hidden */
  19267. _maxX: number;
  19268. /** @hidden */
  19269. _minZ: number;
  19270. /** @hidden */
  19271. _maxZ: number;
  19272. constructor(name: string, scene: Scene);
  19273. /**
  19274. * "GroundMesh"
  19275. * @returns "GroundMesh"
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * The minimum of x and y subdivisions
  19280. */
  19281. readonly subdivisions: number;
  19282. /**
  19283. * X subdivisions
  19284. */
  19285. readonly subdivisionsX: number;
  19286. /**
  19287. * Y subdivisions
  19288. */
  19289. readonly subdivisionsY: number;
  19290. /**
  19291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19293. * @param chunksCount the number of subdivisions for x and y
  19294. * @param octreeBlocksSize (Default: 32)
  19295. */
  19296. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19297. /**
  19298. * Returns a height (y) value in the Worl system :
  19299. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19300. * @param x x coordinate
  19301. * @param z z coordinate
  19302. * @returns the ground y position if (x, z) are outside the ground surface.
  19303. */
  19304. getHeightAtCoordinates(x: number, z: number): number;
  19305. /**
  19306. * Returns a normalized vector (Vector3) orthogonal to the ground
  19307. * at the ground coordinates (x, z) expressed in the World system.
  19308. * @param x x coordinate
  19309. * @param z z coordinate
  19310. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19311. */
  19312. getNormalAtCoordinates(x: number, z: number): Vector3;
  19313. /**
  19314. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19315. * at the ground coordinates (x, z) expressed in the World system.
  19316. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19317. * @param x x coordinate
  19318. * @param z z coordinate
  19319. * @param ref vector to store the result
  19320. * @returns the GroundMesh.
  19321. */
  19322. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19323. /**
  19324. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19325. * if the ground has been updated.
  19326. * This can be used in the render loop.
  19327. * @returns the GroundMesh.
  19328. */
  19329. updateCoordinateHeights(): GroundMesh;
  19330. private _getFacetAt;
  19331. private _initHeightQuads;
  19332. private _computeHeightQuads;
  19333. /**
  19334. * Serializes this ground mesh
  19335. * @param serializationObject object to write serialization to
  19336. */
  19337. serialize(serializationObject: any): void;
  19338. /**
  19339. * Parses a serialized ground mesh
  19340. * @param parsedMesh the serialized mesh
  19341. * @param scene the scene to create the ground mesh in
  19342. * @returns the created ground mesh
  19343. */
  19344. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19345. }
  19346. }
  19347. declare module "babylonjs/Physics/physicsJoint" {
  19348. import { Vector3 } from "babylonjs/Maths/math";
  19349. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19350. /**
  19351. * Interface for Physics-Joint data
  19352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19353. */
  19354. export interface PhysicsJointData {
  19355. /**
  19356. * The main pivot of the joint
  19357. */
  19358. mainPivot?: Vector3;
  19359. /**
  19360. * The connected pivot of the joint
  19361. */
  19362. connectedPivot?: Vector3;
  19363. /**
  19364. * The main axis of the joint
  19365. */
  19366. mainAxis?: Vector3;
  19367. /**
  19368. * The connected axis of the joint
  19369. */
  19370. connectedAxis?: Vector3;
  19371. /**
  19372. * The collision of the joint
  19373. */
  19374. collision?: boolean;
  19375. /**
  19376. * Native Oimo/Cannon/Energy data
  19377. */
  19378. nativeParams?: any;
  19379. }
  19380. /**
  19381. * This is a holder class for the physics joint created by the physics plugin
  19382. * It holds a set of functions to control the underlying joint
  19383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19384. */
  19385. export class PhysicsJoint {
  19386. /**
  19387. * The type of the physics joint
  19388. */
  19389. type: number;
  19390. /**
  19391. * The data for the physics joint
  19392. */
  19393. jointData: PhysicsJointData;
  19394. private _physicsJoint;
  19395. protected _physicsPlugin: IPhysicsEnginePlugin;
  19396. /**
  19397. * Initializes the physics joint
  19398. * @param type The type of the physics joint
  19399. * @param jointData The data for the physics joint
  19400. */
  19401. constructor(
  19402. /**
  19403. * The type of the physics joint
  19404. */
  19405. type: number,
  19406. /**
  19407. * The data for the physics joint
  19408. */
  19409. jointData: PhysicsJointData);
  19410. /**
  19411. * Gets the physics joint
  19412. */
  19413. /**
  19414. * Sets the physics joint
  19415. */
  19416. physicsJoint: any;
  19417. /**
  19418. * Sets the physics plugin
  19419. */
  19420. physicsPlugin: IPhysicsEnginePlugin;
  19421. /**
  19422. * Execute a function that is physics-plugin specific.
  19423. * @param {Function} func the function that will be executed.
  19424. * It accepts two parameters: the physics world and the physics joint
  19425. */
  19426. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19427. /**
  19428. * Distance-Joint type
  19429. */
  19430. static DistanceJoint: number;
  19431. /**
  19432. * Hinge-Joint type
  19433. */
  19434. static HingeJoint: number;
  19435. /**
  19436. * Ball-and-Socket joint type
  19437. */
  19438. static BallAndSocketJoint: number;
  19439. /**
  19440. * Wheel-Joint type
  19441. */
  19442. static WheelJoint: number;
  19443. /**
  19444. * Slider-Joint type
  19445. */
  19446. static SliderJoint: number;
  19447. /**
  19448. * Prismatic-Joint type
  19449. */
  19450. static PrismaticJoint: number;
  19451. /**
  19452. * Universal-Joint type
  19453. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19454. */
  19455. static UniversalJoint: number;
  19456. /**
  19457. * Hinge-Joint 2 type
  19458. */
  19459. static Hinge2Joint: number;
  19460. /**
  19461. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19462. */
  19463. static PointToPointJoint: number;
  19464. /**
  19465. * Spring-Joint type
  19466. */
  19467. static SpringJoint: number;
  19468. /**
  19469. * Lock-Joint type
  19470. */
  19471. static LockJoint: number;
  19472. }
  19473. /**
  19474. * A class representing a physics distance joint
  19475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19476. */
  19477. export class DistanceJoint extends PhysicsJoint {
  19478. /**
  19479. *
  19480. * @param jointData The data for the Distance-Joint
  19481. */
  19482. constructor(jointData: DistanceJointData);
  19483. /**
  19484. * Update the predefined distance.
  19485. * @param maxDistance The maximum preferred distance
  19486. * @param minDistance The minimum preferred distance
  19487. */
  19488. updateDistance(maxDistance: number, minDistance?: number): void;
  19489. }
  19490. /**
  19491. * Represents a Motor-Enabled Joint
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19495. /**
  19496. * Initializes the Motor-Enabled Joint
  19497. * @param type The type of the joint
  19498. * @param jointData The physica joint data for the joint
  19499. */
  19500. constructor(type: number, jointData: PhysicsJointData);
  19501. /**
  19502. * Set the motor values.
  19503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19504. * @param force the force to apply
  19505. * @param maxForce max force for this motor.
  19506. */
  19507. setMotor(force?: number, maxForce?: number): void;
  19508. /**
  19509. * Set the motor's limits.
  19510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19511. * @param upperLimit The upper limit of the motor
  19512. * @param lowerLimit The lower limit of the motor
  19513. */
  19514. setLimit(upperLimit: number, lowerLimit?: number): void;
  19515. }
  19516. /**
  19517. * This class represents a single physics Hinge-Joint
  19518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19519. */
  19520. export class HingeJoint extends MotorEnabledJoint {
  19521. /**
  19522. * Initializes the Hinge-Joint
  19523. * @param jointData The joint data for the Hinge-Joint
  19524. */
  19525. constructor(jointData: PhysicsJointData);
  19526. /**
  19527. * Set the motor values.
  19528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19529. * @param {number} force the force to apply
  19530. * @param {number} maxForce max force for this motor.
  19531. */
  19532. setMotor(force?: number, maxForce?: number): void;
  19533. /**
  19534. * Set the motor's limits.
  19535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19536. * @param upperLimit The upper limit of the motor
  19537. * @param lowerLimit The lower limit of the motor
  19538. */
  19539. setLimit(upperLimit: number, lowerLimit?: number): void;
  19540. }
  19541. /**
  19542. * This class represents a dual hinge physics joint (same as wheel joint)
  19543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19544. */
  19545. export class Hinge2Joint extends MotorEnabledJoint {
  19546. /**
  19547. * Initializes the Hinge2-Joint
  19548. * @param jointData The joint data for the Hinge2-Joint
  19549. */
  19550. constructor(jointData: PhysicsJointData);
  19551. /**
  19552. * Set the motor values.
  19553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19554. * @param {number} targetSpeed the speed the motor is to reach
  19555. * @param {number} maxForce max force for this motor.
  19556. * @param {motorIndex} the motor's index, 0 or 1.
  19557. */
  19558. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19559. /**
  19560. * Set the motor limits.
  19561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19562. * @param {number} upperLimit the upper limit
  19563. * @param {number} lowerLimit lower limit
  19564. * @param {motorIndex} the motor's index, 0 or 1.
  19565. */
  19566. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19567. }
  19568. /**
  19569. * Interface for a motor enabled joint
  19570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19571. */
  19572. export interface IMotorEnabledJoint {
  19573. /**
  19574. * Physics joint
  19575. */
  19576. physicsJoint: any;
  19577. /**
  19578. * Sets the motor of the motor-enabled joint
  19579. * @param force The force of the motor
  19580. * @param maxForce The maximum force of the motor
  19581. * @param motorIndex The index of the motor
  19582. */
  19583. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19584. /**
  19585. * Sets the limit of the motor
  19586. * @param upperLimit The upper limit of the motor
  19587. * @param lowerLimit The lower limit of the motor
  19588. * @param motorIndex The index of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19591. }
  19592. /**
  19593. * Joint data for a Distance-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export interface DistanceJointData extends PhysicsJointData {
  19597. /**
  19598. * Max distance the 2 joint objects can be apart
  19599. */
  19600. maxDistance: number;
  19601. }
  19602. /**
  19603. * Joint data from a spring joint
  19604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19605. */
  19606. export interface SpringJointData extends PhysicsJointData {
  19607. /**
  19608. * Length of the spring
  19609. */
  19610. length: number;
  19611. /**
  19612. * Stiffness of the spring
  19613. */
  19614. stiffness: number;
  19615. /**
  19616. * Damping of the spring
  19617. */
  19618. damping: number;
  19619. /** this callback will be called when applying the force to the impostors. */
  19620. forceApplicationCallback: () => void;
  19621. }
  19622. }
  19623. declare module "babylonjs/Physics/IPhysicsEngine" {
  19624. import { Nullable } from "babylonjs/types";
  19625. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19627. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19628. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19629. /**
  19630. * Interface used to describe a physics joint
  19631. */
  19632. export interface PhysicsImpostorJoint {
  19633. /** Defines the main impostor to which the joint is linked */
  19634. mainImpostor: PhysicsImpostor;
  19635. /** Defines the impostor that is connected to the main impostor using this joint */
  19636. connectedImpostor: PhysicsImpostor;
  19637. /** Defines the joint itself */
  19638. joint: PhysicsJoint;
  19639. }
  19640. /** @hidden */
  19641. export interface IPhysicsEnginePlugin {
  19642. world: any;
  19643. name: string;
  19644. setGravity(gravity: Vector3): void;
  19645. setTimeStep(timeStep: number): void;
  19646. getTimeStep(): number;
  19647. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19651. removePhysicsBody(impostor: PhysicsImpostor): void;
  19652. generateJoint(joint: PhysicsImpostorJoint): void;
  19653. removeJoint(joint: PhysicsImpostorJoint): void;
  19654. isSupported(): boolean;
  19655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19657. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19659. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19662. getBodyMass(impostor: PhysicsImpostor): number;
  19663. getBodyFriction(impostor: PhysicsImpostor): number;
  19664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19665. getBodyRestitution(impostor: PhysicsImpostor): number;
  19666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19667. sleepBody(impostor: PhysicsImpostor): void;
  19668. wakeUpBody(impostor: PhysicsImpostor): void;
  19669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19670. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19671. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19672. getRadius(impostor: PhysicsImpostor): number;
  19673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19674. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19675. dispose(): void;
  19676. }
  19677. /**
  19678. * Interface used to define a physics engine
  19679. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export interface IPhysicsEngine {
  19682. /**
  19683. * Gets the gravity vector used by the simulation
  19684. */
  19685. gravity: Vector3;
  19686. /**
  19687. * Sets the gravity vector used by the simulation
  19688. * @param gravity defines the gravity vector to use
  19689. */
  19690. setGravity(gravity: Vector3): void;
  19691. /**
  19692. * Set the time step of the physics engine.
  19693. * Default is 1/60.
  19694. * To slow it down, enter 1/600 for example.
  19695. * To speed it up, 1/30
  19696. * @param newTimeStep the new timestep to apply to this world.
  19697. */
  19698. setTimeStep(newTimeStep: number): void;
  19699. /**
  19700. * Get the time step of the physics engine.
  19701. * @returns the current time step
  19702. */
  19703. getTimeStep(): number;
  19704. /**
  19705. * Release all resources
  19706. */
  19707. dispose(): void;
  19708. /**
  19709. * Gets the name of the current physics plugin
  19710. * @returns the name of the plugin
  19711. */
  19712. getPhysicsPluginName(): string;
  19713. /**
  19714. * Adding a new impostor for the impostor tracking.
  19715. * This will be done by the impostor itself.
  19716. * @param impostor the impostor to add
  19717. */
  19718. addImpostor(impostor: PhysicsImpostor): void;
  19719. /**
  19720. * Remove an impostor from the engine.
  19721. * This impostor and its mesh will not longer be updated by the physics engine.
  19722. * @param impostor the impostor to remove
  19723. */
  19724. removeImpostor(impostor: PhysicsImpostor): void;
  19725. /**
  19726. * Add a joint to the physics engine
  19727. * @param mainImpostor defines the main impostor to which the joint is added.
  19728. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19729. * @param joint defines the joint that will connect both impostors.
  19730. */
  19731. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19732. /**
  19733. * Removes a joint from the simulation
  19734. * @param mainImpostor defines the impostor used with the joint
  19735. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19736. * @param joint defines the joint to remove
  19737. */
  19738. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19739. /**
  19740. * Gets the current plugin used to run the simulation
  19741. * @returns current plugin
  19742. */
  19743. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19744. /**
  19745. * Gets the list of physic impostors
  19746. * @returns an array of PhysicsImpostor
  19747. */
  19748. getImpostors(): Array<PhysicsImpostor>;
  19749. /**
  19750. * Gets the impostor for a physics enabled object
  19751. * @param object defines the object impersonated by the impostor
  19752. * @returns the PhysicsImpostor or null if not found
  19753. */
  19754. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19755. /**
  19756. * Gets the impostor for a physics body object
  19757. * @param body defines physics body used by the impostor
  19758. * @returns the PhysicsImpostor or null if not found
  19759. */
  19760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19761. /**
  19762. * Called by the scene. No need to call it.
  19763. * @param delta defines the timespam between frames
  19764. */
  19765. _step(delta: number): void;
  19766. }
  19767. }
  19768. declare module "babylonjs/Physics/physicsImpostor" {
  19769. import { Nullable, IndicesArray } from "babylonjs/types";
  19770. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19773. import { Scene } from "babylonjs/scene";
  19774. import { Bone } from "babylonjs/Bones/bone";
  19775. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19776. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19777. /**
  19778. * The interface for the physics imposter parameters
  19779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19780. */
  19781. export interface PhysicsImpostorParameters {
  19782. /**
  19783. * The mass of the physics imposter
  19784. */
  19785. mass: number;
  19786. /**
  19787. * The friction of the physics imposter
  19788. */
  19789. friction?: number;
  19790. /**
  19791. * The coefficient of restitution of the physics imposter
  19792. */
  19793. restitution?: number;
  19794. /**
  19795. * The native options of the physics imposter
  19796. */
  19797. nativeOptions?: any;
  19798. /**
  19799. * Specifies if the parent should be ignored
  19800. */
  19801. ignoreParent?: boolean;
  19802. /**
  19803. * Specifies if bi-directional transformations should be disabled
  19804. */
  19805. disableBidirectionalTransformation?: boolean;
  19806. }
  19807. /**
  19808. * Interface for a physics-enabled object
  19809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19810. */
  19811. export interface IPhysicsEnabledObject {
  19812. /**
  19813. * The position of the physics-enabled object
  19814. */
  19815. position: Vector3;
  19816. /**
  19817. * The rotation of the physics-enabled object
  19818. */
  19819. rotationQuaternion: Nullable<Quaternion>;
  19820. /**
  19821. * The scale of the physics-enabled object
  19822. */
  19823. scaling: Vector3;
  19824. /**
  19825. * The rotation of the physics-enabled object
  19826. */
  19827. rotation?: Vector3;
  19828. /**
  19829. * The parent of the physics-enabled object
  19830. */
  19831. parent?: any;
  19832. /**
  19833. * The bounding info of the physics-enabled object
  19834. * @returns The bounding info of the physics-enabled object
  19835. */
  19836. getBoundingInfo(): BoundingInfo;
  19837. /**
  19838. * Computes the world matrix
  19839. * @param force Specifies if the world matrix should be computed by force
  19840. * @returns A world matrix
  19841. */
  19842. computeWorldMatrix(force: boolean): Matrix;
  19843. /**
  19844. * Gets the world matrix
  19845. * @returns A world matrix
  19846. */
  19847. getWorldMatrix?(): Matrix;
  19848. /**
  19849. * Gets the child meshes
  19850. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19851. * @returns An array of abstract meshes
  19852. */
  19853. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19854. /**
  19855. * Gets the vertex data
  19856. * @param kind The type of vertex data
  19857. * @returns A nullable array of numbers, or a float32 array
  19858. */
  19859. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19860. /**
  19861. * Gets the indices from the mesh
  19862. * @returns A nullable array of index arrays
  19863. */
  19864. getIndices?(): Nullable<IndicesArray>;
  19865. /**
  19866. * Gets the scene from the mesh
  19867. * @returns the indices array or null
  19868. */
  19869. getScene?(): Scene;
  19870. /**
  19871. * Gets the absolute position from the mesh
  19872. * @returns the absolute position
  19873. */
  19874. getAbsolutePosition(): Vector3;
  19875. /**
  19876. * Gets the absolute pivot point from the mesh
  19877. * @returns the absolute pivot point
  19878. */
  19879. getAbsolutePivotPoint(): Vector3;
  19880. /**
  19881. * Rotates the mesh
  19882. * @param axis The axis of rotation
  19883. * @param amount The amount of rotation
  19884. * @param space The space of the rotation
  19885. * @returns The rotation transform node
  19886. */
  19887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19888. /**
  19889. * Translates the mesh
  19890. * @param axis The axis of translation
  19891. * @param distance The distance of translation
  19892. * @param space The space of the translation
  19893. * @returns The transform node
  19894. */
  19895. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19896. /**
  19897. * Sets the absolute position of the mesh
  19898. * @param absolutePosition The absolute position of the mesh
  19899. * @returns The transform node
  19900. */
  19901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19902. /**
  19903. * Gets the class name of the mesh
  19904. * @returns The class name
  19905. */
  19906. getClassName(): string;
  19907. }
  19908. /**
  19909. * Represents a physics imposter
  19910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19911. */
  19912. export class PhysicsImpostor {
  19913. /**
  19914. * The physics-enabled object used as the physics imposter
  19915. */
  19916. object: IPhysicsEnabledObject;
  19917. /**
  19918. * The type of the physics imposter
  19919. */
  19920. type: number;
  19921. private _options;
  19922. private _scene?;
  19923. /**
  19924. * The default object size of the imposter
  19925. */
  19926. static DEFAULT_OBJECT_SIZE: Vector3;
  19927. /**
  19928. * The identity quaternion of the imposter
  19929. */
  19930. static IDENTITY_QUATERNION: Quaternion;
  19931. /** @hidden */
  19932. _pluginData: any;
  19933. private _physicsEngine;
  19934. private _physicsBody;
  19935. private _bodyUpdateRequired;
  19936. private _onBeforePhysicsStepCallbacks;
  19937. private _onAfterPhysicsStepCallbacks;
  19938. /** @hidden */
  19939. _onPhysicsCollideCallbacks: Array<{
  19940. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19941. otherImpostors: Array<PhysicsImpostor>;
  19942. }>;
  19943. private _deltaPosition;
  19944. private _deltaRotation;
  19945. private _deltaRotationConjugated;
  19946. private _parent;
  19947. private _isDisposed;
  19948. private static _tmpVecs;
  19949. private static _tmpQuat;
  19950. /**
  19951. * Specifies if the physics imposter is disposed
  19952. */
  19953. readonly isDisposed: boolean;
  19954. /**
  19955. * Gets the mass of the physics imposter
  19956. */
  19957. mass: number;
  19958. /**
  19959. * Gets the coefficient of friction
  19960. */
  19961. /**
  19962. * Sets the coefficient of friction
  19963. */
  19964. friction: number;
  19965. /**
  19966. * Gets the coefficient of restitution
  19967. */
  19968. /**
  19969. * Sets the coefficient of restitution
  19970. */
  19971. restitution: number;
  19972. /**
  19973. * The unique id of the physics imposter
  19974. * set by the physics engine when adding this impostor to the array
  19975. */
  19976. uniqueId: number;
  19977. private _joints;
  19978. /**
  19979. * Initializes the physics imposter
  19980. * @param object The physics-enabled object used as the physics imposter
  19981. * @param type The type of the physics imposter
  19982. * @param _options The options for the physics imposter
  19983. * @param _scene The Babylon scene
  19984. */
  19985. constructor(
  19986. /**
  19987. * The physics-enabled object used as the physics imposter
  19988. */
  19989. object: IPhysicsEnabledObject,
  19990. /**
  19991. * The type of the physics imposter
  19992. */
  19993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19994. /**
  19995. * This function will completly initialize this impostor.
  19996. * It will create a new body - but only if this mesh has no parent.
  19997. * If it has, this impostor will not be used other than to define the impostor
  19998. * of the child mesh.
  19999. * @hidden
  20000. */
  20001. _init(): void;
  20002. private _getPhysicsParent;
  20003. /**
  20004. * Should a new body be generated.
  20005. * @returns boolean specifying if body initialization is required
  20006. */
  20007. isBodyInitRequired(): boolean;
  20008. /**
  20009. * Sets the updated scaling
  20010. * @param updated Specifies if the scaling is updated
  20011. */
  20012. setScalingUpdated(): void;
  20013. /**
  20014. * Force a regeneration of this or the parent's impostor's body.
  20015. * Use under cautious - This will remove all joints already implemented.
  20016. */
  20017. forceUpdate(): void;
  20018. /**
  20019. * Gets the body that holds this impostor. Either its own, or its parent.
  20020. */
  20021. /**
  20022. * Set the physics body. Used mainly by the physics engine/plugin
  20023. */
  20024. physicsBody: any;
  20025. /**
  20026. * Get the parent of the physics imposter
  20027. * @returns Physics imposter or null
  20028. */
  20029. /**
  20030. * Sets the parent of the physics imposter
  20031. */
  20032. parent: Nullable<PhysicsImpostor>;
  20033. /**
  20034. * Resets the update flags
  20035. */
  20036. resetUpdateFlags(): void;
  20037. /**
  20038. * Gets the object extend size
  20039. * @returns the object extend size
  20040. */
  20041. getObjectExtendSize(): Vector3;
  20042. /**
  20043. * Gets the object center
  20044. * @returns The object center
  20045. */
  20046. getObjectCenter(): Vector3;
  20047. /**
  20048. * Get a specific parametes from the options parameter
  20049. * @param paramName The object parameter name
  20050. * @returns The object parameter
  20051. */
  20052. getParam(paramName: string): any;
  20053. /**
  20054. * Sets a specific parameter in the options given to the physics plugin
  20055. * @param paramName The parameter name
  20056. * @param value The value of the parameter
  20057. */
  20058. setParam(paramName: string, value: number): void;
  20059. /**
  20060. * Specifically change the body's mass option. Won't recreate the physics body object
  20061. * @param mass The mass of the physics imposter
  20062. */
  20063. setMass(mass: number): void;
  20064. /**
  20065. * Gets the linear velocity
  20066. * @returns linear velocity or null
  20067. */
  20068. getLinearVelocity(): Nullable<Vector3>;
  20069. /**
  20070. * Sets the linear velocity
  20071. * @param velocity linear velocity or null
  20072. */
  20073. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20074. /**
  20075. * Gets the angular velocity
  20076. * @returns angular velocity or null
  20077. */
  20078. getAngularVelocity(): Nullable<Vector3>;
  20079. /**
  20080. * Sets the angular velocity
  20081. * @param velocity The velocity or null
  20082. */
  20083. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20084. /**
  20085. * Execute a function with the physics plugin native code
  20086. * Provide a function the will have two variables - the world object and the physics body object
  20087. * @param func The function to execute with the physics plugin native code
  20088. */
  20089. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20090. /**
  20091. * Register a function that will be executed before the physics world is stepping forward
  20092. * @param func The function to execute before the physics world is stepped forward
  20093. */
  20094. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20095. /**
  20096. * Unregister a function that will be executed before the physics world is stepping forward
  20097. * @param func The function to execute before the physics world is stepped forward
  20098. */
  20099. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20100. /**
  20101. * Register a function that will be executed after the physics step
  20102. * @param func The function to execute after physics step
  20103. */
  20104. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20105. /**
  20106. * Unregisters a function that will be executed after the physics step
  20107. * @param func The function to execute after physics step
  20108. */
  20109. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20110. /**
  20111. * register a function that will be executed when this impostor collides against a different body
  20112. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20113. * @param func Callback that is executed on collision
  20114. */
  20115. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20116. /**
  20117. * Unregisters the physics imposter on contact
  20118. * @param collideAgainst The physics object to collide against
  20119. * @param func Callback to execute on collision
  20120. */
  20121. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20122. private _tmpQuat;
  20123. private _tmpQuat2;
  20124. /**
  20125. * Get the parent rotation
  20126. * @returns The parent rotation
  20127. */
  20128. getParentsRotation(): Quaternion;
  20129. /**
  20130. * this function is executed by the physics engine.
  20131. */
  20132. beforeStep: () => void;
  20133. /**
  20134. * this function is executed by the physics engine
  20135. */
  20136. afterStep: () => void;
  20137. /**
  20138. * Legacy collision detection event support
  20139. */
  20140. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20141. /**
  20142. * event and body object due to cannon's event-based architecture.
  20143. */
  20144. onCollide: (e: {
  20145. body: any;
  20146. }) => void;
  20147. /**
  20148. * Apply a force
  20149. * @param force The force to apply
  20150. * @param contactPoint The contact point for the force
  20151. * @returns The physics imposter
  20152. */
  20153. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20154. /**
  20155. * Apply an impulse
  20156. * @param force The impulse force
  20157. * @param contactPoint The contact point for the impulse force
  20158. * @returns The physics imposter
  20159. */
  20160. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20161. /**
  20162. * A help function to create a joint
  20163. * @param otherImpostor A physics imposter used to create a joint
  20164. * @param jointType The type of joint
  20165. * @param jointData The data for the joint
  20166. * @returns The physics imposter
  20167. */
  20168. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20169. /**
  20170. * Add a joint to this impostor with a different impostor
  20171. * @param otherImpostor A physics imposter used to add a joint
  20172. * @param joint The joint to add
  20173. * @returns The physics imposter
  20174. */
  20175. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20176. /**
  20177. * Will keep this body still, in a sleep mode.
  20178. * @returns the physics imposter
  20179. */
  20180. sleep(): PhysicsImpostor;
  20181. /**
  20182. * Wake the body up.
  20183. * @returns The physics imposter
  20184. */
  20185. wakeUp(): PhysicsImpostor;
  20186. /**
  20187. * Clones the physics imposter
  20188. * @param newObject The physics imposter clones to this physics-enabled object
  20189. * @returns A nullable physics imposter
  20190. */
  20191. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20192. /**
  20193. * Disposes the physics imposter
  20194. */
  20195. dispose(): void;
  20196. /**
  20197. * Sets the delta position
  20198. * @param position The delta position amount
  20199. */
  20200. setDeltaPosition(position: Vector3): void;
  20201. /**
  20202. * Sets the delta rotation
  20203. * @param rotation The delta rotation amount
  20204. */
  20205. setDeltaRotation(rotation: Quaternion): void;
  20206. /**
  20207. * Gets the box size of the physics imposter and stores the result in the input parameter
  20208. * @param result Stores the box size
  20209. * @returns The physics imposter
  20210. */
  20211. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20212. /**
  20213. * Gets the radius of the physics imposter
  20214. * @returns Radius of the physics imposter
  20215. */
  20216. getRadius(): number;
  20217. /**
  20218. * Sync a bone with this impostor
  20219. * @param bone The bone to sync to the impostor.
  20220. * @param boneMesh The mesh that the bone is influencing.
  20221. * @param jointPivot The pivot of the joint / bone in local space.
  20222. * @param distToJoint Optional distance from the impostor to the joint.
  20223. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20224. */
  20225. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20226. /**
  20227. * Sync impostor to a bone
  20228. * @param bone The bone that the impostor will be synced to.
  20229. * @param boneMesh The mesh that the bone is influencing.
  20230. * @param jointPivot The pivot of the joint / bone in local space.
  20231. * @param distToJoint Optional distance from the impostor to the joint.
  20232. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20233. * @param boneAxis Optional vector3 axis the bone is aligned with
  20234. */
  20235. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20236. /**
  20237. * No-Imposter type
  20238. */
  20239. static NoImpostor: number;
  20240. /**
  20241. * Sphere-Imposter type
  20242. */
  20243. static SphereImpostor: number;
  20244. /**
  20245. * Box-Imposter type
  20246. */
  20247. static BoxImpostor: number;
  20248. /**
  20249. * Plane-Imposter type
  20250. */
  20251. static PlaneImpostor: number;
  20252. /**
  20253. * Mesh-imposter type
  20254. */
  20255. static MeshImpostor: number;
  20256. /**
  20257. * Cylinder-Imposter type
  20258. */
  20259. static CylinderImpostor: number;
  20260. /**
  20261. * Particle-Imposter type
  20262. */
  20263. static ParticleImpostor: number;
  20264. /**
  20265. * Heightmap-Imposter type
  20266. */
  20267. static HeightmapImpostor: number;
  20268. }
  20269. }
  20270. declare module "babylonjs/Meshes/mesh" {
  20271. import { Observable } from "babylonjs/Misc/observable";
  20272. import { IAnimatable } from "babylonjs/Misc/tools";
  20273. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20274. import { Camera } from "babylonjs/Cameras/camera";
  20275. import { Scene } from "babylonjs/scene";
  20276. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20277. import { Engine } from "babylonjs/Engines/engine";
  20278. import { Node } from "babylonjs/node";
  20279. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20280. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20281. import { Buffer } from "babylonjs/Meshes/buffer";
  20282. import { Geometry } from "babylonjs/Meshes/geometry";
  20283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20285. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20286. import { Effect } from "babylonjs/Materials/effect";
  20287. import { Material } from "babylonjs/Materials/material";
  20288. import { Skeleton } from "babylonjs/Bones/skeleton";
  20289. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20290. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20291. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20292. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20293. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20295. /**
  20296. * Class used to represent a specific level of detail of a mesh
  20297. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20298. */
  20299. export class MeshLODLevel {
  20300. /** Defines the distance where this level should star being displayed */
  20301. distance: number;
  20302. /** Defines the mesh to use to render this level */
  20303. mesh: Nullable<Mesh>;
  20304. /**
  20305. * Creates a new LOD level
  20306. * @param distance defines the distance where this level should star being displayed
  20307. * @param mesh defines the mesh to use to render this level
  20308. */
  20309. constructor(
  20310. /** Defines the distance where this level should star being displayed */
  20311. distance: number,
  20312. /** Defines the mesh to use to render this level */
  20313. mesh: Nullable<Mesh>);
  20314. }
  20315. /**
  20316. * @hidden
  20317. **/
  20318. export class _CreationDataStorage {
  20319. closePath?: boolean;
  20320. closeArray?: boolean;
  20321. idx: number[];
  20322. dashSize: number;
  20323. gapSize: number;
  20324. path3D: Path3D;
  20325. pathArray: Vector3[][];
  20326. arc: number;
  20327. radius: number;
  20328. cap: number;
  20329. tessellation: number;
  20330. }
  20331. /**
  20332. * @hidden
  20333. **/
  20334. class _InstanceDataStorage {
  20335. visibleInstances: any;
  20336. renderIdForInstances: number[];
  20337. batchCache: _InstancesBatch;
  20338. instancesBufferSize: number;
  20339. instancesBuffer: Nullable<Buffer>;
  20340. instancesData: Float32Array;
  20341. overridenInstanceCount: number;
  20342. }
  20343. /**
  20344. * @hidden
  20345. **/
  20346. export class _InstancesBatch {
  20347. mustReturn: boolean;
  20348. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20349. renderSelf: boolean[];
  20350. }
  20351. /**
  20352. * Class used to represent renderable models
  20353. */
  20354. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20355. /**
  20356. * Mesh side orientation : usually the external or front surface
  20357. */
  20358. static readonly FRONTSIDE: number;
  20359. /**
  20360. * Mesh side orientation : usually the internal or back surface
  20361. */
  20362. static readonly BACKSIDE: number;
  20363. /**
  20364. * Mesh side orientation : both internal and external or front and back surfaces
  20365. */
  20366. static readonly DOUBLESIDE: number;
  20367. /**
  20368. * Mesh side orientation : by default, `FRONTSIDE`
  20369. */
  20370. static readonly DEFAULTSIDE: number;
  20371. /**
  20372. * Mesh cap setting : no cap
  20373. */
  20374. static readonly NO_CAP: number;
  20375. /**
  20376. * Mesh cap setting : one cap at the beginning of the mesh
  20377. */
  20378. static readonly CAP_START: number;
  20379. /**
  20380. * Mesh cap setting : one cap at the end of the mesh
  20381. */
  20382. static readonly CAP_END: number;
  20383. /**
  20384. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20385. */
  20386. static readonly CAP_ALL: number;
  20387. /**
  20388. * Gets the default side orientation.
  20389. * @param orientation the orientation to value to attempt to get
  20390. * @returns the default orientation
  20391. * @hidden
  20392. */
  20393. static _GetDefaultSideOrientation(orientation?: number): number;
  20394. private _onBeforeRenderObservable;
  20395. private _onBeforeBindObservable;
  20396. private _onAfterRenderObservable;
  20397. private _onBeforeDrawObservable;
  20398. /**
  20399. * An event triggered before rendering the mesh
  20400. */
  20401. readonly onBeforeRenderObservable: Observable<Mesh>;
  20402. /**
  20403. * An event triggered before binding the mesh
  20404. */
  20405. readonly onBeforeBindObservable: Observable<Mesh>;
  20406. /**
  20407. * An event triggered after rendering the mesh
  20408. */
  20409. readonly onAfterRenderObservable: Observable<Mesh>;
  20410. /**
  20411. * An event triggered before drawing the mesh
  20412. */
  20413. readonly onBeforeDrawObservable: Observable<Mesh>;
  20414. private _onBeforeDrawObserver;
  20415. /**
  20416. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20417. */
  20418. onBeforeDraw: () => void;
  20419. /**
  20420. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20421. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20422. */
  20423. delayLoadState: number;
  20424. /**
  20425. * Gets the list of instances created from this mesh
  20426. * it is not supposed to be modified manually.
  20427. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20428. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20429. */
  20430. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20431. /**
  20432. * Gets the file containing delay loading data for this mesh
  20433. */
  20434. delayLoadingFile: string;
  20435. /** @hidden */
  20436. _binaryInfo: any;
  20437. private _LODLevels;
  20438. /**
  20439. * User defined function used to change how LOD level selection is done
  20440. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20441. */
  20442. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20443. private _morphTargetManager;
  20444. /**
  20445. * Gets or sets the morph target manager
  20446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20447. */
  20448. morphTargetManager: Nullable<MorphTargetManager>;
  20449. /** @hidden */
  20450. _creationDataStorage: Nullable<_CreationDataStorage>;
  20451. /** @hidden */
  20452. _geometry: Nullable<Geometry>;
  20453. /** @hidden */
  20454. _delayInfo: Array<string>;
  20455. /** @hidden */
  20456. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20457. /** @hidden */
  20458. _instanceDataStorage: _InstanceDataStorage;
  20459. private _effectiveMaterial;
  20460. /** @hidden */
  20461. _shouldGenerateFlatShading: boolean;
  20462. private _preActivateId;
  20463. /** @hidden */
  20464. _originalBuilderSideOrientation: number;
  20465. /**
  20466. * Use this property to change the original side orientation defined at construction time
  20467. */
  20468. overrideMaterialSideOrientation: Nullable<number>;
  20469. private _areNormalsFrozen;
  20470. private _sourcePositions;
  20471. private _sourceNormals;
  20472. private _source;
  20473. private meshMap;
  20474. /**
  20475. * Gets the source mesh (the one used to clone this one from)
  20476. */
  20477. readonly source: Nullable<Mesh>;
  20478. /**
  20479. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20480. */
  20481. isUnIndexed: boolean;
  20482. /**
  20483. * @constructor
  20484. * @param name The value used by scene.getMeshByName() to do a lookup.
  20485. * @param scene The scene to add this mesh to.
  20486. * @param parent The parent of this mesh, if it has one
  20487. * @param source An optional Mesh from which geometry is shared, cloned.
  20488. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20489. * When false, achieved by calling a clone(), also passing False.
  20490. * This will make creation of children, recursive.
  20491. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20492. */
  20493. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20494. /**
  20495. * Gets the class name
  20496. * @returns the string "Mesh".
  20497. */
  20498. getClassName(): string;
  20499. /** @hidden */
  20500. readonly _isMesh: boolean;
  20501. /**
  20502. * Returns a description of this mesh
  20503. * @param fullDetails define if full details about this mesh must be used
  20504. * @returns a descriptive string representing this mesh
  20505. */
  20506. toString(fullDetails?: boolean): string;
  20507. /** @hidden */
  20508. _unBindEffect(): void;
  20509. /**
  20510. * Gets a boolean indicating if this mesh has LOD
  20511. */
  20512. readonly hasLODLevels: boolean;
  20513. /**
  20514. * Gets the list of MeshLODLevel associated with the current mesh
  20515. * @returns an array of MeshLODLevel
  20516. */
  20517. getLODLevels(): MeshLODLevel[];
  20518. private _sortLODLevels;
  20519. /**
  20520. * Add a mesh as LOD level triggered at the given distance.
  20521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20522. * @param distance The distance from the center of the object to show this level
  20523. * @param mesh The mesh to be added as LOD level (can be null)
  20524. * @return This mesh (for chaining)
  20525. */
  20526. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20527. /**
  20528. * Returns the LOD level mesh at the passed distance or null if not found.
  20529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20530. * @param distance The distance from the center of the object to show this level
  20531. * @returns a Mesh or `null`
  20532. */
  20533. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20534. /**
  20535. * Remove a mesh from the LOD array
  20536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20537. * @param mesh defines the mesh to be removed
  20538. * @return This mesh (for chaining)
  20539. */
  20540. removeLODLevel(mesh: Mesh): Mesh;
  20541. /**
  20542. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20544. * @param camera defines the camera to use to compute distance
  20545. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20546. * @return This mesh (for chaining)
  20547. */
  20548. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20549. /**
  20550. * Gets the mesh internal Geometry object
  20551. */
  20552. readonly geometry: Nullable<Geometry>;
  20553. /**
  20554. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20555. * @returns the total number of vertices
  20556. */
  20557. getTotalVertices(): number;
  20558. /**
  20559. * Returns the content of an associated vertex buffer
  20560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20561. * - VertexBuffer.PositionKind
  20562. * - VertexBuffer.UVKind
  20563. * - VertexBuffer.UV2Kind
  20564. * - VertexBuffer.UV3Kind
  20565. * - VertexBuffer.UV4Kind
  20566. * - VertexBuffer.UV5Kind
  20567. * - VertexBuffer.UV6Kind
  20568. * - VertexBuffer.ColorKind
  20569. * - VertexBuffer.MatricesIndicesKind
  20570. * - VertexBuffer.MatricesIndicesExtraKind
  20571. * - VertexBuffer.MatricesWeightsKind
  20572. * - VertexBuffer.MatricesWeightsExtraKind
  20573. * @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
  20574. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20575. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20576. */
  20577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20578. /**
  20579. * Returns the mesh VertexBuffer object from the requested `kind`
  20580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20581. * - VertexBuffer.PositionKind
  20582. * - VertexBuffer.UVKind
  20583. * - VertexBuffer.UV2Kind
  20584. * - VertexBuffer.UV3Kind
  20585. * - VertexBuffer.UV4Kind
  20586. * - VertexBuffer.UV5Kind
  20587. * - VertexBuffer.UV6Kind
  20588. * - VertexBuffer.ColorKind
  20589. * - VertexBuffer.MatricesIndicesKind
  20590. * - VertexBuffer.MatricesIndicesExtraKind
  20591. * - VertexBuffer.MatricesWeightsKind
  20592. * - VertexBuffer.MatricesWeightsExtraKind
  20593. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20594. */
  20595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20596. /**
  20597. * Tests if a specific vertex buffer is associated with this mesh
  20598. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20599. * - VertexBuffer.PositionKind
  20600. * - VertexBuffer.UVKind
  20601. * - VertexBuffer.UV2Kind
  20602. * - VertexBuffer.UV3Kind
  20603. * - VertexBuffer.UV4Kind
  20604. * - VertexBuffer.UV5Kind
  20605. * - VertexBuffer.UV6Kind
  20606. * - VertexBuffer.ColorKind
  20607. * - VertexBuffer.MatricesIndicesKind
  20608. * - VertexBuffer.MatricesIndicesExtraKind
  20609. * - VertexBuffer.MatricesWeightsKind
  20610. * - VertexBuffer.MatricesWeightsExtraKind
  20611. * @returns a boolean
  20612. */
  20613. isVerticesDataPresent(kind: string): boolean;
  20614. /**
  20615. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20616. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20617. * - VertexBuffer.PositionKind
  20618. * - VertexBuffer.UVKind
  20619. * - VertexBuffer.UV2Kind
  20620. * - VertexBuffer.UV3Kind
  20621. * - VertexBuffer.UV4Kind
  20622. * - VertexBuffer.UV5Kind
  20623. * - VertexBuffer.UV6Kind
  20624. * - VertexBuffer.ColorKind
  20625. * - VertexBuffer.MatricesIndicesKind
  20626. * - VertexBuffer.MatricesIndicesExtraKind
  20627. * - VertexBuffer.MatricesWeightsKind
  20628. * - VertexBuffer.MatricesWeightsExtraKind
  20629. * @returns a boolean
  20630. */
  20631. isVertexBufferUpdatable(kind: string): boolean;
  20632. /**
  20633. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20634. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20635. * - VertexBuffer.PositionKind
  20636. * - VertexBuffer.UVKind
  20637. * - VertexBuffer.UV2Kind
  20638. * - VertexBuffer.UV3Kind
  20639. * - VertexBuffer.UV4Kind
  20640. * - VertexBuffer.UV5Kind
  20641. * - VertexBuffer.UV6Kind
  20642. * - VertexBuffer.ColorKind
  20643. * - VertexBuffer.MatricesIndicesKind
  20644. * - VertexBuffer.MatricesIndicesExtraKind
  20645. * - VertexBuffer.MatricesWeightsKind
  20646. * - VertexBuffer.MatricesWeightsExtraKind
  20647. * @returns an array of strings
  20648. */
  20649. getVerticesDataKinds(): string[];
  20650. /**
  20651. * Returns a positive integer : the total number of indices in this mesh geometry.
  20652. * @returns the numner of indices or zero if the mesh has no geometry.
  20653. */
  20654. getTotalIndices(): number;
  20655. /**
  20656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20657. * @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.
  20658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20659. * @returns the indices array or an empty array if the mesh has no geometry
  20660. */
  20661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20662. readonly isBlocked: boolean;
  20663. /**
  20664. * Determine if the current mesh is ready to be rendered
  20665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20667. * @returns true if all associated assets are ready (material, textures, shaders)
  20668. */
  20669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20670. /**
  20671. * 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.
  20672. */
  20673. readonly areNormalsFrozen: boolean;
  20674. /**
  20675. * 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.
  20676. * @returns the current mesh
  20677. */
  20678. freezeNormals(): Mesh;
  20679. /**
  20680. * 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
  20681. * @returns the current mesh
  20682. */
  20683. unfreezeNormals(): Mesh;
  20684. /**
  20685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20686. */
  20687. overridenInstanceCount: number;
  20688. /** @hidden */
  20689. _preActivate(): Mesh;
  20690. /** @hidden */
  20691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20692. /** @hidden */
  20693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20694. /**
  20695. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20696. * This means the mesh underlying bounding box and sphere are recomputed.
  20697. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20698. * @returns the current mesh
  20699. */
  20700. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20701. /** @hidden */
  20702. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20703. /**
  20704. * This function will subdivide the mesh into multiple submeshes
  20705. * @param count defines the expected number of submeshes
  20706. */
  20707. subdivide(count: number): void;
  20708. /**
  20709. * Copy a FloatArray into a specific associated vertex buffer
  20710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @param data defines the data source
  20724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20725. * @param stride defines the data stride size (can be null)
  20726. * @returns the current mesh
  20727. */
  20728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20729. /**
  20730. * Flags an associated vertex buffer as updatable
  20731. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20732. * - VertexBuffer.PositionKind
  20733. * - VertexBuffer.UVKind
  20734. * - VertexBuffer.UV2Kind
  20735. * - VertexBuffer.UV3Kind
  20736. * - VertexBuffer.UV4Kind
  20737. * - VertexBuffer.UV5Kind
  20738. * - VertexBuffer.UV6Kind
  20739. * - VertexBuffer.ColorKind
  20740. * - VertexBuffer.MatricesIndicesKind
  20741. * - VertexBuffer.MatricesIndicesExtraKind
  20742. * - VertexBuffer.MatricesWeightsKind
  20743. * - VertexBuffer.MatricesWeightsExtraKind
  20744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20745. */
  20746. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20747. /**
  20748. * Sets the mesh global Vertex Buffer
  20749. * @param buffer defines the buffer to use
  20750. * @returns the current mesh
  20751. */
  20752. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20753. /**
  20754. * Update a specific associated vertex buffer
  20755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20756. * - VertexBuffer.PositionKind
  20757. * - VertexBuffer.UVKind
  20758. * - VertexBuffer.UV2Kind
  20759. * - VertexBuffer.UV3Kind
  20760. * - VertexBuffer.UV4Kind
  20761. * - VertexBuffer.UV5Kind
  20762. * - VertexBuffer.UV6Kind
  20763. * - VertexBuffer.ColorKind
  20764. * - VertexBuffer.MatricesIndicesKind
  20765. * - VertexBuffer.MatricesIndicesExtraKind
  20766. * - VertexBuffer.MatricesWeightsKind
  20767. * - VertexBuffer.MatricesWeightsExtraKind
  20768. * @param data defines the data source
  20769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20770. * @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)
  20771. * @returns the current mesh
  20772. */
  20773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20774. /**
  20775. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20777. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20778. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20779. * @returns the current mesh
  20780. */
  20781. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20782. /**
  20783. * Creates a un-shared specific occurence of the geometry for the mesh.
  20784. * @returns the current mesh
  20785. */
  20786. makeGeometryUnique(): Mesh;
  20787. /**
  20788. * Set the index buffer of this mesh
  20789. * @param indices defines the source data
  20790. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20791. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20792. * @returns the current mesh
  20793. */
  20794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20795. /**
  20796. * Update the current index buffer
  20797. * @param indices defines the source data
  20798. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20799. * @returns the current mesh
  20800. */
  20801. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20802. /**
  20803. * Invert the geometry to move from a right handed system to a left handed one.
  20804. * @returns the current mesh
  20805. */
  20806. toLeftHanded(): Mesh;
  20807. /** @hidden */
  20808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20809. /** @hidden */
  20810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20811. /**
  20812. * Registers for this mesh a javascript function called just before the rendering process
  20813. * @param func defines the function to call before rendering this mesh
  20814. * @returns the current mesh
  20815. */
  20816. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20817. /**
  20818. * Disposes a previously registered javascript function called before the rendering
  20819. * @param func defines the function to remove
  20820. * @returns the current mesh
  20821. */
  20822. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20823. /**
  20824. * Registers for this mesh a javascript function called just after the rendering is complete
  20825. * @param func defines the function to call after rendering this mesh
  20826. * @returns the current mesh
  20827. */
  20828. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20829. /**
  20830. * Disposes a previously registered javascript function called after the rendering.
  20831. * @param func defines the function to remove
  20832. * @returns the current mesh
  20833. */
  20834. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20835. /** @hidden */
  20836. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20837. /** @hidden */
  20838. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20839. /** @hidden */
  20840. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20841. /**
  20842. * 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
  20843. * @param subMesh defines the subMesh to render
  20844. * @param enableAlphaMode defines if alpha mode can be changed
  20845. * @returns the current mesh
  20846. */
  20847. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20848. private _onBeforeDraw;
  20849. /**
  20850. * Renormalize the mesh and patch it up if there are no weights
  20851. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20852. * However in the case of zero weights then we set just a single influence to 1.
  20853. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20854. */
  20855. cleanMatrixWeights(): void;
  20856. private normalizeSkinFourWeights;
  20857. private normalizeSkinWeightsAndExtra;
  20858. /**
  20859. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20860. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20861. * the user know there was an issue with importing the mesh
  20862. * @returns a validation object with skinned, valid and report string
  20863. */
  20864. validateSkinning(): {
  20865. skinned: boolean;
  20866. valid: boolean;
  20867. report: string;
  20868. };
  20869. /** @hidden */
  20870. _checkDelayState(): Mesh;
  20871. private _queueLoad;
  20872. /**
  20873. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20874. * A mesh is in the frustum if its bounding box intersects the frustum
  20875. * @param frustumPlanes defines the frustum to test
  20876. * @returns true if the mesh is in the frustum planes
  20877. */
  20878. isInFrustum(frustumPlanes: Plane[]): boolean;
  20879. /**
  20880. * Sets the mesh material by the material or multiMaterial `id` property
  20881. * @param id is a string identifying the material or the multiMaterial
  20882. * @returns the current mesh
  20883. */
  20884. setMaterialByID(id: string): Mesh;
  20885. /**
  20886. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20887. * @returns an array of IAnimatable
  20888. */
  20889. getAnimatables(): IAnimatable[];
  20890. /**
  20891. * Modifies the mesh geometry according to the passed transformation matrix.
  20892. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20893. * The mesh normals are modified using the same transformation.
  20894. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20895. * @param transform defines the transform matrix to use
  20896. * @see http://doc.babylonjs.com/resources/baking_transformations
  20897. * @returns the current mesh
  20898. */
  20899. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20900. /**
  20901. * Modifies the mesh geometry according to its own current World Matrix.
  20902. * The mesh World Matrix is then reset.
  20903. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20904. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20905. * @see http://doc.babylonjs.com/resources/baking_transformations
  20906. * @returns the current mesh
  20907. */
  20908. bakeCurrentTransformIntoVertices(): Mesh;
  20909. /** @hidden */
  20910. readonly _positions: Nullable<Vector3[]>;
  20911. /** @hidden */
  20912. _resetPointsArrayCache(): Mesh;
  20913. /** @hidden */
  20914. _generatePointsArray(): boolean;
  20915. /**
  20916. * Returns a new Mesh object generated from the current mesh properties.
  20917. * This method must not get confused with createInstance()
  20918. * @param name is a string, the name given to the new mesh
  20919. * @param newParent can be any Node object (default `null`)
  20920. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20921. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20922. * @returns a new mesh
  20923. */
  20924. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20925. /**
  20926. * Releases resources associated with this mesh.
  20927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20929. */
  20930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20931. /**
  20932. * Modifies the mesh geometry according to a displacement map.
  20933. * 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.
  20934. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20935. * @param url is a string, the URL from the image file is to be downloaded.
  20936. * @param minHeight is the lower limit of the displacement.
  20937. * @param maxHeight is the upper limit of the displacement.
  20938. * @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.
  20939. * @param uvOffset is an optional vector2 used to offset UV.
  20940. * @param uvScale is an optional vector2 used to scale UV.
  20941. * @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.
  20942. * @returns the Mesh.
  20943. */
  20944. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20945. /**
  20946. * Modifies the mesh geometry according to a displacementMap buffer.
  20947. * 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.
  20948. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20949. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20950. * @param heightMapWidth is the width of the buffer image.
  20951. * @param heightMapHeight is the height of the buffer image.
  20952. * @param minHeight is the lower limit of the displacement.
  20953. * @param maxHeight is the upper limit of the displacement.
  20954. * @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.
  20955. * @param uvOffset is an optional vector2 used to offset UV.
  20956. * @param uvScale is an optional vector2 used to scale UV.
  20957. * @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.
  20958. * @returns the Mesh.
  20959. */
  20960. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20961. /**
  20962. * Modify the mesh to get a flat shading rendering.
  20963. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20964. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20965. * @returns current mesh
  20966. */
  20967. convertToFlatShadedMesh(): Mesh;
  20968. /**
  20969. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20970. * In other words, more vertices, no more indices and a single bigger VBO.
  20971. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20972. * @returns current mesh
  20973. */
  20974. convertToUnIndexedMesh(): Mesh;
  20975. /**
  20976. * Inverses facet orientations.
  20977. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20978. * @param flipNormals will also inverts the normals
  20979. * @returns current mesh
  20980. */
  20981. flipFaces(flipNormals?: boolean): Mesh;
  20982. /** @hidden */
  20983. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20984. /** @hidden */
  20985. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20986. /**
  20987. * Creates a new InstancedMesh object from the mesh model.
  20988. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20989. * @param name defines the name of the new instance
  20990. * @returns a new InstancedMesh
  20991. */
  20992. createInstance(name: string): InstancedMesh;
  20993. /**
  20994. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20995. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20996. * @returns the current mesh
  20997. */
  20998. synchronizeInstances(): Mesh;
  20999. /**
  21000. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21001. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21002. * This should be used together with the simplification to avoid disappearing triangles.
  21003. * @param successCallback an optional success callback to be called after the optimization finished.
  21004. * @returns the current mesh
  21005. */
  21006. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21007. /**
  21008. * Serialize current mesh
  21009. * @param serializationObject defines the object which will receive the serialization data
  21010. */
  21011. serialize(serializationObject: any): void;
  21012. /** @hidden */
  21013. _syncGeometryWithMorphTargetManager(): void;
  21014. /** @hidden */
  21015. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21016. /**
  21017. * Returns a new Mesh object parsed from the source provided.
  21018. * @param parsedMesh is the source
  21019. * @param scene defines the hosting scene
  21020. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21021. * @returns a new Mesh
  21022. */
  21023. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21024. /**
  21025. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21026. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21027. * @param name defines the name of the mesh to create
  21028. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21029. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21030. * @param closePath creates a seam between the first and the last points of each path of the path array
  21031. * @param offset is taken in account only if the `pathArray` is containing a single path
  21032. * @param scene defines the hosting scene
  21033. * @param updatable defines if the mesh must be flagged as updatable
  21034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21035. * @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)
  21036. * @returns a new Mesh
  21037. */
  21038. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21039. /**
  21040. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21041. * @param name defines the name of the mesh to create
  21042. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21043. * @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
  21044. * @param scene defines the hosting scene
  21045. * @param updatable defines if the mesh must be flagged as updatable
  21046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21047. * @returns a new Mesh
  21048. */
  21049. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21050. /**
  21051. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21052. * @param name defines the name of the mesh to create
  21053. * @param size sets the size (float) of each box side (default 1)
  21054. * @param scene defines the hosting scene
  21055. * @param updatable defines if the mesh must be flagged as updatable
  21056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21057. * @returns a new Mesh
  21058. */
  21059. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21060. /**
  21061. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21062. * @param name defines the name of the mesh to create
  21063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21065. * @param scene defines the hosting scene
  21066. * @param updatable defines if the mesh must be flagged as updatable
  21067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21068. * @returns a new Mesh
  21069. */
  21070. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21071. /**
  21072. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21073. * @param name defines the name of the mesh to create
  21074. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21075. * @param diameterTop set the top cap diameter (floats, default 1)
  21076. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21077. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21078. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21079. * @param scene defines the hosting scene
  21080. * @param updatable defines if the mesh must be flagged as updatable
  21081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21082. * @returns a new Mesh
  21083. */
  21084. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21085. /**
  21086. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21087. * @param name defines the name of the mesh to create
  21088. * @param diameter sets the diameter size (float) of the torus (default 1)
  21089. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21090. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21091. * @param scene defines the hosting scene
  21092. * @param updatable defines if the mesh must be flagged as updatable
  21093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21094. * @returns a new Mesh
  21095. */
  21096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21097. /**
  21098. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21099. * @param name defines the name of the mesh to create
  21100. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21101. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21102. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21103. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21104. * @param p the number of windings on X axis (positive integers, default 2)
  21105. * @param q the number of windings on Y axis (positive integers, default 3)
  21106. * @param scene defines the hosting scene
  21107. * @param updatable defines if the mesh must be flagged as updatable
  21108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21109. * @returns a new Mesh
  21110. */
  21111. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21112. /**
  21113. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21114. * @param name defines the name of the mesh to create
  21115. * @param points is an array successive Vector3
  21116. * @param scene defines the hosting scene
  21117. * @param updatable defines if the mesh must be flagged as updatable
  21118. * @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).
  21119. * @returns a new Mesh
  21120. */
  21121. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21122. /**
  21123. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21124. * @param name defines the name of the mesh to create
  21125. * @param points is an array successive Vector3
  21126. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21127. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21128. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21129. * @param scene defines the hosting scene
  21130. * @param updatable defines if the mesh must be flagged as updatable
  21131. * @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)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21135. /**
  21136. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21138. * 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.
  21139. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21141. * Remember you can only change the shape positions, not their number when updating a polygon.
  21142. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21143. * @param name defines the name of the mesh to create
  21144. * @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
  21145. * @param scene defines the hosting scene
  21146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21147. * @param updatable defines if the mesh must be flagged as updatable
  21148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21149. * @param earcutInjection can be used to inject your own earcut reference
  21150. * @returns a new Mesh
  21151. */
  21152. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21153. /**
  21154. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21156. * @param name defines the name of the mesh to create
  21157. * @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
  21158. * @param depth defines the height of extrusion
  21159. * @param scene defines the hosting scene
  21160. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21161. * @param updatable defines if the mesh must be flagged as updatable
  21162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21163. * @param earcutInjection can be used to inject your own earcut reference
  21164. * @returns a new Mesh
  21165. */
  21166. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21167. /**
  21168. * Creates an extruded shape mesh.
  21169. * 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
  21170. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21172. * @param name defines the name of the mesh to create
  21173. * @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
  21174. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21175. * @param scale is the value to scale the shape
  21176. * @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
  21177. * @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
  21178. * @param scene defines the hosting scene
  21179. * @param updatable defines if the mesh must be flagged as updatable
  21180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21181. * @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)
  21182. * @returns a new Mesh
  21183. */
  21184. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21185. /**
  21186. * Creates an custom extruded shape mesh.
  21187. * The custom extrusion is a parametric shape.
  21188. * It has no predefined shape. Its final shape will depend on the input parameters.
  21189. * Please consider using the same method from the MeshBuilder class instead
  21190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21191. * @param name defines the name of the mesh to create
  21192. * @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
  21193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21194. * @param scaleFunction is a custom Javascript function called on each path point
  21195. * @param rotationFunction is a custom Javascript function called on each path point
  21196. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21197. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21198. * @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
  21199. * @param scene defines the hosting scene
  21200. * @param updatable defines if the mesh must be flagged as updatable
  21201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21202. * @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)
  21203. * @returns a new Mesh
  21204. */
  21205. 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;
  21206. /**
  21207. * Creates lathe mesh.
  21208. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21209. * Please consider using the same method from the MeshBuilder class instead
  21210. * @param name defines the name of the mesh to create
  21211. * @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
  21212. * @param radius is the radius value of the lathe
  21213. * @param tessellation is the side number of the lathe.
  21214. * @param scene defines the hosting scene
  21215. * @param updatable defines if the mesh must be flagged as updatable
  21216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21217. * @returns a new Mesh
  21218. */
  21219. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21220. /**
  21221. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21222. * @param name defines the name of the mesh to create
  21223. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21224. * @param scene defines the hosting scene
  21225. * @param updatable defines if the mesh must be flagged as updatable
  21226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21227. * @returns a new Mesh
  21228. */
  21229. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21230. /**
  21231. * Creates a ground mesh.
  21232. * Please consider using the same method from the MeshBuilder class instead
  21233. * @param name defines the name of the mesh to create
  21234. * @param width set the width of the ground
  21235. * @param height set the height of the ground
  21236. * @param subdivisions sets the number of subdivisions per side
  21237. * @param scene defines the hosting scene
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @returns a new Mesh
  21240. */
  21241. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21242. /**
  21243. * Creates a tiled ground mesh.
  21244. * Please consider using the same method from the MeshBuilder class instead
  21245. * @param name defines the name of the mesh to create
  21246. * @param xmin set the ground minimum X coordinate
  21247. * @param zmin set the ground minimum Y coordinate
  21248. * @param xmax set the ground maximum X coordinate
  21249. * @param zmax set the ground maximum Z coordinate
  21250. * @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
  21251. * @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
  21252. * @param scene defines the hosting scene
  21253. * @param updatable defines if the mesh must be flagged as updatable
  21254. * @returns a new Mesh
  21255. */
  21256. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21257. w: number;
  21258. h: number;
  21259. }, precision: {
  21260. w: number;
  21261. h: number;
  21262. }, scene: Scene, updatable?: boolean): Mesh;
  21263. /**
  21264. * Creates a ground mesh from a height map.
  21265. * Please consider using the same method from the MeshBuilder class instead
  21266. * @see http://doc.babylonjs.com/babylon101/height_map
  21267. * @param name defines the name of the mesh to create
  21268. * @param url sets the URL of the height map image resource
  21269. * @param width set the ground width size
  21270. * @param height set the ground height size
  21271. * @param subdivisions sets the number of subdivision per side
  21272. * @param minHeight is the minimum altitude on the ground
  21273. * @param maxHeight is the maximum altitude on the ground
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21277. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21278. * @returns a new Mesh
  21279. */
  21280. 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;
  21281. /**
  21282. * Creates a tube mesh.
  21283. * The tube is a parametric shape.
  21284. * It has no predefined shape. Its final shape will depend on the input parameters.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21287. * @param name defines the name of the mesh to create
  21288. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21289. * @param radius sets the tube radius size
  21290. * @param tessellation is the number of sides on the tubular surface
  21291. * @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
  21292. * @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
  21293. * @param scene defines the hosting scene
  21294. * @param updatable defines if the mesh must be flagged as updatable
  21295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21296. * @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)
  21297. * @returns a new Mesh
  21298. */
  21299. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21300. (i: number, distance: number): number;
  21301. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21302. /**
  21303. * Creates a polyhedron mesh.
  21304. * Please consider using the same method from the MeshBuilder class instead.
  21305. * * 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
  21306. * * The parameter `size` (positive float, default 1) sets the polygon size
  21307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21308. * * 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`
  21309. * * 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
  21310. * * 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)`)
  21311. * * 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
  21312. * * 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
  21313. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21314. * * If you create a double-sided mesh, you can choose what parts of 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
  21315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21316. * @param name defines the name of the mesh to create
  21317. * @param options defines the options used to create the mesh
  21318. * @param scene defines the hosting scene
  21319. * @returns a new Mesh
  21320. */
  21321. static CreatePolyhedron(name: string, options: {
  21322. type?: number;
  21323. size?: number;
  21324. sizeX?: number;
  21325. sizeY?: number;
  21326. sizeZ?: number;
  21327. custom?: any;
  21328. faceUV?: Vector4[];
  21329. faceColors?: Color4[];
  21330. updatable?: boolean;
  21331. sideOrientation?: number;
  21332. }, scene: Scene): Mesh;
  21333. /**
  21334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21336. * * 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`)
  21337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21338. * * 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
  21339. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21340. * * If you create a double-sided mesh, you can choose what parts of 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
  21341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21342. * @param name defines the name of the mesh
  21343. * @param options defines the options used to create the mesh
  21344. * @param scene defines the hosting scene
  21345. * @returns a new Mesh
  21346. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21347. */
  21348. static CreateIcoSphere(name: string, options: {
  21349. radius?: number;
  21350. flat?: boolean;
  21351. subdivisions?: number;
  21352. sideOrientation?: number;
  21353. updatable?: boolean;
  21354. }, scene: Scene): Mesh;
  21355. /**
  21356. * Creates a decal mesh.
  21357. * Please consider using the same method from the MeshBuilder class instead.
  21358. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21359. * @param name defines the name of the mesh
  21360. * @param sourceMesh defines the mesh receiving the decal
  21361. * @param position sets the position of the decal in world coordinates
  21362. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21363. * @param size sets the decal scaling
  21364. * @param angle sets the angle to rotate the decal
  21365. * @returns a new Mesh
  21366. */
  21367. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21368. /**
  21369. * Prepare internal position array for software CPU skinning
  21370. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21371. */
  21372. setPositionsForCPUSkinning(): Float32Array;
  21373. /**
  21374. * Prepare internal normal array for software CPU skinning
  21375. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21376. */
  21377. setNormalsForCPUSkinning(): Float32Array;
  21378. /**
  21379. * Updates the vertex buffer by applying transformation from the bones
  21380. * @param skeleton defines the skeleton to apply to current mesh
  21381. * @returns the current mesh
  21382. */
  21383. applySkeleton(skeleton: Skeleton): Mesh;
  21384. /**
  21385. * 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
  21386. * @param meshes defines the list of meshes to scan
  21387. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21388. */
  21389. static MinMax(meshes: AbstractMesh[]): {
  21390. min: Vector3;
  21391. max: Vector3;
  21392. };
  21393. /**
  21394. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21395. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21396. * @returns a vector3
  21397. */
  21398. static Center(meshesOrMinMaxVector: {
  21399. min: Vector3;
  21400. max: Vector3;
  21401. } | AbstractMesh[]): Vector3;
  21402. /**
  21403. * Merge the array of meshes into a single mesh for performance reasons.
  21404. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21405. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21406. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21407. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21408. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21409. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21410. * @returns a new mesh
  21411. */
  21412. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21413. /** @hidden */
  21414. addInstance(instance: InstancedMesh): void;
  21415. /** @hidden */
  21416. removeInstance(instance: InstancedMesh): void;
  21417. }
  21418. }
  21419. declare module "babylonjs/Materials/material" {
  21420. import { IAnimatable } from "babylonjs/Misc/tools";
  21421. import { SmartArray } from "babylonjs/Misc/smartArray";
  21422. import { Observable } from "babylonjs/Misc/observable";
  21423. import { Nullable } from "babylonjs/types";
  21424. import { Scene } from "babylonjs/scene";
  21425. import { Matrix } from "babylonjs/Maths/math";
  21426. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21428. import { Mesh } from "babylonjs/Meshes/mesh";
  21429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21430. import { Effect } from "babylonjs/Materials/effect";
  21431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21434. import { Animation } from "babylonjs/Animations/animation";
  21435. /**
  21436. * Base class for the main features of a material in Babylon.js
  21437. */
  21438. export class Material implements IAnimatable {
  21439. /**
  21440. * Returns the triangle fill mode
  21441. */
  21442. static readonly TriangleFillMode: number;
  21443. /**
  21444. * Returns the wireframe mode
  21445. */
  21446. static readonly WireFrameFillMode: number;
  21447. /**
  21448. * Returns the point fill mode
  21449. */
  21450. static readonly PointFillMode: number;
  21451. /**
  21452. * Returns the point list draw mode
  21453. */
  21454. static readonly PointListDrawMode: number;
  21455. /**
  21456. * Returns the line list draw mode
  21457. */
  21458. static readonly LineListDrawMode: number;
  21459. /**
  21460. * Returns the line loop draw mode
  21461. */
  21462. static readonly LineLoopDrawMode: number;
  21463. /**
  21464. * Returns the line strip draw mode
  21465. */
  21466. static readonly LineStripDrawMode: number;
  21467. /**
  21468. * Returns the triangle strip draw mode
  21469. */
  21470. static readonly TriangleStripDrawMode: number;
  21471. /**
  21472. * Returns the triangle fan draw mode
  21473. */
  21474. static readonly TriangleFanDrawMode: number;
  21475. /**
  21476. * Stores the clock-wise side orientation
  21477. */
  21478. static readonly ClockWiseSideOrientation: number;
  21479. /**
  21480. * Stores the counter clock-wise side orientation
  21481. */
  21482. static readonly CounterClockWiseSideOrientation: number;
  21483. /**
  21484. * The dirty texture flag value
  21485. */
  21486. static readonly TextureDirtyFlag: number;
  21487. /**
  21488. * The dirty light flag value
  21489. */
  21490. static readonly LightDirtyFlag: number;
  21491. /**
  21492. * The dirty fresnel flag value
  21493. */
  21494. static readonly FresnelDirtyFlag: number;
  21495. /**
  21496. * The dirty attribute flag value
  21497. */
  21498. static readonly AttributesDirtyFlag: number;
  21499. /**
  21500. * The dirty misc flag value
  21501. */
  21502. static readonly MiscDirtyFlag: number;
  21503. /**
  21504. * The all dirty flag value
  21505. */
  21506. static readonly AllDirtyFlag: number;
  21507. /**
  21508. * The ID of the material
  21509. */
  21510. id: string;
  21511. /**
  21512. * Gets or sets the unique id of the material
  21513. */
  21514. uniqueId: number;
  21515. /**
  21516. * The name of the material
  21517. */
  21518. name: string;
  21519. /**
  21520. * Gets or sets user defined metadata
  21521. */
  21522. metadata: any;
  21523. /**
  21524. * For internal use only. Please do not use.
  21525. */
  21526. reservedDataStore: any;
  21527. /**
  21528. * Specifies if the ready state should be checked on each call
  21529. */
  21530. checkReadyOnEveryCall: boolean;
  21531. /**
  21532. * Specifies if the ready state should be checked once
  21533. */
  21534. checkReadyOnlyOnce: boolean;
  21535. /**
  21536. * The state of the material
  21537. */
  21538. state: string;
  21539. /**
  21540. * The alpha value of the material
  21541. */
  21542. protected _alpha: number;
  21543. /**
  21544. * Sets the alpha value of the material
  21545. */
  21546. /**
  21547. * Gets the alpha value of the material
  21548. */
  21549. alpha: number;
  21550. /**
  21551. * Specifies if back face culling is enabled
  21552. */
  21553. protected _backFaceCulling: boolean;
  21554. /**
  21555. * Sets the back-face culling state
  21556. */
  21557. /**
  21558. * Gets the back-face culling state
  21559. */
  21560. backFaceCulling: boolean;
  21561. /**
  21562. * Stores the value for side orientation
  21563. */
  21564. sideOrientation: number;
  21565. /**
  21566. * Callback triggered when the material is compiled
  21567. */
  21568. onCompiled: (effect: Effect) => void;
  21569. /**
  21570. * Callback triggered when an error occurs
  21571. */
  21572. onError: (effect: Effect, errors: string) => void;
  21573. /**
  21574. * Callback triggered to get the render target textures
  21575. */
  21576. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21577. /**
  21578. * Gets a boolean indicating that current material needs to register RTT
  21579. */
  21580. readonly hasRenderTargetTextures: boolean;
  21581. /**
  21582. * Specifies if the material should be serialized
  21583. */
  21584. doNotSerialize: boolean;
  21585. /**
  21586. * @hidden
  21587. */
  21588. _storeEffectOnSubMeshes: boolean;
  21589. /**
  21590. * Stores the animations for the material
  21591. */
  21592. animations: Array<Animation>;
  21593. /**
  21594. * An event triggered when the material is disposed
  21595. */
  21596. onDisposeObservable: Observable<Material>;
  21597. /**
  21598. * An observer which watches for dispose events
  21599. */
  21600. private _onDisposeObserver;
  21601. private _onUnBindObservable;
  21602. /**
  21603. * Called during a dispose event
  21604. */
  21605. onDispose: () => void;
  21606. private _onBindObservable;
  21607. /**
  21608. * An event triggered when the material is bound
  21609. */
  21610. readonly onBindObservable: Observable<AbstractMesh>;
  21611. /**
  21612. * An observer which watches for bind events
  21613. */
  21614. private _onBindObserver;
  21615. /**
  21616. * Called during a bind event
  21617. */
  21618. onBind: (Mesh: AbstractMesh) => void;
  21619. /**
  21620. * An event triggered when the material is unbound
  21621. */
  21622. readonly onUnBindObservable: Observable<Material>;
  21623. /**
  21624. * Stores the value of the alpha mode
  21625. */
  21626. private _alphaMode;
  21627. /**
  21628. * Sets the value of the alpha mode.
  21629. *
  21630. * | Value | Type | Description |
  21631. * | --- | --- | --- |
  21632. * | 0 | ALPHA_DISABLE | |
  21633. * | 1 | ALPHA_ADD | |
  21634. * | 2 | ALPHA_COMBINE | |
  21635. * | 3 | ALPHA_SUBTRACT | |
  21636. * | 4 | ALPHA_MULTIPLY | |
  21637. * | 5 | ALPHA_MAXIMIZED | |
  21638. * | 6 | ALPHA_ONEONE | |
  21639. * | 7 | ALPHA_PREMULTIPLIED | |
  21640. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21641. * | 9 | ALPHA_INTERPOLATE | |
  21642. * | 10 | ALPHA_SCREENMODE | |
  21643. *
  21644. */
  21645. /**
  21646. * Gets the value of the alpha mode
  21647. */
  21648. alphaMode: number;
  21649. /**
  21650. * Stores the state of the need depth pre-pass value
  21651. */
  21652. private _needDepthPrePass;
  21653. /**
  21654. * Sets the need depth pre-pass value
  21655. */
  21656. /**
  21657. * Gets the depth pre-pass value
  21658. */
  21659. needDepthPrePass: boolean;
  21660. /**
  21661. * Specifies if depth writing should be disabled
  21662. */
  21663. disableDepthWrite: boolean;
  21664. /**
  21665. * Specifies if depth writing should be forced
  21666. */
  21667. forceDepthWrite: boolean;
  21668. /**
  21669. * Specifies if there should be a separate pass for culling
  21670. */
  21671. separateCullingPass: boolean;
  21672. /**
  21673. * Stores the state specifing if fog should be enabled
  21674. */
  21675. private _fogEnabled;
  21676. /**
  21677. * Sets the state for enabling fog
  21678. */
  21679. /**
  21680. * Gets the value of the fog enabled state
  21681. */
  21682. fogEnabled: boolean;
  21683. /**
  21684. * Stores the size of points
  21685. */
  21686. pointSize: number;
  21687. /**
  21688. * Stores the z offset value
  21689. */
  21690. zOffset: number;
  21691. /**
  21692. * Gets a value specifying if wireframe mode is enabled
  21693. */
  21694. /**
  21695. * Sets the state of wireframe mode
  21696. */
  21697. wireframe: boolean;
  21698. /**
  21699. * Gets the value specifying if point clouds are enabled
  21700. */
  21701. /**
  21702. * Sets the state of point cloud mode
  21703. */
  21704. pointsCloud: boolean;
  21705. /**
  21706. * Gets the material fill mode
  21707. */
  21708. /**
  21709. * Sets the material fill mode
  21710. */
  21711. fillMode: number;
  21712. /**
  21713. * @hidden
  21714. * Stores the effects for the material
  21715. */
  21716. _effect: Nullable<Effect>;
  21717. /**
  21718. * @hidden
  21719. * Specifies if the material was previously ready
  21720. */
  21721. _wasPreviouslyReady: boolean;
  21722. /**
  21723. * Specifies if uniform buffers should be used
  21724. */
  21725. private _useUBO;
  21726. /**
  21727. * Stores a reference to the scene
  21728. */
  21729. private _scene;
  21730. /**
  21731. * Stores the fill mode state
  21732. */
  21733. private _fillMode;
  21734. /**
  21735. * Specifies if the depth write state should be cached
  21736. */
  21737. private _cachedDepthWriteState;
  21738. /**
  21739. * Stores the uniform buffer
  21740. */
  21741. protected _uniformBuffer: UniformBuffer;
  21742. /** @hidden */
  21743. _indexInSceneMaterialArray: number;
  21744. /** @hidden */
  21745. meshMap: Nullable<{
  21746. [id: string]: AbstractMesh | undefined;
  21747. }>;
  21748. /**
  21749. * Creates a material instance
  21750. * @param name defines the name of the material
  21751. * @param scene defines the scene to reference
  21752. * @param doNotAdd specifies if the material should be added to the scene
  21753. */
  21754. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21755. /**
  21756. * Returns a string representation of the current material
  21757. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21758. * @returns a string with material information
  21759. */
  21760. toString(fullDetails?: boolean): string;
  21761. /**
  21762. * Gets the class name of the material
  21763. * @returns a string with the class name of the material
  21764. */
  21765. getClassName(): string;
  21766. /**
  21767. * Specifies if updates for the material been locked
  21768. */
  21769. readonly isFrozen: boolean;
  21770. /**
  21771. * Locks updates for the material
  21772. */
  21773. freeze(): void;
  21774. /**
  21775. * Unlocks updates for the material
  21776. */
  21777. unfreeze(): void;
  21778. /**
  21779. * Specifies if the material is ready to be used
  21780. * @param mesh defines the mesh to check
  21781. * @param useInstances specifies if instances should be used
  21782. * @returns a boolean indicating if the material is ready to be used
  21783. */
  21784. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21785. /**
  21786. * Specifies that the submesh is ready to be used
  21787. * @param mesh defines the mesh to check
  21788. * @param subMesh defines which submesh to check
  21789. * @param useInstances specifies that instances should be used
  21790. * @returns a boolean indicating that the submesh is ready or not
  21791. */
  21792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21793. /**
  21794. * Returns the material effect
  21795. * @returns the effect associated with the material
  21796. */
  21797. getEffect(): Nullable<Effect>;
  21798. /**
  21799. * Returns the current scene
  21800. * @returns a Scene
  21801. */
  21802. getScene(): Scene;
  21803. /**
  21804. * Specifies if the material will require alpha blending
  21805. * @returns a boolean specifying if alpha blending is needed
  21806. */
  21807. needAlphaBlending(): boolean;
  21808. /**
  21809. * Specifies if the mesh will require alpha blending
  21810. * @param mesh defines the mesh to check
  21811. * @returns a boolean specifying if alpha blending is needed for the mesh
  21812. */
  21813. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21814. /**
  21815. * Specifies if this material should be rendered in alpha test mode
  21816. * @returns a boolean specifying if an alpha test is needed.
  21817. */
  21818. needAlphaTesting(): boolean;
  21819. /**
  21820. * Gets the texture used for the alpha test
  21821. * @returns the texture to use for alpha testing
  21822. */
  21823. getAlphaTestTexture(): Nullable<BaseTexture>;
  21824. /**
  21825. * Marks the material to indicate that it needs to be re-calculated
  21826. */
  21827. markDirty(): void;
  21828. /** @hidden */
  21829. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21830. /**
  21831. * Binds the material to the mesh
  21832. * @param world defines the world transformation matrix
  21833. * @param mesh defines the mesh to bind the material to
  21834. */
  21835. bind(world: Matrix, mesh?: Mesh): void;
  21836. /**
  21837. * Binds the submesh to the material
  21838. * @param world defines the world transformation matrix
  21839. * @param mesh defines the mesh containing the submesh
  21840. * @param subMesh defines the submesh to bind the material to
  21841. */
  21842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21843. /**
  21844. * Binds the world matrix to the material
  21845. * @param world defines the world transformation matrix
  21846. */
  21847. bindOnlyWorldMatrix(world: Matrix): void;
  21848. /**
  21849. * Binds the scene's uniform buffer to the effect.
  21850. * @param effect defines the effect to bind to the scene uniform buffer
  21851. * @param sceneUbo defines the uniform buffer storing scene data
  21852. */
  21853. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21854. /**
  21855. * Binds the view matrix to the effect
  21856. * @param effect defines the effect to bind the view matrix to
  21857. */
  21858. bindView(effect: Effect): void;
  21859. /**
  21860. * Binds the view projection matrix to the effect
  21861. * @param effect defines the effect to bind the view projection matrix to
  21862. */
  21863. bindViewProjection(effect: Effect): void;
  21864. /**
  21865. * Specifies if material alpha testing should be turned on for the mesh
  21866. * @param mesh defines the mesh to check
  21867. */
  21868. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21869. /**
  21870. * Processes to execute after binding the material to a mesh
  21871. * @param mesh defines the rendered mesh
  21872. */
  21873. protected _afterBind(mesh?: Mesh): void;
  21874. /**
  21875. * Unbinds the material from the mesh
  21876. */
  21877. unbind(): void;
  21878. /**
  21879. * Gets the active textures from the material
  21880. * @returns an array of textures
  21881. */
  21882. getActiveTextures(): BaseTexture[];
  21883. /**
  21884. * Specifies if the material uses a texture
  21885. * @param texture defines the texture to check against the material
  21886. * @returns a boolean specifying if the material uses the texture
  21887. */
  21888. hasTexture(texture: BaseTexture): boolean;
  21889. /**
  21890. * Makes a duplicate of the material, and gives it a new name
  21891. * @param name defines the new name for the duplicated material
  21892. * @returns the cloned material
  21893. */
  21894. clone(name: string): Nullable<Material>;
  21895. /**
  21896. * Gets the meshes bound to the material
  21897. * @returns an array of meshes bound to the material
  21898. */
  21899. getBindedMeshes(): AbstractMesh[];
  21900. /**
  21901. * Force shader compilation
  21902. * @param mesh defines the mesh associated with this material
  21903. * @param onCompiled defines a function to execute once the material is compiled
  21904. * @param options defines the options to configure the compilation
  21905. */
  21906. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21907. clipPlane: boolean;
  21908. }>): void;
  21909. /**
  21910. * Force shader compilation
  21911. * @param mesh defines the mesh that will use this material
  21912. * @param options defines additional options for compiling the shaders
  21913. * @returns a promise that resolves when the compilation completes
  21914. */
  21915. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21916. clipPlane: boolean;
  21917. }>): Promise<void>;
  21918. private static readonly _ImageProcessingDirtyCallBack;
  21919. private static readonly _TextureDirtyCallBack;
  21920. private static readonly _FresnelDirtyCallBack;
  21921. private static readonly _MiscDirtyCallBack;
  21922. private static readonly _LightsDirtyCallBack;
  21923. private static readonly _AttributeDirtyCallBack;
  21924. private static _FresnelAndMiscDirtyCallBack;
  21925. private static _TextureAndMiscDirtyCallBack;
  21926. private static readonly _DirtyCallbackArray;
  21927. private static readonly _RunDirtyCallBacks;
  21928. /**
  21929. * Marks a define in the material to indicate that it needs to be re-computed
  21930. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21931. */
  21932. markAsDirty(flag: number): void;
  21933. /**
  21934. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21935. * @param func defines a function which checks material defines against the submeshes
  21936. */
  21937. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21938. /**
  21939. * Indicates that image processing needs to be re-calculated for all submeshes
  21940. */
  21941. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21942. /**
  21943. * Indicates that textures need to be re-calculated for all submeshes
  21944. */
  21945. protected _markAllSubMeshesAsTexturesDirty(): void;
  21946. /**
  21947. * Indicates that fresnel needs to be re-calculated for all submeshes
  21948. */
  21949. protected _markAllSubMeshesAsFresnelDirty(): void;
  21950. /**
  21951. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21952. */
  21953. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21954. /**
  21955. * Indicates that lights need to be re-calculated for all submeshes
  21956. */
  21957. protected _markAllSubMeshesAsLightsDirty(): void;
  21958. /**
  21959. * Indicates that attributes need to be re-calculated for all submeshes
  21960. */
  21961. protected _markAllSubMeshesAsAttributesDirty(): void;
  21962. /**
  21963. * Indicates that misc needs to be re-calculated for all submeshes
  21964. */
  21965. protected _markAllSubMeshesAsMiscDirty(): void;
  21966. /**
  21967. * Indicates that textures and misc need to be re-calculated for all submeshes
  21968. */
  21969. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21970. /**
  21971. * Disposes the material
  21972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21975. */
  21976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21977. /** @hidden */
  21978. private releaseVertexArrayObject;
  21979. /**
  21980. * Serializes this material
  21981. * @returns the serialized material object
  21982. */
  21983. serialize(): any;
  21984. /**
  21985. * Creates a material from parsed material data
  21986. * @param parsedMaterial defines parsed material data
  21987. * @param scene defines the hosting scene
  21988. * @param rootUrl defines the root URL to use to load textures
  21989. * @returns a new material
  21990. */
  21991. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21992. }
  21993. }
  21994. declare module "babylonjs/Meshes/subMesh" {
  21995. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21996. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21997. import { Engine } from "babylonjs/Engines/engine";
  21998. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21999. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22000. import { Effect } from "babylonjs/Materials/effect";
  22001. import { Collider } from "babylonjs/Collisions/collider";
  22002. import { Material } from "babylonjs/Materials/material";
  22003. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { Mesh } from "babylonjs/Meshes/mesh";
  22006. import { Ray } from "babylonjs/Culling/ray";
  22007. /**
  22008. * Base class for submeshes
  22009. */
  22010. export class BaseSubMesh {
  22011. /** @hidden */
  22012. _materialDefines: Nullable<MaterialDefines>;
  22013. /** @hidden */
  22014. _materialEffect: Nullable<Effect>;
  22015. /**
  22016. * Gets associated effect
  22017. */
  22018. readonly effect: Nullable<Effect>;
  22019. /**
  22020. * Sets associated effect (effect used to render this submesh)
  22021. * @param effect defines the effect to associate with
  22022. * @param defines defines the set of defines used to compile this effect
  22023. */
  22024. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22025. }
  22026. /**
  22027. * Defines a subdivision inside a mesh
  22028. */
  22029. export class SubMesh extends BaseSubMesh implements ICullable {
  22030. /** the material index to use */
  22031. materialIndex: number;
  22032. /** vertex index start */
  22033. verticesStart: number;
  22034. /** vertices count */
  22035. verticesCount: number;
  22036. /** index start */
  22037. indexStart: number;
  22038. /** indices count */
  22039. indexCount: number;
  22040. /** @hidden */
  22041. _linesIndexCount: number;
  22042. private _mesh;
  22043. private _renderingMesh;
  22044. private _boundingInfo;
  22045. private _linesIndexBuffer;
  22046. /** @hidden */
  22047. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22048. /** @hidden */
  22049. _trianglePlanes: Plane[];
  22050. /** @hidden */
  22051. _lastColliderTransformMatrix: Matrix;
  22052. /** @hidden */
  22053. _renderId: number;
  22054. /** @hidden */
  22055. _alphaIndex: number;
  22056. /** @hidden */
  22057. _distanceToCamera: number;
  22058. /** @hidden */
  22059. _id: number;
  22060. private _currentMaterial;
  22061. /**
  22062. * Add a new submesh to a mesh
  22063. * @param materialIndex defines the material index to use
  22064. * @param verticesStart defines vertex index start
  22065. * @param verticesCount defines vertices count
  22066. * @param indexStart defines index start
  22067. * @param indexCount defines indices count
  22068. * @param mesh defines the parent mesh
  22069. * @param renderingMesh defines an optional rendering mesh
  22070. * @param createBoundingBox defines if bounding box should be created for this submesh
  22071. * @returns the new submesh
  22072. */
  22073. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22074. /**
  22075. * Creates a new submesh
  22076. * @param materialIndex defines the material index to use
  22077. * @param verticesStart defines vertex index start
  22078. * @param verticesCount defines vertices count
  22079. * @param indexStart defines index start
  22080. * @param indexCount defines indices count
  22081. * @param mesh defines the parent mesh
  22082. * @param renderingMesh defines an optional rendering mesh
  22083. * @param createBoundingBox defines if bounding box should be created for this submesh
  22084. */
  22085. constructor(
  22086. /** the material index to use */
  22087. materialIndex: number,
  22088. /** vertex index start */
  22089. verticesStart: number,
  22090. /** vertices count */
  22091. verticesCount: number,
  22092. /** index start */
  22093. indexStart: number,
  22094. /** indices count */
  22095. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22096. /**
  22097. * Returns true if this submesh covers the entire parent mesh
  22098. * @ignorenaming
  22099. */
  22100. readonly IsGlobal: boolean;
  22101. /**
  22102. * Returns the submesh BoudingInfo object
  22103. * @returns current bounding info (or mesh's one if the submesh is global)
  22104. */
  22105. getBoundingInfo(): BoundingInfo;
  22106. /**
  22107. * Sets the submesh BoundingInfo
  22108. * @param boundingInfo defines the new bounding info to use
  22109. * @returns the SubMesh
  22110. */
  22111. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22112. /**
  22113. * Returns the mesh of the current submesh
  22114. * @return the parent mesh
  22115. */
  22116. getMesh(): AbstractMesh;
  22117. /**
  22118. * Returns the rendering mesh of the submesh
  22119. * @returns the rendering mesh (could be different from parent mesh)
  22120. */
  22121. getRenderingMesh(): Mesh;
  22122. /**
  22123. * Returns the submesh material
  22124. * @returns null or the current material
  22125. */
  22126. getMaterial(): Nullable<Material>;
  22127. /**
  22128. * Sets a new updated BoundingInfo object to the submesh
  22129. * @returns the SubMesh
  22130. */
  22131. refreshBoundingInfo(): SubMesh;
  22132. /** @hidden */
  22133. _checkCollision(collider: Collider): boolean;
  22134. /**
  22135. * Updates the submesh BoundingInfo
  22136. * @param world defines the world matrix to use to update the bounding info
  22137. * @returns the submesh
  22138. */
  22139. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22140. /**
  22141. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22142. * @param frustumPlanes defines the frustum planes
  22143. * @returns true if the submesh is intersecting with the frustum
  22144. */
  22145. isInFrustum(frustumPlanes: Plane[]): boolean;
  22146. /**
  22147. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22148. * @param frustumPlanes defines the frustum planes
  22149. * @returns true if the submesh is inside the frustum
  22150. */
  22151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22152. /**
  22153. * Renders the submesh
  22154. * @param enableAlphaMode defines if alpha needs to be used
  22155. * @returns the submesh
  22156. */
  22157. render(enableAlphaMode: boolean): SubMesh;
  22158. /**
  22159. * @hidden
  22160. */
  22161. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22162. /**
  22163. * Checks if the submesh intersects with a ray
  22164. * @param ray defines the ray to test
  22165. * @returns true is the passed ray intersects the submesh bounding box
  22166. */
  22167. canIntersects(ray: Ray): boolean;
  22168. /**
  22169. * Intersects current submesh with a ray
  22170. * @param ray defines the ray to test
  22171. * @param positions defines mesh's positions array
  22172. * @param indices defines mesh's indices array
  22173. * @param fastCheck defines if only bounding info should be used
  22174. * @returns intersection info or null if no intersection
  22175. */
  22176. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22177. /** @hidden */
  22178. private _intersectLines;
  22179. /** @hidden */
  22180. private _intersectTriangles;
  22181. /** @hidden */
  22182. _rebuild(): void;
  22183. /**
  22184. * Creates a new submesh from the passed mesh
  22185. * @param newMesh defines the new hosting mesh
  22186. * @param newRenderingMesh defines an optional rendering mesh
  22187. * @returns the new submesh
  22188. */
  22189. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22190. /**
  22191. * Release associated resources
  22192. */
  22193. dispose(): void;
  22194. /**
  22195. * Gets the class name
  22196. * @returns the string "SubMesh".
  22197. */
  22198. getClassName(): string;
  22199. /**
  22200. * Creates a new submesh from indices data
  22201. * @param materialIndex the index of the main mesh material
  22202. * @param startIndex the index where to start the copy in the mesh indices array
  22203. * @param indexCount the number of indices to copy then from the startIndex
  22204. * @param mesh the main mesh to create the submesh from
  22205. * @param renderingMesh the optional rendering mesh
  22206. * @returns a new submesh
  22207. */
  22208. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22209. }
  22210. }
  22211. declare module "babylonjs/Meshes/geometry" {
  22212. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22213. import { Scene } from "babylonjs/scene";
  22214. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22215. import { Engine } from "babylonjs/Engines/engine";
  22216. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22217. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22218. import { Effect } from "babylonjs/Materials/effect";
  22219. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22220. import { Mesh } from "babylonjs/Meshes/mesh";
  22221. /**
  22222. * Class used to store geometry data (vertex buffers + index buffer)
  22223. */
  22224. export class Geometry implements IGetSetVerticesData {
  22225. /**
  22226. * Gets or sets the ID of the geometry
  22227. */
  22228. id: string;
  22229. /**
  22230. * Gets or sets the unique ID of the geometry
  22231. */
  22232. uniqueId: number;
  22233. /**
  22234. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22235. */
  22236. delayLoadState: number;
  22237. /**
  22238. * Gets the file containing the data to load when running in delay load state
  22239. */
  22240. delayLoadingFile: Nullable<string>;
  22241. /**
  22242. * Callback called when the geometry is updated
  22243. */
  22244. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22245. private _scene;
  22246. private _engine;
  22247. private _meshes;
  22248. private _totalVertices;
  22249. /** @hidden */
  22250. _indices: IndicesArray;
  22251. /** @hidden */
  22252. _vertexBuffers: {
  22253. [key: string]: VertexBuffer;
  22254. };
  22255. private _isDisposed;
  22256. private _extend;
  22257. private _boundingBias;
  22258. /** @hidden */
  22259. _delayInfo: Array<string>;
  22260. private _indexBuffer;
  22261. private _indexBufferIsUpdatable;
  22262. /** @hidden */
  22263. _boundingInfo: Nullable<BoundingInfo>;
  22264. /** @hidden */
  22265. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22266. /** @hidden */
  22267. _softwareSkinningFrameId: number;
  22268. private _vertexArrayObjects;
  22269. private _updatable;
  22270. /** @hidden */
  22271. _positions: Nullable<Vector3[]>;
  22272. /**
  22273. * 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
  22274. */
  22275. /**
  22276. * 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
  22277. */
  22278. boundingBias: Vector2;
  22279. /**
  22280. * Static function used to attach a new empty geometry to a mesh
  22281. * @param mesh defines the mesh to attach the geometry to
  22282. * @returns the new Geometry
  22283. */
  22284. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22285. /**
  22286. * Creates a new geometry
  22287. * @param id defines the unique ID
  22288. * @param scene defines the hosting scene
  22289. * @param vertexData defines the VertexData used to get geometry data
  22290. * @param updatable defines if geometry must be updatable (false by default)
  22291. * @param mesh defines the mesh that will be associated with the geometry
  22292. */
  22293. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22294. /**
  22295. * Gets the current extend of the geometry
  22296. */
  22297. readonly extend: {
  22298. minimum: Vector3;
  22299. maximum: Vector3;
  22300. };
  22301. /**
  22302. * Gets the hosting scene
  22303. * @returns the hosting Scene
  22304. */
  22305. getScene(): Scene;
  22306. /**
  22307. * Gets the hosting engine
  22308. * @returns the hosting Engine
  22309. */
  22310. getEngine(): Engine;
  22311. /**
  22312. * Defines if the geometry is ready to use
  22313. * @returns true if the geometry is ready to be used
  22314. */
  22315. isReady(): boolean;
  22316. /**
  22317. * Gets a value indicating that the geometry should not be serialized
  22318. */
  22319. readonly doNotSerialize: boolean;
  22320. /** @hidden */
  22321. _rebuild(): void;
  22322. /**
  22323. * Affects all geometry data in one call
  22324. * @param vertexData defines the geometry data
  22325. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22326. */
  22327. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22328. /**
  22329. * Set specific vertex data
  22330. * @param kind defines the data kind (Position, normal, etc...)
  22331. * @param data defines the vertex data to use
  22332. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22333. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22334. */
  22335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22336. /**
  22337. * Removes a specific vertex data
  22338. * @param kind defines the data kind (Position, normal, etc...)
  22339. */
  22340. removeVerticesData(kind: string): void;
  22341. /**
  22342. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22343. * @param buffer defines the vertex buffer to use
  22344. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22345. */
  22346. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22347. /**
  22348. * Update a specific vertex buffer
  22349. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22350. * It will do nothing if the buffer is not updatable
  22351. * @param kind defines the data kind (Position, normal, etc...)
  22352. * @param data defines the data to use
  22353. * @param offset defines the offset in the target buffer where to store the data
  22354. * @param useBytes set to true if the offset is in bytes
  22355. */
  22356. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22357. /**
  22358. * Update a specific vertex buffer
  22359. * This function will create a new buffer if the current one is not updatable
  22360. * @param kind defines the data kind (Position, normal, etc...)
  22361. * @param data defines the data to use
  22362. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22363. */
  22364. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22365. private _updateBoundingInfo;
  22366. /** @hidden */
  22367. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22368. /**
  22369. * Gets total number of vertices
  22370. * @returns the total number of vertices
  22371. */
  22372. getTotalVertices(): number;
  22373. /**
  22374. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22375. * @param kind defines the data kind (Position, normal, etc...)
  22376. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22377. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22378. * @returns a float array containing vertex data
  22379. */
  22380. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22381. /**
  22382. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22383. * @param kind defines the data kind (Position, normal, etc...)
  22384. * @returns true if the vertex buffer with the specified kind is updatable
  22385. */
  22386. isVertexBufferUpdatable(kind: string): boolean;
  22387. /**
  22388. * Gets a specific vertex buffer
  22389. * @param kind defines the data kind (Position, normal, etc...)
  22390. * @returns a VertexBuffer
  22391. */
  22392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22393. /**
  22394. * Returns all vertex buffers
  22395. * @return an object holding all vertex buffers indexed by kind
  22396. */
  22397. getVertexBuffers(): Nullable<{
  22398. [key: string]: VertexBuffer;
  22399. }>;
  22400. /**
  22401. * Gets a boolean indicating if specific vertex buffer is present
  22402. * @param kind defines the data kind (Position, normal, etc...)
  22403. * @returns true if data is present
  22404. */
  22405. isVerticesDataPresent(kind: string): boolean;
  22406. /**
  22407. * Gets a list of all attached data kinds (Position, normal, etc...)
  22408. * @returns a list of string containing all kinds
  22409. */
  22410. getVerticesDataKinds(): string[];
  22411. /**
  22412. * Update index buffer
  22413. * @param indices defines the indices to store in the index buffer
  22414. * @param offset defines the offset in the target buffer where to store the data
  22415. */
  22416. updateIndices(indices: IndicesArray, offset?: number): void;
  22417. /**
  22418. * Creates a new index buffer
  22419. * @param indices defines the indices to store in the index buffer
  22420. * @param totalVertices defines the total number of vertices (could be null)
  22421. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22422. */
  22423. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22424. /**
  22425. * Return the total number of indices
  22426. * @returns the total number of indices
  22427. */
  22428. getTotalIndices(): number;
  22429. /**
  22430. * Gets the index buffer array
  22431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22433. * @returns the index buffer array
  22434. */
  22435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22436. /**
  22437. * Gets the index buffer
  22438. * @return the index buffer
  22439. */
  22440. getIndexBuffer(): Nullable<WebGLBuffer>;
  22441. /** @hidden */
  22442. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22443. /**
  22444. * Release the associated resources for a specific mesh
  22445. * @param mesh defines the source mesh
  22446. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22447. */
  22448. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22449. /**
  22450. * Apply current geometry to a given mesh
  22451. * @param mesh defines the mesh to apply geometry to
  22452. */
  22453. applyToMesh(mesh: Mesh): void;
  22454. private _updateExtend;
  22455. private _applyToMesh;
  22456. private notifyUpdate;
  22457. /**
  22458. * Load the geometry if it was flagged as delay loaded
  22459. * @param scene defines the hosting scene
  22460. * @param onLoaded defines a callback called when the geometry is loaded
  22461. */
  22462. load(scene: Scene, onLoaded?: () => void): void;
  22463. private _queueLoad;
  22464. /**
  22465. * Invert the geometry to move from a right handed system to a left handed one.
  22466. */
  22467. toLeftHanded(): void;
  22468. /** @hidden */
  22469. _resetPointsArrayCache(): void;
  22470. /** @hidden */
  22471. _generatePointsArray(): boolean;
  22472. /**
  22473. * Gets a value indicating if the geometry is disposed
  22474. * @returns true if the geometry was disposed
  22475. */
  22476. isDisposed(): boolean;
  22477. private _disposeVertexArrayObjects;
  22478. /**
  22479. * Free all associated resources
  22480. */
  22481. dispose(): void;
  22482. /**
  22483. * Clone the current geometry into a new geometry
  22484. * @param id defines the unique ID of the new geometry
  22485. * @returns a new geometry object
  22486. */
  22487. copy(id: string): Geometry;
  22488. /**
  22489. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22490. * @return a JSON representation of the current geometry data (without the vertices data)
  22491. */
  22492. serialize(): any;
  22493. private toNumberArray;
  22494. /**
  22495. * Serialize all vertices data into a JSON oject
  22496. * @returns a JSON representation of the current geometry data
  22497. */
  22498. serializeVerticeData(): any;
  22499. /**
  22500. * Extracts a clone of a mesh geometry
  22501. * @param mesh defines the source mesh
  22502. * @param id defines the unique ID of the new geometry object
  22503. * @returns the new geometry object
  22504. */
  22505. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22506. /**
  22507. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22509. * Be aware Math.random() could cause collisions, but:
  22510. * "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"
  22511. * @returns a string containing a new GUID
  22512. */
  22513. static RandomId(): string;
  22514. /** @hidden */
  22515. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22516. private static _CleanMatricesWeights;
  22517. /**
  22518. * Create a new geometry from persisted data (Using .babylon file format)
  22519. * @param parsedVertexData defines the persisted data
  22520. * @param scene defines the hosting scene
  22521. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22522. * @returns the new geometry object
  22523. */
  22524. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22525. }
  22526. }
  22527. declare module "babylonjs/Meshes/mesh.vertexData" {
  22528. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22529. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22530. import { Geometry } from "babylonjs/Meshes/geometry";
  22531. import { Mesh } from "babylonjs/Meshes/mesh";
  22532. /**
  22533. * Define an interface for all classes that will get and set the data on vertices
  22534. */
  22535. export interface IGetSetVerticesData {
  22536. /**
  22537. * Gets a boolean indicating if specific vertex data is present
  22538. * @param kind defines the vertex data kind to use
  22539. * @returns true is data kind is present
  22540. */
  22541. isVerticesDataPresent(kind: string): boolean;
  22542. /**
  22543. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22544. * @param kind defines the data kind (Position, normal, etc...)
  22545. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22546. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22547. * @returns a float array containing vertex data
  22548. */
  22549. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22550. /**
  22551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22552. * @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.
  22553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22554. * @returns the indices array or an empty array if the mesh has no geometry
  22555. */
  22556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22557. /**
  22558. * Set specific vertex data
  22559. * @param kind defines the data kind (Position, normal, etc...)
  22560. * @param data defines the vertex data to use
  22561. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22562. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22563. */
  22564. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22565. /**
  22566. * Update a specific associated vertex buffer
  22567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22568. * - VertexBuffer.PositionKind
  22569. * - VertexBuffer.UVKind
  22570. * - VertexBuffer.UV2Kind
  22571. * - VertexBuffer.UV3Kind
  22572. * - VertexBuffer.UV4Kind
  22573. * - VertexBuffer.UV5Kind
  22574. * - VertexBuffer.UV6Kind
  22575. * - VertexBuffer.ColorKind
  22576. * - VertexBuffer.MatricesIndicesKind
  22577. * - VertexBuffer.MatricesIndicesExtraKind
  22578. * - VertexBuffer.MatricesWeightsKind
  22579. * - VertexBuffer.MatricesWeightsExtraKind
  22580. * @param data defines the data source
  22581. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22582. * @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)
  22583. */
  22584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22585. /**
  22586. * Creates a new index buffer
  22587. * @param indices defines the indices to store in the index buffer
  22588. * @param totalVertices defines the total number of vertices (could be null)
  22589. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22590. */
  22591. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22592. }
  22593. /**
  22594. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22595. */
  22596. export class VertexData {
  22597. /**
  22598. * Mesh side orientation : usually the external or front surface
  22599. */
  22600. static readonly FRONTSIDE: number;
  22601. /**
  22602. * Mesh side orientation : usually the internal or back surface
  22603. */
  22604. static readonly BACKSIDE: number;
  22605. /**
  22606. * Mesh side orientation : both internal and external or front and back surfaces
  22607. */
  22608. static readonly DOUBLESIDE: number;
  22609. /**
  22610. * Mesh side orientation : by default, `FRONTSIDE`
  22611. */
  22612. static readonly DEFAULTSIDE: number;
  22613. /**
  22614. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22615. */
  22616. positions: Nullable<FloatArray>;
  22617. /**
  22618. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22619. */
  22620. normals: Nullable<FloatArray>;
  22621. /**
  22622. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22623. */
  22624. tangents: Nullable<FloatArray>;
  22625. /**
  22626. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22627. */
  22628. uvs: Nullable<FloatArray>;
  22629. /**
  22630. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22631. */
  22632. uvs2: Nullable<FloatArray>;
  22633. /**
  22634. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22635. */
  22636. uvs3: Nullable<FloatArray>;
  22637. /**
  22638. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22639. */
  22640. uvs4: Nullable<FloatArray>;
  22641. /**
  22642. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22643. */
  22644. uvs5: Nullable<FloatArray>;
  22645. /**
  22646. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22647. */
  22648. uvs6: Nullable<FloatArray>;
  22649. /**
  22650. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22651. */
  22652. colors: Nullable<FloatArray>;
  22653. /**
  22654. * 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).
  22655. */
  22656. matricesIndices: Nullable<FloatArray>;
  22657. /**
  22658. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22659. */
  22660. matricesWeights: Nullable<FloatArray>;
  22661. /**
  22662. * An array extending the number of possible indices
  22663. */
  22664. matricesIndicesExtra: Nullable<FloatArray>;
  22665. /**
  22666. * An array extending the number of possible weights when the number of indices is extended
  22667. */
  22668. matricesWeightsExtra: Nullable<FloatArray>;
  22669. /**
  22670. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22671. */
  22672. indices: Nullable<IndicesArray>;
  22673. /**
  22674. * Uses the passed data array to set the set the values for the specified kind of data
  22675. * @param data a linear array of floating numbers
  22676. * @param kind the type of data that is being set, eg positions, colors etc
  22677. */
  22678. set(data: FloatArray, kind: string): void;
  22679. /**
  22680. * Associates the vertexData to the passed Mesh.
  22681. * Sets it as updatable or not (default `false`)
  22682. * @param mesh the mesh the vertexData is applied to
  22683. * @param updatable when used and having the value true allows new data to update the vertexData
  22684. * @returns the VertexData
  22685. */
  22686. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22687. /**
  22688. * Associates the vertexData to the passed Geometry.
  22689. * Sets it as updatable or not (default `false`)
  22690. * @param geometry the geometry the vertexData is applied to
  22691. * @param updatable when used and having the value true allows new data to update the vertexData
  22692. * @returns VertexData
  22693. */
  22694. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22695. /**
  22696. * Updates the associated mesh
  22697. * @param mesh the mesh to be updated
  22698. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22699. * @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
  22700. * @returns VertexData
  22701. */
  22702. updateMesh(mesh: Mesh): VertexData;
  22703. /**
  22704. * Updates the associated geometry
  22705. * @param geometry the geometry to be updated
  22706. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22707. * @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
  22708. * @returns VertexData.
  22709. */
  22710. updateGeometry(geometry: Geometry): VertexData;
  22711. private _applyTo;
  22712. private _update;
  22713. /**
  22714. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22715. * @param matrix the transforming matrix
  22716. * @returns the VertexData
  22717. */
  22718. transform(matrix: Matrix): VertexData;
  22719. /**
  22720. * Merges the passed VertexData into the current one
  22721. * @param other the VertexData to be merged into the current one
  22722. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22723. * @returns the modified VertexData
  22724. */
  22725. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22726. private _mergeElement;
  22727. private _validate;
  22728. /**
  22729. * Serializes the VertexData
  22730. * @returns a serialized object
  22731. */
  22732. serialize(): any;
  22733. /**
  22734. * Extracts the vertexData from a mesh
  22735. * @param mesh the mesh from which to extract the VertexData
  22736. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22737. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22738. * @returns the object VertexData associated to the passed mesh
  22739. */
  22740. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22741. /**
  22742. * Extracts the vertexData from the geometry
  22743. * @param geometry the geometry from which to extract the VertexData
  22744. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22745. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22746. * @returns the object VertexData associated to the passed mesh
  22747. */
  22748. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22749. private static _ExtractFrom;
  22750. /**
  22751. * Creates the VertexData for a Ribbon
  22752. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22753. * * pathArray array of paths, each of which an array of successive Vector3
  22754. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22755. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22756. * * 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
  22757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22758. * * 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)
  22759. * * 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)
  22760. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22761. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22762. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22763. * @returns the VertexData of the ribbon
  22764. */
  22765. static CreateRibbon(options: {
  22766. pathArray: Vector3[][];
  22767. closeArray?: boolean;
  22768. closePath?: boolean;
  22769. offset?: number;
  22770. sideOrientation?: number;
  22771. frontUVs?: Vector4;
  22772. backUVs?: Vector4;
  22773. invertUV?: boolean;
  22774. uvs?: Vector2[];
  22775. colors?: Color4[];
  22776. }): VertexData;
  22777. /**
  22778. * Creates the VertexData for a box
  22779. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22780. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22781. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22782. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22783. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22784. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22785. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22787. * * 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)
  22788. * * 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)
  22789. * @returns the VertexData of the box
  22790. */
  22791. static CreateBox(options: {
  22792. size?: number;
  22793. width?: number;
  22794. height?: number;
  22795. depth?: number;
  22796. faceUV?: Vector4[];
  22797. faceColors?: Color4[];
  22798. sideOrientation?: number;
  22799. frontUVs?: Vector4;
  22800. backUVs?: Vector4;
  22801. }): VertexData;
  22802. /**
  22803. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22805. * * segments sets the number of horizontal strips optional, default 32
  22806. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22807. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22808. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22809. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22810. * * 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
  22811. * * 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
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * @returns the VertexData of the ellipsoid
  22816. */
  22817. static CreateSphere(options: {
  22818. segments?: number;
  22819. diameter?: number;
  22820. diameterX?: number;
  22821. diameterY?: number;
  22822. diameterZ?: number;
  22823. arc?: number;
  22824. slice?: number;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. }): VertexData;
  22829. /**
  22830. * Creates the VertexData for a cylinder, cone or prism
  22831. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22832. * * height sets the height (y direction) of the cylinder, optional, default 2
  22833. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22834. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22835. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22836. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22837. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22838. * * 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
  22839. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22841. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22842. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22844. * * 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)
  22845. * * 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)
  22846. * @returns the VertexData of the cylinder, cone or prism
  22847. */
  22848. static CreateCylinder(options: {
  22849. height?: number;
  22850. diameterTop?: number;
  22851. diameterBottom?: number;
  22852. diameter?: number;
  22853. tessellation?: number;
  22854. subdivisions?: number;
  22855. arc?: number;
  22856. faceColors?: Color4[];
  22857. faceUV?: Vector4[];
  22858. hasRings?: boolean;
  22859. enclose?: boolean;
  22860. sideOrientation?: number;
  22861. frontUVs?: Vector4;
  22862. backUVs?: Vector4;
  22863. }): VertexData;
  22864. /**
  22865. * Creates the VertexData for a torus
  22866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22867. * * diameter the diameter of the torus, optional default 1
  22868. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22869. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22871. * * 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)
  22872. * * 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)
  22873. * @returns the VertexData of the torus
  22874. */
  22875. static CreateTorus(options: {
  22876. diameter?: number;
  22877. thickness?: number;
  22878. tessellation?: number;
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData of the LineSystem
  22885. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22886. * - lines an array of lines, each line being an array of successive Vector3
  22887. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22888. * @returns the VertexData of the LineSystem
  22889. */
  22890. static CreateLineSystem(options: {
  22891. lines: Vector3[][];
  22892. colors?: Nullable<Color4[][]>;
  22893. }): VertexData;
  22894. /**
  22895. * Create the VertexData for a DashedLines
  22896. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22897. * - points an array successive Vector3
  22898. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22899. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22900. * - dashNb the intended total number of dashes, optional, default 200
  22901. * @returns the VertexData for the DashedLines
  22902. */
  22903. static CreateDashedLines(options: {
  22904. points: Vector3[];
  22905. dashSize?: number;
  22906. gapSize?: number;
  22907. dashNb?: number;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a Ground
  22911. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22912. * - width the width (x direction) of the ground, optional, default 1
  22913. * - height the height (z direction) of the ground, optional, default 1
  22914. * - subdivisions the number of subdivisions per side, optional, default 1
  22915. * @returns the VertexData of the Ground
  22916. */
  22917. static CreateGround(options: {
  22918. width?: number;
  22919. height?: number;
  22920. subdivisions?: number;
  22921. subdivisionsX?: number;
  22922. subdivisionsY?: number;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22927. * * xmin the ground minimum X coordinate, optional, default -1
  22928. * * zmin the ground minimum Z coordinate, optional, default -1
  22929. * * xmax the ground maximum X coordinate, optional, default 1
  22930. * * zmax the ground maximum Z coordinate, optional, default 1
  22931. * * 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}
  22932. * * 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}
  22933. * @returns the VertexData of the TiledGround
  22934. */
  22935. static CreateTiledGround(options: {
  22936. xmin: number;
  22937. zmin: number;
  22938. xmax: number;
  22939. zmax: number;
  22940. subdivisions?: {
  22941. w: number;
  22942. h: number;
  22943. };
  22944. precision?: {
  22945. w: number;
  22946. h: number;
  22947. };
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData of the Ground designed from a heightmap
  22951. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22952. * * width the width (x direction) of the ground
  22953. * * height the height (z direction) of the ground
  22954. * * subdivisions the number of subdivisions per side
  22955. * * minHeight the minimum altitude on the ground, optional, default 0
  22956. * * maxHeight the maximum altitude on the ground, optional default 1
  22957. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22958. * * buffer the array holding the image color data
  22959. * * bufferWidth the width of image
  22960. * * bufferHeight the height of image
  22961. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22962. * @returns the VertexData of the Ground designed from a heightmap
  22963. */
  22964. static CreateGroundFromHeightMap(options: {
  22965. width: number;
  22966. height: number;
  22967. subdivisions: number;
  22968. minHeight: number;
  22969. maxHeight: number;
  22970. colorFilter: Color3;
  22971. buffer: Uint8Array;
  22972. bufferWidth: number;
  22973. bufferHeight: number;
  22974. alphaFilter: number;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData for a Plane
  22978. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22979. * * size sets the width and height of the plane to the value of size, optional default 1
  22980. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22981. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22983. * * 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)
  22984. * * 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)
  22985. * @returns the VertexData of the box
  22986. */
  22987. static CreatePlane(options: {
  22988. size?: number;
  22989. width?: number;
  22990. height?: number;
  22991. sideOrientation?: number;
  22992. frontUVs?: Vector4;
  22993. backUVs?: Vector4;
  22994. }): VertexData;
  22995. /**
  22996. * Creates the VertexData of the Disc or regular Polygon
  22997. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22998. * * radius the radius of the disc, optional default 0.5
  22999. * * tessellation the number of polygon sides, optional, default 64
  23000. * * 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
  23001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23002. * * 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)
  23003. * * 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)
  23004. * @returns the VertexData of the box
  23005. */
  23006. static CreateDisc(options: {
  23007. radius?: number;
  23008. tessellation?: number;
  23009. arc?: number;
  23010. sideOrientation?: number;
  23011. frontUVs?: Vector4;
  23012. backUVs?: Vector4;
  23013. }): VertexData;
  23014. /**
  23015. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23016. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23017. * @param polygon a mesh built from polygonTriangulation.build()
  23018. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23019. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23020. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23021. * @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)
  23022. * @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)
  23023. * @returns the VertexData of the Polygon
  23024. */
  23025. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23026. /**
  23027. * Creates the VertexData of the IcoSphere
  23028. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23029. * * radius the radius of the IcoSphere, optional default 1
  23030. * * radiusX allows stretching in the x direction, optional, default radius
  23031. * * radiusY allows stretching in the y direction, optional, default radius
  23032. * * radiusZ allows stretching in the z direction, optional, default radius
  23033. * * flat when true creates a flat shaded mesh, optional, default true
  23034. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23036. * * 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)
  23037. * * 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)
  23038. * @returns the VertexData of the IcoSphere
  23039. */
  23040. static CreateIcoSphere(options: {
  23041. radius?: number;
  23042. radiusX?: number;
  23043. radiusY?: number;
  23044. radiusZ?: number;
  23045. flat?: boolean;
  23046. subdivisions?: number;
  23047. sideOrientation?: number;
  23048. frontUVs?: Vector4;
  23049. backUVs?: Vector4;
  23050. }): VertexData;
  23051. /**
  23052. * Creates the VertexData for a Polyhedron
  23053. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23054. * * type provided types are:
  23055. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23056. * * 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)
  23057. * * size the size of the IcoSphere, optional default 1
  23058. * * sizeX allows stretching in the x direction, optional, default size
  23059. * * sizeY allows stretching in the y direction, optional, default size
  23060. * * sizeZ allows stretching in the z direction, optional, default size
  23061. * * 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
  23062. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23063. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23064. * * flat when true creates a flat shaded mesh, optional, default true
  23065. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23067. * * 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)
  23068. * * 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)
  23069. * @returns the VertexData of the Polyhedron
  23070. */
  23071. static CreatePolyhedron(options: {
  23072. type?: number;
  23073. size?: number;
  23074. sizeX?: number;
  23075. sizeY?: number;
  23076. sizeZ?: number;
  23077. custom?: any;
  23078. faceUV?: Vector4[];
  23079. faceColors?: Color4[];
  23080. flat?: boolean;
  23081. sideOrientation?: number;
  23082. frontUVs?: Vector4;
  23083. backUVs?: Vector4;
  23084. }): VertexData;
  23085. /**
  23086. * Creates the VertexData for a TorusKnot
  23087. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23088. * * radius the radius of the torus knot, optional, default 2
  23089. * * tube the thickness of the tube, optional, default 0.5
  23090. * * radialSegments the number of sides on each tube segments, optional, default 32
  23091. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23092. * * p the number of windings around the z axis, optional, default 2
  23093. * * q the number of windings around the x axis, optional, default 3
  23094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23095. * * 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)
  23096. * * 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)
  23097. * @returns the VertexData of the Torus Knot
  23098. */
  23099. static CreateTorusKnot(options: {
  23100. radius?: number;
  23101. tube?: number;
  23102. radialSegments?: number;
  23103. tubularSegments?: number;
  23104. p?: number;
  23105. q?: number;
  23106. sideOrientation?: number;
  23107. frontUVs?: Vector4;
  23108. backUVs?: Vector4;
  23109. }): VertexData;
  23110. /**
  23111. * Compute normals for given positions and indices
  23112. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23113. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23114. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23115. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23116. * * facetNormals : optional array of facet normals (vector3)
  23117. * * facetPositions : optional array of facet positions (vector3)
  23118. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23119. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23120. * * bInfo : optional bounding info, required for facetPartitioning computation
  23121. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23122. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23123. * * useRightHandedSystem: optional boolean to for right handed system computation
  23124. * * depthSort : optional boolean to enable the facet depth sort computation
  23125. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23126. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23127. */
  23128. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23129. facetNormals?: any;
  23130. facetPositions?: any;
  23131. facetPartitioning?: any;
  23132. ratio?: number;
  23133. bInfo?: any;
  23134. bbSize?: Vector3;
  23135. subDiv?: any;
  23136. useRightHandedSystem?: boolean;
  23137. depthSort?: boolean;
  23138. distanceTo?: Vector3;
  23139. depthSortedFacets?: any;
  23140. }): void;
  23141. /** @hidden */
  23142. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23143. /**
  23144. * Applies VertexData created from the imported parameters to the geometry
  23145. * @param parsedVertexData the parsed data from an imported file
  23146. * @param geometry the geometry to apply the VertexData to
  23147. */
  23148. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23149. }
  23150. }
  23151. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { Scene } from "babylonjs/scene";
  23154. import { Vector4 } from "babylonjs/Maths/math";
  23155. import { Mesh } from "babylonjs/Meshes/mesh";
  23156. /**
  23157. * Class containing static functions to help procedurally build meshes
  23158. */
  23159. export class DiscBuilder {
  23160. /**
  23161. * Creates a plane polygonal mesh. By default, this is a disc
  23162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23163. * * 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
  23164. * * 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
  23165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23168. * @param name defines the name of the mesh
  23169. * @param options defines the options used to create the mesh
  23170. * @param scene defines the hosting scene
  23171. * @returns the plane polygonal mesh
  23172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23173. */
  23174. static CreateDisc(name: string, options: {
  23175. radius?: number;
  23176. tessellation?: number;
  23177. arc?: number;
  23178. updatable?: boolean;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }, scene?: Nullable<Scene>): Mesh;
  23183. }
  23184. }
  23185. declare module "babylonjs/Particles/solidParticleSystem" {
  23186. import { Vector3 } from "babylonjs/Maths/math";
  23187. import { Mesh } from "babylonjs/Meshes/mesh";
  23188. import { Scene, IDisposable } from "babylonjs/scene";
  23189. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23190. /**
  23191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23192. *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.
  23193. * The SPS is also a particle system. It provides some methods to manage the particles.
  23194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23195. *
  23196. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23197. */
  23198. export class SolidParticleSystem implements IDisposable {
  23199. /**
  23200. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23201. * Example : var p = SPS.particles[i];
  23202. */
  23203. particles: SolidParticle[];
  23204. /**
  23205. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23206. */
  23207. nbParticles: number;
  23208. /**
  23209. * If the particles must ever face the camera (default false). Useful for planar particles.
  23210. */
  23211. billboard: boolean;
  23212. /**
  23213. * Recompute normals when adding a shape
  23214. */
  23215. recomputeNormals: boolean;
  23216. /**
  23217. * This a counter ofr your own usage. It's not set by any SPS functions.
  23218. */
  23219. counter: number;
  23220. /**
  23221. * The SPS name. This name is also given to the underlying mesh.
  23222. */
  23223. name: string;
  23224. /**
  23225. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23226. */
  23227. mesh: Mesh;
  23228. /**
  23229. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23230. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23231. */
  23232. vars: any;
  23233. /**
  23234. * This array is populated when the SPS is set as 'pickable'.
  23235. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23236. * Each element of this array is an object `{idx: int, faceId: int}`.
  23237. * `idx` is the picked particle index in the `SPS.particles` array
  23238. * `faceId` is the picked face index counted within this particle.
  23239. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23240. */
  23241. pickedParticles: {
  23242. idx: number;
  23243. faceId: number;
  23244. }[];
  23245. /**
  23246. * This array is populated when `enableDepthSort` is set to true.
  23247. * Each element of this array is an instance of the class DepthSortedParticle.
  23248. */
  23249. depthSortedParticles: DepthSortedParticle[];
  23250. /**
  23251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23252. * @hidden
  23253. */
  23254. _bSphereOnly: boolean;
  23255. /**
  23256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23257. * @hidden
  23258. */
  23259. _bSphereRadiusFactor: number;
  23260. private _scene;
  23261. private _positions;
  23262. private _indices;
  23263. private _normals;
  23264. private _colors;
  23265. private _uvs;
  23266. private _indices32;
  23267. private _positions32;
  23268. private _normals32;
  23269. private _fixedNormal32;
  23270. private _colors32;
  23271. private _uvs32;
  23272. private _index;
  23273. private _updatable;
  23274. private _pickable;
  23275. private _isVisibilityBoxLocked;
  23276. private _alwaysVisible;
  23277. private _depthSort;
  23278. private _shapeCounter;
  23279. private _copy;
  23280. private _color;
  23281. private _computeParticleColor;
  23282. private _computeParticleTexture;
  23283. private _computeParticleRotation;
  23284. private _computeParticleVertex;
  23285. private _computeBoundingBox;
  23286. private _depthSortParticles;
  23287. private _camera;
  23288. private _mustUnrotateFixedNormals;
  23289. private _particlesIntersect;
  23290. private _needs32Bits;
  23291. /**
  23292. * Creates a SPS (Solid Particle System) object.
  23293. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23294. * @param scene (Scene) is the scene in which the SPS is added.
  23295. * @param options defines the options of the sps e.g.
  23296. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23297. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23298. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23299. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23300. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23301. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23302. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23303. */
  23304. constructor(name: string, scene: Scene, options?: {
  23305. updatable?: boolean;
  23306. isPickable?: boolean;
  23307. enableDepthSort?: boolean;
  23308. particleIntersection?: boolean;
  23309. boundingSphereOnly?: boolean;
  23310. bSphereRadiusFactor?: number;
  23311. });
  23312. /**
  23313. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23314. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23315. * @returns the created mesh
  23316. */
  23317. buildMesh(): Mesh;
  23318. /**
  23319. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23320. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23321. * Thus the particles generated from `digest()` have their property `position` set yet.
  23322. * @param mesh ( Mesh ) is the mesh to be digested
  23323. * @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
  23324. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23325. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23326. * @returns the current SPS
  23327. */
  23328. digest(mesh: Mesh, options?: {
  23329. facetNb?: number;
  23330. number?: number;
  23331. delta?: number;
  23332. }): SolidParticleSystem;
  23333. private _unrotateFixedNormals;
  23334. private _resetCopy;
  23335. private _meshBuilder;
  23336. private _posToShape;
  23337. private _uvsToShapeUV;
  23338. private _addParticle;
  23339. /**
  23340. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23341. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23342. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23343. * @param nb (positive integer) the number of particles to be created from this model
  23344. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23345. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23346. * @returns the number of shapes in the system
  23347. */
  23348. addShape(mesh: Mesh, nb: number, options?: {
  23349. positionFunction?: any;
  23350. vertexFunction?: any;
  23351. }): number;
  23352. private _rebuildParticle;
  23353. /**
  23354. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23355. * @returns the SPS.
  23356. */
  23357. rebuildMesh(): SolidParticleSystem;
  23358. /**
  23359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23360. * This method calls `updateParticle()` for each particle of the SPS.
  23361. * For an animated SPS, it is usually called within the render loop.
  23362. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23363. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23364. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23365. * @returns the SPS.
  23366. */
  23367. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23368. /**
  23369. * Disposes the SPS.
  23370. */
  23371. dispose(): void;
  23372. /**
  23373. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23374. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23375. * @returns the SPS.
  23376. */
  23377. refreshVisibleSize(): SolidParticleSystem;
  23378. /**
  23379. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23380. * @param size the size (float) of the visibility box
  23381. * note : this doesn't lock the SPS mesh bounding box.
  23382. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23383. */
  23384. setVisibilityBox(size: number): void;
  23385. /**
  23386. * Gets whether the SPS as always visible or not
  23387. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23388. */
  23389. /**
  23390. * Sets the SPS as always visible or not
  23391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23392. */
  23393. isAlwaysVisible: boolean;
  23394. /**
  23395. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23397. */
  23398. /**
  23399. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23400. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23401. */
  23402. isVisibilityBoxLocked: boolean;
  23403. /**
  23404. * Tells to `setParticles()` to compute the particle rotations or not.
  23405. * Default value : true. The SPS is faster when it's set to false.
  23406. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23407. */
  23408. /**
  23409. * Gets if `setParticles()` computes the particle rotations or not.
  23410. * Default value : true. The SPS is faster when it's set to false.
  23411. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23412. */
  23413. computeParticleRotation: boolean;
  23414. /**
  23415. * Tells to `setParticles()` to compute the particle colors or not.
  23416. * Default value : true. The SPS is faster when it's set to false.
  23417. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23418. */
  23419. /**
  23420. * Gets if `setParticles()` computes the particle colors or not.
  23421. * Default value : true. The SPS is faster when it's set to false.
  23422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23423. */
  23424. computeParticleColor: boolean;
  23425. /**
  23426. * Gets if `setParticles()` computes the particle textures or not.
  23427. * Default value : true. The SPS is faster when it's set to false.
  23428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23429. */
  23430. computeParticleTexture: boolean;
  23431. /**
  23432. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23433. * Default value : false. The SPS is faster when it's set to false.
  23434. * Note : the particle custom vertex positions aren't stored values.
  23435. */
  23436. /**
  23437. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23438. * Default value : false. The SPS is faster when it's set to false.
  23439. * Note : the particle custom vertex positions aren't stored values.
  23440. */
  23441. computeParticleVertex: boolean;
  23442. /**
  23443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23444. */
  23445. /**
  23446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23447. */
  23448. computeBoundingBox: boolean;
  23449. /**
  23450. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23451. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23452. * Default : `true`
  23453. */
  23454. /**
  23455. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23456. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23457. * Default : `true`
  23458. */
  23459. depthSortParticles: boolean;
  23460. /**
  23461. * This function does nothing. It may be overwritten to set all the particle first values.
  23462. * The SPS doesn't call this function, you may have to call it by your own.
  23463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23464. */
  23465. initParticles(): void;
  23466. /**
  23467. * This function does nothing. It may be overwritten to recycle a particle.
  23468. * The SPS doesn't call this function, you may have to call it by your own.
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23470. * @param particle The particle to recycle
  23471. * @returns the recycled particle
  23472. */
  23473. recycleParticle(particle: SolidParticle): SolidParticle;
  23474. /**
  23475. * Updates a particle : this function should be overwritten by the user.
  23476. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23478. * @example : just set a particle position or velocity and recycle conditions
  23479. * @param particle The particle to update
  23480. * @returns the updated particle
  23481. */
  23482. updateParticle(particle: SolidParticle): SolidParticle;
  23483. /**
  23484. * Updates a vertex of a particle : it can be overwritten by the user.
  23485. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23486. * @param particle the current particle
  23487. * @param vertex the current index of the current particle
  23488. * @param pt the index of the current vertex in the particle shape
  23489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23490. * @example : just set a vertex particle position
  23491. * @returns the updated vertex
  23492. */
  23493. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23494. /**
  23495. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23496. * This does nothing and may be overwritten by the user.
  23497. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23498. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23499. * @param update the boolean update value actually passed to setParticles()
  23500. */
  23501. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23502. /**
  23503. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23504. * This will be passed three parameters.
  23505. * This does nothing and may be overwritten by the user.
  23506. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23507. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23508. * @param update the boolean update value actually passed to setParticles()
  23509. */
  23510. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23511. }
  23512. }
  23513. declare module "babylonjs/Particles/solidParticle" {
  23514. import { Nullable } from "babylonjs/types";
  23515. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23516. import { Mesh } from "babylonjs/Meshes/mesh";
  23517. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23518. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23519. /**
  23520. * Represents one particle of a solid particle system.
  23521. */
  23522. export class SolidParticle {
  23523. /**
  23524. * particle global index
  23525. */
  23526. idx: number;
  23527. /**
  23528. * The color of the particle
  23529. */
  23530. color: Nullable<Color4>;
  23531. /**
  23532. * The world space position of the particle.
  23533. */
  23534. position: Vector3;
  23535. /**
  23536. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23537. */
  23538. rotation: Vector3;
  23539. /**
  23540. * The world space rotation quaternion of the particle.
  23541. */
  23542. rotationQuaternion: Nullable<Quaternion>;
  23543. /**
  23544. * The scaling of the particle.
  23545. */
  23546. scaling: Vector3;
  23547. /**
  23548. * The uvs of the particle.
  23549. */
  23550. uvs: Vector4;
  23551. /**
  23552. * The current speed of the particle.
  23553. */
  23554. velocity: Vector3;
  23555. /**
  23556. * The pivot point in the particle local space.
  23557. */
  23558. pivot: Vector3;
  23559. /**
  23560. * Must the particle be translated from its pivot point in its local space ?
  23561. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23562. * Default : false
  23563. */
  23564. translateFromPivot: boolean;
  23565. /**
  23566. * Is the particle active or not ?
  23567. */
  23568. alive: boolean;
  23569. /**
  23570. * Is the particle visible or not ?
  23571. */
  23572. isVisible: boolean;
  23573. /**
  23574. * Index of this particle in the global "positions" array (Internal use)
  23575. * @hidden
  23576. */
  23577. _pos: number;
  23578. /**
  23579. * @hidden Index of this particle in the global "indices" array (Internal use)
  23580. */
  23581. _ind: number;
  23582. /**
  23583. * @hidden ModelShape of this particle (Internal use)
  23584. */
  23585. _model: ModelShape;
  23586. /**
  23587. * ModelShape id of this particle
  23588. */
  23589. shapeId: number;
  23590. /**
  23591. * Index of the particle in its shape id (Internal use)
  23592. */
  23593. idxInShape: number;
  23594. /**
  23595. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23596. */
  23597. _modelBoundingInfo: BoundingInfo;
  23598. /**
  23599. * @hidden Particle BoundingInfo object (Internal use)
  23600. */
  23601. _boundingInfo: BoundingInfo;
  23602. /**
  23603. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23604. */
  23605. _sps: SolidParticleSystem;
  23606. /**
  23607. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23608. */
  23609. _stillInvisible: boolean;
  23610. /**
  23611. * @hidden Last computed particle rotation matrix
  23612. */
  23613. _rotationMatrix: number[];
  23614. /**
  23615. * Parent particle Id, if any.
  23616. * Default null.
  23617. */
  23618. parentId: Nullable<number>;
  23619. /**
  23620. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23621. * The possible values are :
  23622. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23623. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23624. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23625. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23626. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23627. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23628. * */
  23629. cullingStrategy: number;
  23630. /**
  23631. * @hidden Internal global position in the SPS.
  23632. */
  23633. _globalPosition: Vector3;
  23634. /**
  23635. * Creates a Solid Particle object.
  23636. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23637. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23638. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23639. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23640. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23641. * @param shapeId (integer) is the model shape identifier in the SPS.
  23642. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23643. * @param sps defines the sps it is associated to
  23644. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23645. */
  23646. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23647. /**
  23648. * Legacy support, changed scale to scaling
  23649. */
  23650. /**
  23651. * Legacy support, changed scale to scaling
  23652. */
  23653. scale: Vector3;
  23654. /**
  23655. * Legacy support, changed quaternion to rotationQuaternion
  23656. */
  23657. /**
  23658. * Legacy support, changed quaternion to rotationQuaternion
  23659. */
  23660. quaternion: Nullable<Quaternion>;
  23661. /**
  23662. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23663. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23664. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23665. * @returns true if it intersects
  23666. */
  23667. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23668. /**
  23669. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23670. * A particle is in the frustum if its bounding box intersects the frustum
  23671. * @param frustumPlanes defines the frustum to test
  23672. * @returns true if the particle is in the frustum planes
  23673. */
  23674. isInFrustum(frustumPlanes: Plane[]): boolean;
  23675. /**
  23676. * get the rotation matrix of the particle
  23677. * @hidden
  23678. */
  23679. getRotationMatrix(m: Matrix): void;
  23680. }
  23681. /**
  23682. * Represents the shape of the model used by one particle of a solid particle system.
  23683. * SPS internal tool, don't use it manually.
  23684. */
  23685. export class ModelShape {
  23686. /**
  23687. * The shape id
  23688. * @hidden
  23689. */
  23690. shapeID: number;
  23691. /**
  23692. * flat array of model positions (internal use)
  23693. * @hidden
  23694. */
  23695. _shape: Vector3[];
  23696. /**
  23697. * flat array of model UVs (internal use)
  23698. * @hidden
  23699. */
  23700. _shapeUV: number[];
  23701. /**
  23702. * length of the shape in the model indices array (internal use)
  23703. * @hidden
  23704. */
  23705. _indicesLength: number;
  23706. /**
  23707. * Custom position function (internal use)
  23708. * @hidden
  23709. */
  23710. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23711. /**
  23712. * Custom vertex function (internal use)
  23713. * @hidden
  23714. */
  23715. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23716. /**
  23717. * 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.
  23718. * SPS internal tool, don't use it manually.
  23719. * @hidden
  23720. */
  23721. 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>);
  23722. }
  23723. /**
  23724. * Represents a Depth Sorted Particle in the solid particle system.
  23725. */
  23726. export class DepthSortedParticle {
  23727. /**
  23728. * Index of the particle in the "indices" array
  23729. */
  23730. ind: number;
  23731. /**
  23732. * Length of the particle shape in the "indices" array
  23733. */
  23734. indicesLength: number;
  23735. /**
  23736. * Squared distance from the particle to the camera
  23737. */
  23738. sqDistance: number;
  23739. }
  23740. }
  23741. declare module "babylonjs/Meshes/abstractMesh" {
  23742. import { Observable } from "babylonjs/Misc/observable";
  23743. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23744. import { Camera } from "babylonjs/Cameras/camera";
  23745. import { Scene, IDisposable } from "babylonjs/scene";
  23746. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23747. import { Node } from "babylonjs/node";
  23748. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23749. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23752. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23753. import { Material } from "babylonjs/Materials/material";
  23754. import { Light } from "babylonjs/Lights/light";
  23755. import { Skeleton } from "babylonjs/Bones/skeleton";
  23756. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23757. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23759. import { Ray } from "babylonjs/Culling/ray";
  23760. import { Collider } from "babylonjs/Collisions/collider";
  23761. /**
  23762. * Class used to store all common mesh properties
  23763. */
  23764. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23765. /** No occlusion */
  23766. static OCCLUSION_TYPE_NONE: number;
  23767. /** Occlusion set to optimisitic */
  23768. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23769. /** Occlusion set to strict */
  23770. static OCCLUSION_TYPE_STRICT: number;
  23771. /** Use an accurante occlusion algorithm */
  23772. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23773. /** Use a conservative occlusion algorithm */
  23774. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23775. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23776. * Test order :
  23777. * Is the bounding sphere outside the frustum ?
  23778. * If not, are the bounding box vertices outside the frustum ?
  23779. * It not, then the cullable object is in the frustum.
  23780. */
  23781. static readonly CULLINGSTRATEGY_STANDARD: number;
  23782. /** Culling strategy : Bounding Sphere Only.
  23783. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23784. * It's also less accurate than the standard because some not visible objects can still be selected.
  23785. * Test : is the bounding sphere outside the frustum ?
  23786. * If not, then the cullable object is in the frustum.
  23787. */
  23788. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23789. /** Culling strategy : Optimistic Inclusion.
  23790. * This in an inclusion test first, then the standard exclusion test.
  23791. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23792. * 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.
  23793. * Anyway, it's as accurate as the standard strategy.
  23794. * Test :
  23795. * Is the cullable object bounding sphere center in the frustum ?
  23796. * If not, apply the default culling strategy.
  23797. */
  23798. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23799. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23800. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23801. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23802. * 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.
  23803. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23804. * Test :
  23805. * Is the cullable object bounding sphere center in the frustum ?
  23806. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23807. */
  23808. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23809. /**
  23810. * No billboard
  23811. */
  23812. static readonly BILLBOARDMODE_NONE: number;
  23813. /** Billboard on X axis */
  23814. static readonly BILLBOARDMODE_X: number;
  23815. /** Billboard on Y axis */
  23816. static readonly BILLBOARDMODE_Y: number;
  23817. /** Billboard on Z axis */
  23818. static readonly BILLBOARDMODE_Z: number;
  23819. /** Billboard on all axes */
  23820. static readonly BILLBOARDMODE_ALL: number;
  23821. private _facetData;
  23822. /**
  23823. * The culling strategy to use to check whether the mesh must be rendered or not.
  23824. * This value can be changed at any time and will be used on the next render mesh selection.
  23825. * The possible values are :
  23826. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23827. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23828. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23829. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23830. * Please read each static variable documentation to get details about the culling process.
  23831. * */
  23832. cullingStrategy: number;
  23833. /**
  23834. * Gets the number of facets in the mesh
  23835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23836. */
  23837. readonly facetNb: number;
  23838. /**
  23839. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23841. */
  23842. partitioningSubdivisions: number;
  23843. /**
  23844. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23845. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23847. */
  23848. partitioningBBoxRatio: number;
  23849. /**
  23850. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23851. * Works only for updatable meshes.
  23852. * Doesn't work with multi-materials
  23853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23854. */
  23855. mustDepthSortFacets: boolean;
  23856. /**
  23857. * The location (Vector3) where the facet depth sort must be computed from.
  23858. * By default, the active camera position.
  23859. * Used only when facet depth sort is enabled
  23860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23861. */
  23862. facetDepthSortFrom: Vector3;
  23863. /**
  23864. * gets a boolean indicating if facetData is enabled
  23865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23866. */
  23867. readonly isFacetDataEnabled: boolean;
  23868. /** @hidden */
  23869. _updateNonUniformScalingState(value: boolean): boolean;
  23870. /**
  23871. * An event triggered when this mesh collides with another one
  23872. */
  23873. onCollideObservable: Observable<AbstractMesh>;
  23874. private _onCollideObserver;
  23875. /** Set a function to call when this mesh collides with another one */
  23876. onCollide: () => void;
  23877. /**
  23878. * An event triggered when the collision's position changes
  23879. */
  23880. onCollisionPositionChangeObservable: Observable<Vector3>;
  23881. private _onCollisionPositionChangeObserver;
  23882. /** Set a function to call when the collision's position changes */
  23883. onCollisionPositionChange: () => void;
  23884. /**
  23885. * An event triggered when material is changed
  23886. */
  23887. onMaterialChangedObservable: Observable<AbstractMesh>;
  23888. /**
  23889. * Gets or sets the orientation for POV movement & rotation
  23890. */
  23891. definedFacingForward: boolean;
  23892. /** @hidden */
  23893. _occlusionQuery: Nullable<WebGLQuery>;
  23894. private _visibility;
  23895. /**
  23896. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23897. */
  23898. /**
  23899. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23900. */
  23901. visibility: number;
  23902. /** Gets or sets the alpha index used to sort transparent meshes
  23903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23904. */
  23905. alphaIndex: number;
  23906. /**
  23907. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23908. */
  23909. isVisible: boolean;
  23910. /**
  23911. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23912. */
  23913. isPickable: boolean;
  23914. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23915. showSubMeshesBoundingBox: boolean;
  23916. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23918. */
  23919. isBlocker: boolean;
  23920. /**
  23921. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23922. */
  23923. enablePointerMoveEvents: boolean;
  23924. /**
  23925. * Specifies the rendering group id for this mesh (0 by default)
  23926. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23927. */
  23928. renderingGroupId: number;
  23929. private _material;
  23930. /** Gets or sets current material */
  23931. material: Nullable<Material>;
  23932. private _receiveShadows;
  23933. /**
  23934. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23935. * @see http://doc.babylonjs.com/babylon101/shadows
  23936. */
  23937. receiveShadows: boolean;
  23938. /** Defines color to use when rendering outline */
  23939. outlineColor: Color3;
  23940. /** Define width to use when rendering outline */
  23941. outlineWidth: number;
  23942. /** Defines color to use when rendering overlay */
  23943. overlayColor: Color3;
  23944. /** Defines alpha to use when rendering overlay */
  23945. overlayAlpha: number;
  23946. private _hasVertexAlpha;
  23947. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23948. hasVertexAlpha: boolean;
  23949. private _useVertexColors;
  23950. /** 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) */
  23951. useVertexColors: boolean;
  23952. private _computeBonesUsingShaders;
  23953. /**
  23954. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23955. */
  23956. computeBonesUsingShaders: boolean;
  23957. private _numBoneInfluencers;
  23958. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23959. numBoneInfluencers: number;
  23960. private _applyFog;
  23961. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23962. applyFog: boolean;
  23963. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23964. useOctreeForRenderingSelection: boolean;
  23965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23966. useOctreeForPicking: boolean;
  23967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23968. useOctreeForCollisions: boolean;
  23969. private _layerMask;
  23970. /**
  23971. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23972. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23973. */
  23974. layerMask: number;
  23975. /**
  23976. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23977. */
  23978. alwaysSelectAsActiveMesh: boolean;
  23979. /**
  23980. * Gets or sets the current action manager
  23981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23982. */
  23983. actionManager: Nullable<AbstractActionManager>;
  23984. private _checkCollisions;
  23985. private _collisionMask;
  23986. private _collisionGroup;
  23987. /**
  23988. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23990. */
  23991. ellipsoid: Vector3;
  23992. /**
  23993. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23995. */
  23996. ellipsoidOffset: Vector3;
  23997. private _collider;
  23998. private _oldPositionForCollisions;
  23999. private _diffPositionForCollisions;
  24000. /**
  24001. * Gets or sets a collision mask used to mask collisions (default is -1).
  24002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24003. */
  24004. collisionMask: number;
  24005. /**
  24006. * Gets or sets the current collision group mask (-1 by default).
  24007. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24008. */
  24009. collisionGroup: number;
  24010. /**
  24011. * Defines edge width used when edgesRenderer is enabled
  24012. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24013. */
  24014. edgesWidth: number;
  24015. /**
  24016. * Defines edge color used when edgesRenderer is enabled
  24017. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24018. */
  24019. edgesColor: Color4;
  24020. /** @hidden */
  24021. _edgesRenderer: Nullable<IEdgesRenderer>;
  24022. /** @hidden */
  24023. _masterMesh: Nullable<AbstractMesh>;
  24024. /** @hidden */
  24025. _boundingInfo: Nullable<BoundingInfo>;
  24026. /** @hidden */
  24027. _renderId: number;
  24028. /**
  24029. * Gets or sets the list of subMeshes
  24030. * @see http://doc.babylonjs.com/how_to/multi_materials
  24031. */
  24032. subMeshes: SubMesh[];
  24033. /** @hidden */
  24034. _intersectionsInProgress: AbstractMesh[];
  24035. /** @hidden */
  24036. _unIndexed: boolean;
  24037. /** @hidden */
  24038. _lightSources: Light[];
  24039. /** @hidden */
  24040. readonly _positions: Nullable<Vector3[]>;
  24041. /** @hidden */
  24042. _waitingActions: any;
  24043. /** @hidden */
  24044. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24045. private _skeleton;
  24046. /** @hidden */
  24047. _bonesTransformMatrices: Nullable<Float32Array>;
  24048. /**
  24049. * Gets or sets a skeleton to apply skining transformations
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24051. */
  24052. skeleton: Nullable<Skeleton>;
  24053. /**
  24054. * An event triggered when the mesh is rebuilt.
  24055. */
  24056. onRebuildObservable: Observable<AbstractMesh>;
  24057. /**
  24058. * Creates a new AbstractMesh
  24059. * @param name defines the name of the mesh
  24060. * @param scene defines the hosting scene
  24061. */
  24062. constructor(name: string, scene?: Nullable<Scene>);
  24063. /**
  24064. * Returns the string "AbstractMesh"
  24065. * @returns "AbstractMesh"
  24066. */
  24067. getClassName(): string;
  24068. /**
  24069. * Gets a string representation of the current mesh
  24070. * @param fullDetails defines a boolean indicating if full details must be included
  24071. * @returns a string representation of the current mesh
  24072. */
  24073. toString(fullDetails?: boolean): string;
  24074. /** @hidden */
  24075. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24076. /** @hidden */
  24077. _rebuild(): void;
  24078. /** @hidden */
  24079. _resyncLightSources(): void;
  24080. /** @hidden */
  24081. _resyncLighSource(light: Light): void;
  24082. /** @hidden */
  24083. _unBindEffect(): void;
  24084. /** @hidden */
  24085. _removeLightSource(light: Light): void;
  24086. private _markSubMeshesAsDirty;
  24087. /** @hidden */
  24088. _markSubMeshesAsLightDirty(): void;
  24089. /** @hidden */
  24090. _markSubMeshesAsAttributesDirty(): void;
  24091. /** @hidden */
  24092. _markSubMeshesAsMiscDirty(): void;
  24093. /**
  24094. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24095. */
  24096. scaling: Vector3;
  24097. /**
  24098. * Returns true if the mesh is blocked. Implemented by child classes
  24099. */
  24100. readonly isBlocked: boolean;
  24101. /**
  24102. * Returns the mesh itself by default. Implemented by child classes
  24103. * @param camera defines the camera to use to pick the right LOD level
  24104. * @returns the currentAbstractMesh
  24105. */
  24106. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24107. /**
  24108. * Returns 0 by default. Implemented by child classes
  24109. * @returns an integer
  24110. */
  24111. getTotalVertices(): number;
  24112. /**
  24113. * Returns a positive integer : the total number of indices in this mesh geometry.
  24114. * @returns the numner of indices or zero if the mesh has no geometry.
  24115. */
  24116. getTotalIndices(): number;
  24117. /**
  24118. * Returns null by default. Implemented by child classes
  24119. * @returns null
  24120. */
  24121. getIndices(): Nullable<IndicesArray>;
  24122. /**
  24123. * Returns the array of the requested vertex data kind. Implemented by child classes
  24124. * @param kind defines the vertex data kind to use
  24125. * @returns null
  24126. */
  24127. getVerticesData(kind: string): Nullable<FloatArray>;
  24128. /**
  24129. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24130. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24131. * Note that a new underlying VertexBuffer object is created each call.
  24132. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24133. * @param kind defines vertex data kind:
  24134. * * VertexBuffer.PositionKind
  24135. * * VertexBuffer.UVKind
  24136. * * VertexBuffer.UV2Kind
  24137. * * VertexBuffer.UV3Kind
  24138. * * VertexBuffer.UV4Kind
  24139. * * VertexBuffer.UV5Kind
  24140. * * VertexBuffer.UV6Kind
  24141. * * VertexBuffer.ColorKind
  24142. * * VertexBuffer.MatricesIndicesKind
  24143. * * VertexBuffer.MatricesIndicesExtraKind
  24144. * * VertexBuffer.MatricesWeightsKind
  24145. * * VertexBuffer.MatricesWeightsExtraKind
  24146. * @param data defines the data source
  24147. * @param updatable defines if the data must be flagged as updatable (or static)
  24148. * @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
  24149. * @returns the current mesh
  24150. */
  24151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24152. /**
  24153. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24154. * If the mesh has no geometry, it is simply returned as it is.
  24155. * @param kind defines vertex data kind:
  24156. * * VertexBuffer.PositionKind
  24157. * * VertexBuffer.UVKind
  24158. * * VertexBuffer.UV2Kind
  24159. * * VertexBuffer.UV3Kind
  24160. * * VertexBuffer.UV4Kind
  24161. * * VertexBuffer.UV5Kind
  24162. * * VertexBuffer.UV6Kind
  24163. * * VertexBuffer.ColorKind
  24164. * * VertexBuffer.MatricesIndicesKind
  24165. * * VertexBuffer.MatricesIndicesExtraKind
  24166. * * VertexBuffer.MatricesWeightsKind
  24167. * * VertexBuffer.MatricesWeightsExtraKind
  24168. * @param data defines the data source
  24169. * @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
  24170. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24171. * @returns the current mesh
  24172. */
  24173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24174. /**
  24175. * Sets the mesh indices,
  24176. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24177. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24178. * @param totalVertices Defines the total number of vertices
  24179. * @returns the current mesh
  24180. */
  24181. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24182. /**
  24183. * Gets a boolean indicating if specific vertex data is present
  24184. * @param kind defines the vertex data kind to use
  24185. * @returns true is data kind is present
  24186. */
  24187. isVerticesDataPresent(kind: string): boolean;
  24188. /**
  24189. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24190. * @returns a BoundingInfo
  24191. */
  24192. getBoundingInfo(): BoundingInfo;
  24193. /**
  24194. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24195. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24196. * @returns the current mesh
  24197. */
  24198. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24199. /**
  24200. * Overwrite the current bounding info
  24201. * @param boundingInfo defines the new bounding info
  24202. * @returns the current mesh
  24203. */
  24204. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24205. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24206. readonly useBones: boolean;
  24207. /** @hidden */
  24208. _preActivate(): void;
  24209. /** @hidden */
  24210. _preActivateForIntermediateRendering(renderId: number): void;
  24211. /** @hidden */
  24212. _activate(renderId: number): void;
  24213. /**
  24214. * Gets the current world matrix
  24215. * @returns a Matrix
  24216. */
  24217. getWorldMatrix(): Matrix;
  24218. /** @hidden */
  24219. _getWorldMatrixDeterminant(): number;
  24220. /**
  24221. * Perform relative position change from the point of view of behind the front of the mesh.
  24222. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24223. * Supports definition of mesh facing forward or backward
  24224. * @param amountRight defines the distance on the right axis
  24225. * @param amountUp defines the distance on the up axis
  24226. * @param amountForward defines the distance on the forward axis
  24227. * @returns the current mesh
  24228. */
  24229. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24230. /**
  24231. * Calculate relative position change from the point of view of behind the front of the mesh.
  24232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24233. * Supports definition of mesh facing forward or backward
  24234. * @param amountRight defines the distance on the right axis
  24235. * @param amountUp defines the distance on the up axis
  24236. * @param amountForward defines the distance on the forward axis
  24237. * @returns the new displacement vector
  24238. */
  24239. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24240. /**
  24241. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24242. * Supports definition of mesh facing forward or backward
  24243. * @param flipBack defines the flip
  24244. * @param twirlClockwise defines the twirl
  24245. * @param tiltRight defines the tilt
  24246. * @returns the current mesh
  24247. */
  24248. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24249. /**
  24250. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24251. * Supports definition of mesh facing forward or backward.
  24252. * @param flipBack defines the flip
  24253. * @param twirlClockwise defines the twirl
  24254. * @param tiltRight defines the tilt
  24255. * @returns the new rotation vector
  24256. */
  24257. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24258. /**
  24259. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24260. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24261. * @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
  24262. * @returns the new bounding vectors
  24263. */
  24264. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24265. min: Vector3;
  24266. max: Vector3;
  24267. };
  24268. /**
  24269. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24270. * This means the mesh underlying bounding box and sphere are recomputed.
  24271. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24272. * @returns the current mesh
  24273. */
  24274. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24275. /** @hidden */
  24276. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24277. /** @hidden */
  24278. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24279. /** @hidden */
  24280. _updateBoundingInfo(): AbstractMesh;
  24281. /** @hidden */
  24282. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24283. /** @hidden */
  24284. protected _afterComputeWorldMatrix(): void;
  24285. /**
  24286. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24287. * A mesh is in the frustum if its bounding box intersects the frustum
  24288. * @param frustumPlanes defines the frustum to test
  24289. * @returns true if the mesh is in the frustum planes
  24290. */
  24291. isInFrustum(frustumPlanes: Plane[]): boolean;
  24292. /**
  24293. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24294. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24295. * @param frustumPlanes defines the frustum to test
  24296. * @returns true if the mesh is completely in the frustum planes
  24297. */
  24298. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24299. /**
  24300. * True if the mesh intersects another mesh or a SolidParticle object
  24301. * @param mesh defines a target mesh or SolidParticle to test
  24302. * @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)
  24303. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24304. * @returns true if there is an intersection
  24305. */
  24306. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24307. /**
  24308. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24309. * @param point defines the point to test
  24310. * @returns true if there is an intersection
  24311. */
  24312. intersectsPoint(point: Vector3): boolean;
  24313. /**
  24314. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24316. */
  24317. checkCollisions: boolean;
  24318. /**
  24319. * Gets Collider object used to compute collisions (not physics)
  24320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24321. */
  24322. readonly collider: Collider;
  24323. /**
  24324. * Move the mesh using collision engine
  24325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24326. * @param displacement defines the requested displacement vector
  24327. * @returns the current mesh
  24328. */
  24329. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24330. private _onCollisionPositionChange;
  24331. /** @hidden */
  24332. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24333. /** @hidden */
  24334. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24335. /** @hidden */
  24336. _checkCollision(collider: Collider): AbstractMesh;
  24337. /** @hidden */
  24338. _generatePointsArray(): boolean;
  24339. /**
  24340. * Checks if the passed Ray intersects with the mesh
  24341. * @param ray defines the ray to use
  24342. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24343. * @returns the picking info
  24344. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24345. */
  24346. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24347. /**
  24348. * Clones the current mesh
  24349. * @param name defines the mesh name
  24350. * @param newParent defines the new mesh parent
  24351. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24352. * @returns the new mesh
  24353. */
  24354. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24355. /**
  24356. * Disposes all the submeshes of the current meshnp
  24357. * @returns the current mesh
  24358. */
  24359. releaseSubMeshes(): AbstractMesh;
  24360. /**
  24361. * Releases resources associated with this abstract mesh.
  24362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24364. */
  24365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24366. /**
  24367. * Adds the passed mesh as a child to the current mesh
  24368. * @param mesh defines the child mesh
  24369. * @returns the current mesh
  24370. */
  24371. addChild(mesh: AbstractMesh): AbstractMesh;
  24372. /**
  24373. * Removes the passed mesh from the current mesh children list
  24374. * @param mesh defines the child mesh
  24375. * @returns the current mesh
  24376. */
  24377. removeChild(mesh: AbstractMesh): AbstractMesh;
  24378. /** @hidden */
  24379. private _initFacetData;
  24380. /**
  24381. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24382. * This method can be called within the render loop.
  24383. * 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
  24384. * @returns the current mesh
  24385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24386. */
  24387. updateFacetData(): AbstractMesh;
  24388. /**
  24389. * Returns the facetLocalNormals array.
  24390. * The normals are expressed in the mesh local spac
  24391. * @returns an array of Vector3
  24392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24393. */
  24394. getFacetLocalNormals(): Vector3[];
  24395. /**
  24396. * Returns the facetLocalPositions array.
  24397. * The facet positions are expressed in the mesh local space
  24398. * @returns an array of Vector3
  24399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24400. */
  24401. getFacetLocalPositions(): Vector3[];
  24402. /**
  24403. * Returns the facetLocalPartioning array
  24404. * @returns an array of array of numbers
  24405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24406. */
  24407. getFacetLocalPartitioning(): number[][];
  24408. /**
  24409. * Returns the i-th facet position in the world system.
  24410. * This method allocates a new Vector3 per call
  24411. * @param i defines the facet index
  24412. * @returns a new Vector3
  24413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24414. */
  24415. getFacetPosition(i: number): Vector3;
  24416. /**
  24417. * Sets the reference Vector3 with the i-th facet position in the world system
  24418. * @param i defines the facet index
  24419. * @param ref defines the target vector
  24420. * @returns the current mesh
  24421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24422. */
  24423. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24424. /**
  24425. * Returns the i-th facet normal in the world system.
  24426. * This method allocates a new Vector3 per call
  24427. * @param i defines the facet index
  24428. * @returns a new Vector3
  24429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24430. */
  24431. getFacetNormal(i: number): Vector3;
  24432. /**
  24433. * Sets the reference Vector3 with the i-th facet normal in the world system
  24434. * @param i defines the facet index
  24435. * @param ref defines the target vector
  24436. * @returns the current mesh
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24438. */
  24439. getFacetNormalToRef(i: number, ref: Vector3): this;
  24440. /**
  24441. * 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)
  24442. * @param x defines x coordinate
  24443. * @param y defines y coordinate
  24444. * @param z defines z coordinate
  24445. * @returns the array of facet indexes
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24447. */
  24448. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24449. /**
  24450. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24451. * @param projected sets as the (x,y,z) world projection on the facet
  24452. * @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
  24453. * @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
  24454. * @param x defines x coordinate
  24455. * @param y defines y coordinate
  24456. * @param z defines z coordinate
  24457. * @returns the face index if found (or null instead)
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24461. /**
  24462. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24463. * @param projected sets as the (x,y,z) local projection on the facet
  24464. * @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
  24465. * @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
  24466. * @param x defines x coordinate
  24467. * @param y defines y coordinate
  24468. * @param z defines z coordinate
  24469. * @returns the face index if found (or null instead)
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24473. /**
  24474. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24475. * @returns the parameters
  24476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24477. */
  24478. getFacetDataParameters(): any;
  24479. /**
  24480. * Disables the feature FacetData and frees the related memory
  24481. * @returns the current mesh
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. disableFacetData(): AbstractMesh;
  24485. /**
  24486. * Updates the AbstractMesh indices array
  24487. * @param indices defines the data source
  24488. * @returns the current mesh
  24489. */
  24490. updateIndices(indices: IndicesArray): AbstractMesh;
  24491. /**
  24492. * Creates new normals data for the mesh
  24493. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24494. * @returns the current mesh
  24495. */
  24496. createNormals(updatable: boolean): AbstractMesh;
  24497. /**
  24498. * Align the mesh with a normal
  24499. * @param normal defines the normal to use
  24500. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24501. * @returns the current mesh
  24502. */
  24503. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24504. /** @hidden */
  24505. _checkOcclusionQuery(): boolean;
  24506. }
  24507. }
  24508. declare module "babylonjs/Actions/actionEvent" {
  24509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24510. import { Nullable } from "babylonjs/types";
  24511. import { Sprite } from "babylonjs/Sprites/sprite";
  24512. import { Scene } from "babylonjs/scene";
  24513. import { Vector2 } from "babylonjs/Maths/math";
  24514. /**
  24515. * Interface used to define ActionEvent
  24516. */
  24517. export interface IActionEvent {
  24518. /** The mesh or sprite that triggered the action */
  24519. source: any;
  24520. /** The X mouse cursor position at the time of the event */
  24521. pointerX: number;
  24522. /** The Y mouse cursor position at the time of the event */
  24523. pointerY: number;
  24524. /** The mesh that is currently pointed at (can be null) */
  24525. meshUnderPointer: Nullable<AbstractMesh>;
  24526. /** the original (browser) event that triggered the ActionEvent */
  24527. sourceEvent?: any;
  24528. /** additional data for the event */
  24529. additionalData?: any;
  24530. }
  24531. /**
  24532. * ActionEvent is the event being sent when an action is triggered.
  24533. */
  24534. export class ActionEvent implements IActionEvent {
  24535. /** The mesh or sprite that triggered the action */
  24536. source: any;
  24537. /** The X mouse cursor position at the time of the event */
  24538. pointerX: number;
  24539. /** The Y mouse cursor position at the time of the event */
  24540. pointerY: number;
  24541. /** The mesh that is currently pointed at (can be null) */
  24542. meshUnderPointer: Nullable<AbstractMesh>;
  24543. /** the original (browser) event that triggered the ActionEvent */
  24544. sourceEvent?: any;
  24545. /** additional data for the event */
  24546. additionalData?: any;
  24547. /**
  24548. * Creates a new ActionEvent
  24549. * @param source The mesh or sprite that triggered the action
  24550. * @param pointerX The X mouse cursor position at the time of the event
  24551. * @param pointerY The Y mouse cursor position at the time of the event
  24552. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24553. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24554. * @param additionalData additional data for the event
  24555. */
  24556. constructor(
  24557. /** The mesh or sprite that triggered the action */
  24558. source: any,
  24559. /** The X mouse cursor position at the time of the event */
  24560. pointerX: number,
  24561. /** The Y mouse cursor position at the time of the event */
  24562. pointerY: number,
  24563. /** The mesh that is currently pointed at (can be null) */
  24564. meshUnderPointer: Nullable<AbstractMesh>,
  24565. /** the original (browser) event that triggered the ActionEvent */
  24566. sourceEvent?: any,
  24567. /** additional data for the event */
  24568. additionalData?: any);
  24569. /**
  24570. * Helper function to auto-create an ActionEvent from a source mesh.
  24571. * @param source The source mesh that triggered the event
  24572. * @param evt The original (browser) event
  24573. * @param additionalData additional data for the event
  24574. * @returns the new ActionEvent
  24575. */
  24576. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24577. /**
  24578. * Helper function to auto-create an ActionEvent from a source sprite
  24579. * @param source The source sprite that triggered the event
  24580. * @param scene Scene associated with the sprite
  24581. * @param evt The original (browser) event
  24582. * @param additionalData additional data for the event
  24583. * @returns the new ActionEvent
  24584. */
  24585. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24586. /**
  24587. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24588. * @param scene the scene where the event occurred
  24589. * @param evt The original (browser) event
  24590. * @returns the new ActionEvent
  24591. */
  24592. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24593. /**
  24594. * Helper function to auto-create an ActionEvent from a primitive
  24595. * @param prim defines the target primitive
  24596. * @param pointerPos defines the pointer position
  24597. * @param evt The original (browser) event
  24598. * @param additionalData additional data for the event
  24599. * @returns the new ActionEvent
  24600. */
  24601. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24602. }
  24603. }
  24604. declare module "babylonjs/Actions/abstractActionManager" {
  24605. import { IDisposable } from "babylonjs/scene";
  24606. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24607. import { IAction } from "babylonjs/Actions/action";
  24608. /**
  24609. * Abstract class used to decouple action Manager from scene and meshes.
  24610. * Do not instantiate.
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24612. */
  24613. export abstract class AbstractActionManager implements IDisposable {
  24614. /** Gets the list of active triggers */
  24615. static Triggers: {
  24616. [key: string]: number;
  24617. };
  24618. /** Gets the cursor to use when hovering items */
  24619. hoverCursor: string;
  24620. /** Gets the list of actions */
  24621. actions: IAction[];
  24622. /**
  24623. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24624. */
  24625. isRecursive: boolean;
  24626. /**
  24627. * Releases all associated resources
  24628. */
  24629. abstract dispose(): void;
  24630. /**
  24631. * Does this action manager has pointer triggers
  24632. */
  24633. abstract readonly hasPointerTriggers: boolean;
  24634. /**
  24635. * Does this action manager has pick triggers
  24636. */
  24637. abstract readonly hasPickTriggers: boolean;
  24638. /**
  24639. * Process a specific trigger
  24640. * @param trigger defines the trigger to process
  24641. * @param evt defines the event details to be processed
  24642. */
  24643. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24644. /**
  24645. * Does this action manager handles actions of any of the given triggers
  24646. * @param triggers defines the triggers to be tested
  24647. * @return a boolean indicating whether one (or more) of the triggers is handled
  24648. */
  24649. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24650. /**
  24651. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24652. * speed.
  24653. * @param triggerA defines the trigger to be tested
  24654. * @param triggerB defines the trigger to be tested
  24655. * @return a boolean indicating whether one (or more) of the triggers is handled
  24656. */
  24657. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24658. /**
  24659. * Does this action manager handles actions of a given trigger
  24660. * @param trigger defines the trigger to be tested
  24661. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24662. * @return whether the trigger is handled
  24663. */
  24664. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24665. /**
  24666. * Serialize this manager to a JSON object
  24667. * @param name defines the property name to store this manager
  24668. * @returns a JSON representation of this manager
  24669. */
  24670. abstract serialize(name: string): any;
  24671. /**
  24672. * Does exist one action manager with at least one trigger
  24673. **/
  24674. static readonly HasTriggers: boolean;
  24675. /**
  24676. * Does exist one action manager with at least one pick trigger
  24677. **/
  24678. static readonly HasPickTriggers: boolean;
  24679. /**
  24680. * Does exist one action manager that handles actions of a given trigger
  24681. * @param trigger defines the trigger to be tested
  24682. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24683. **/
  24684. static HasSpecificTrigger(trigger: number): boolean;
  24685. }
  24686. }
  24687. declare module "babylonjs/node" {
  24688. import { Scene } from "babylonjs/scene";
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Matrix } from "babylonjs/Maths/math";
  24691. import { Engine } from "babylonjs/Engines/engine";
  24692. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24693. import { Observable } from "babylonjs/Misc/observable";
  24694. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24695. import { Animatable } from "babylonjs/Animations/animatable";
  24696. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24697. import { Animation } from "babylonjs/Animations/animation";
  24698. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24700. /**
  24701. * Defines how a node can be built from a string name.
  24702. */
  24703. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24704. /**
  24705. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24706. */
  24707. export class Node implements IBehaviorAware<Node> {
  24708. /** @hidden */
  24709. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24710. private static _NodeConstructors;
  24711. /**
  24712. * Add a new node constructor
  24713. * @param type defines the type name of the node to construct
  24714. * @param constructorFunc defines the constructor function
  24715. */
  24716. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24717. /**
  24718. * Returns a node constructor based on type name
  24719. * @param type defines the type name
  24720. * @param name defines the new node name
  24721. * @param scene defines the hosting scene
  24722. * @param options defines optional options to transmit to constructors
  24723. * @returns the new constructor or null
  24724. */
  24725. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24726. /**
  24727. * Gets or sets the name of the node
  24728. */
  24729. name: string;
  24730. /**
  24731. * Gets or sets the id of the node
  24732. */
  24733. id: string;
  24734. /**
  24735. * Gets or sets the unique id of the node
  24736. */
  24737. uniqueId: number;
  24738. /**
  24739. * Gets or sets a string used to store user defined state for the node
  24740. */
  24741. state: string;
  24742. /**
  24743. * Gets or sets an object used to store user defined information for the node
  24744. */
  24745. metadata: any;
  24746. /**
  24747. * For internal use only. Please do not use.
  24748. */
  24749. reservedDataStore: any;
  24750. /**
  24751. * Gets or sets a boolean used to define if the node must be serialized
  24752. */
  24753. doNotSerialize: boolean;
  24754. /** @hidden */
  24755. _isDisposed: boolean;
  24756. /**
  24757. * Gets a list of Animations associated with the node
  24758. */
  24759. animations: import("babylonjs/Animations/animation").Animation[];
  24760. protected _ranges: {
  24761. [name: string]: Nullable<AnimationRange>;
  24762. };
  24763. /**
  24764. * Callback raised when the node is ready to be used
  24765. */
  24766. onReady: (node: Node) => void;
  24767. private _isEnabled;
  24768. private _isParentEnabled;
  24769. private _isReady;
  24770. /** @hidden */
  24771. _currentRenderId: number;
  24772. private _parentRenderId;
  24773. protected _childRenderId: number;
  24774. /** @hidden */
  24775. _waitingParentId: Nullable<string>;
  24776. /** @hidden */
  24777. _scene: Scene;
  24778. /** @hidden */
  24779. _cache: any;
  24780. private _parentNode;
  24781. private _children;
  24782. /** @hidden */
  24783. _worldMatrix: Matrix;
  24784. /** @hidden */
  24785. _worldMatrixDeterminant: number;
  24786. /** @hidden */
  24787. private _sceneRootNodesIndex;
  24788. /**
  24789. * Gets a boolean indicating if the node has been disposed
  24790. * @returns true if the node was disposed
  24791. */
  24792. isDisposed(): boolean;
  24793. /**
  24794. * Gets or sets the parent of the node
  24795. */
  24796. parent: Nullable<Node>;
  24797. private addToSceneRootNodes;
  24798. private removeFromSceneRootNodes;
  24799. private _animationPropertiesOverride;
  24800. /**
  24801. * Gets or sets the animation properties override
  24802. */
  24803. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24804. /**
  24805. * Gets a string idenfifying the name of the class
  24806. * @returns "Node" string
  24807. */
  24808. getClassName(): string;
  24809. /** @hidden */
  24810. readonly _isNode: boolean;
  24811. /**
  24812. * An event triggered when the mesh is disposed
  24813. */
  24814. onDisposeObservable: Observable<Node>;
  24815. private _onDisposeObserver;
  24816. /**
  24817. * Sets a callback that will be raised when the node will be disposed
  24818. */
  24819. onDispose: () => void;
  24820. /**
  24821. * Creates a new Node
  24822. * @param name the name and id to be given to this node
  24823. * @param scene the scene this node will be added to
  24824. * @param addToRootNodes the node will be added to scene.rootNodes
  24825. */
  24826. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24827. /**
  24828. * Gets the scene of the node
  24829. * @returns a scene
  24830. */
  24831. getScene(): Scene;
  24832. /**
  24833. * Gets the engine of the node
  24834. * @returns a Engine
  24835. */
  24836. getEngine(): Engine;
  24837. private _behaviors;
  24838. /**
  24839. * Attach a behavior to the node
  24840. * @see http://doc.babylonjs.com/features/behaviour
  24841. * @param behavior defines the behavior to attach
  24842. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24843. * @returns the current Node
  24844. */
  24845. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24846. /**
  24847. * Remove an attached behavior
  24848. * @see http://doc.babylonjs.com/features/behaviour
  24849. * @param behavior defines the behavior to attach
  24850. * @returns the current Node
  24851. */
  24852. removeBehavior(behavior: Behavior<Node>): Node;
  24853. /**
  24854. * Gets the list of attached behaviors
  24855. * @see http://doc.babylonjs.com/features/behaviour
  24856. */
  24857. readonly behaviors: Behavior<Node>[];
  24858. /**
  24859. * Gets an attached behavior by name
  24860. * @param name defines the name of the behavior to look for
  24861. * @see http://doc.babylonjs.com/features/behaviour
  24862. * @returns null if behavior was not found else the requested behavior
  24863. */
  24864. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24865. /**
  24866. * Returns the latest update of the World matrix
  24867. * @returns a Matrix
  24868. */
  24869. getWorldMatrix(): Matrix;
  24870. /** @hidden */
  24871. _getWorldMatrixDeterminant(): number;
  24872. /**
  24873. * Returns directly the latest state of the mesh World matrix.
  24874. * A Matrix is returned.
  24875. */
  24876. readonly worldMatrixFromCache: Matrix;
  24877. /** @hidden */
  24878. _initCache(): void;
  24879. /** @hidden */
  24880. updateCache(force?: boolean): void;
  24881. /** @hidden */
  24882. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24883. /** @hidden */
  24884. _updateCache(ignoreParentClass?: boolean): void;
  24885. /** @hidden */
  24886. _isSynchronized(): boolean;
  24887. /** @hidden */
  24888. _markSyncedWithParent(): void;
  24889. /** @hidden */
  24890. isSynchronizedWithParent(): boolean;
  24891. /** @hidden */
  24892. isSynchronized(): boolean;
  24893. /**
  24894. * Is this node ready to be used/rendered
  24895. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24896. * @return true if the node is ready
  24897. */
  24898. isReady(completeCheck?: boolean): boolean;
  24899. /**
  24900. * Is this node enabled?
  24901. * 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
  24902. * @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
  24903. * @return whether this node (and its parent) is enabled
  24904. */
  24905. isEnabled(checkAncestors?: boolean): boolean;
  24906. /** @hidden */
  24907. protected _syncParentEnabledState(): void;
  24908. /**
  24909. * Set the enabled state of this node
  24910. * @param value defines the new enabled state
  24911. */
  24912. setEnabled(value: boolean): void;
  24913. /**
  24914. * Is this node a descendant of the given node?
  24915. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24916. * @param ancestor defines the parent node to inspect
  24917. * @returns a boolean indicating if this node is a descendant of the given node
  24918. */
  24919. isDescendantOf(ancestor: Node): boolean;
  24920. /** @hidden */
  24921. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24922. /**
  24923. * Will return all nodes that have this node as ascendant
  24924. * @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
  24925. * @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
  24926. * @return all children nodes of all types
  24927. */
  24928. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24929. /**
  24930. * Get all child-meshes of this node
  24931. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24932. * @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
  24933. * @returns an array of AbstractMesh
  24934. */
  24935. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24936. /**
  24937. * Get all direct children of this node
  24938. * @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
  24939. * @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)
  24940. * @returns an array of Node
  24941. */
  24942. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24943. /** @hidden */
  24944. _setReady(state: boolean): void;
  24945. /**
  24946. * Get an animation by name
  24947. * @param name defines the name of the animation to look for
  24948. * @returns null if not found else the requested animation
  24949. */
  24950. getAnimationByName(name: string): Nullable<Animation>;
  24951. /**
  24952. * Creates an animation range for this node
  24953. * @param name defines the name of the range
  24954. * @param from defines the starting key
  24955. * @param to defines the end key
  24956. */
  24957. createAnimationRange(name: string, from: number, to: number): void;
  24958. /**
  24959. * Delete a specific animation range
  24960. * @param name defines the name of the range to delete
  24961. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24962. */
  24963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24964. /**
  24965. * Get an animation range by name
  24966. * @param name defines the name of the animation range to look for
  24967. * @returns null if not found else the requested animation range
  24968. */
  24969. getAnimationRange(name: string): Nullable<AnimationRange>;
  24970. /**
  24971. * Will start the animation sequence
  24972. * @param name defines the range frames for animation sequence
  24973. * @param loop defines if the animation should loop (false by default)
  24974. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24975. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24976. * @returns the object created for this animation. If range does not exist, it will return null
  24977. */
  24978. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24979. /**
  24980. * Serialize animation ranges into a JSON compatible object
  24981. * @returns serialization object
  24982. */
  24983. serializeAnimationRanges(): any;
  24984. /**
  24985. * Computes the world matrix of the node
  24986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24987. * @returns the world matrix
  24988. */
  24989. computeWorldMatrix(force?: boolean): Matrix;
  24990. /**
  24991. * Releases resources associated with this node.
  24992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24994. */
  24995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24996. /**
  24997. * Parse animation range data from a serialization object and store them into a given node
  24998. * @param node defines where to store the animation ranges
  24999. * @param parsedNode defines the serialization object to read data from
  25000. * @param scene defines the hosting scene
  25001. */
  25002. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25003. }
  25004. }
  25005. declare module "babylonjs/Animations/animation" {
  25006. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25007. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25008. import { Nullable } from "babylonjs/types";
  25009. import { Scene } from "babylonjs/scene";
  25010. import { IAnimatable } from "babylonjs/Misc/tools";
  25011. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25012. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25013. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25014. import { Node } from "babylonjs/node";
  25015. import { Animatable } from "babylonjs/Animations/animatable";
  25016. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25017. /**
  25018. * Class used to store any kind of animation
  25019. */
  25020. export class Animation {
  25021. /**Name of the animation */
  25022. name: string;
  25023. /**Property to animate */
  25024. targetProperty: string;
  25025. /**The frames per second of the animation */
  25026. framePerSecond: number;
  25027. /**The data type of the animation */
  25028. dataType: number;
  25029. /**The loop mode of the animation */
  25030. loopMode?: number | undefined;
  25031. /**Specifies if blending should be enabled */
  25032. enableBlending?: boolean | undefined;
  25033. /**
  25034. * Use matrix interpolation instead of using direct key value when animating matrices
  25035. */
  25036. static AllowMatricesInterpolation: boolean;
  25037. /**
  25038. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25039. */
  25040. static AllowMatrixDecomposeForInterpolation: boolean;
  25041. /**
  25042. * Stores the key frames of the animation
  25043. */
  25044. private _keys;
  25045. /**
  25046. * Stores the easing function of the animation
  25047. */
  25048. private _easingFunction;
  25049. /**
  25050. * @hidden Internal use only
  25051. */
  25052. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25053. /**
  25054. * The set of event that will be linked to this animation
  25055. */
  25056. private _events;
  25057. /**
  25058. * Stores an array of target property paths
  25059. */
  25060. targetPropertyPath: string[];
  25061. /**
  25062. * Stores the blending speed of the animation
  25063. */
  25064. blendingSpeed: number;
  25065. /**
  25066. * Stores the animation ranges for the animation
  25067. */
  25068. private _ranges;
  25069. /**
  25070. * @hidden Internal use
  25071. */
  25072. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25073. /**
  25074. * Sets up an animation
  25075. * @param property The property to animate
  25076. * @param animationType The animation type to apply
  25077. * @param framePerSecond The frames per second of the animation
  25078. * @param easingFunction The easing function used in the animation
  25079. * @returns The created animation
  25080. */
  25081. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25082. /**
  25083. * Create and start an animation on a node
  25084. * @param name defines the name of the global animation that will be run on all nodes
  25085. * @param node defines the root node where the animation will take place
  25086. * @param targetProperty defines property to animate
  25087. * @param framePerSecond defines the number of frame per second yo use
  25088. * @param totalFrame defines the number of frames in total
  25089. * @param from defines the initial value
  25090. * @param to defines the final value
  25091. * @param loopMode defines which loop mode you want to use (off by default)
  25092. * @param easingFunction defines the easing function to use (linear by default)
  25093. * @param onAnimationEnd defines the callback to call when animation end
  25094. * @returns the animatable created for this animation
  25095. */
  25096. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25097. /**
  25098. * Create and start an animation on a node and its descendants
  25099. * @param name defines the name of the global animation that will be run on all nodes
  25100. * @param node defines the root node where the animation will take place
  25101. * @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
  25102. * @param targetProperty defines property to animate
  25103. * @param framePerSecond defines the number of frame per second to use
  25104. * @param totalFrame defines the number of frames in total
  25105. * @param from defines the initial value
  25106. * @param to defines the final value
  25107. * @param loopMode defines which loop mode you want to use (off by default)
  25108. * @param easingFunction defines the easing function to use (linear by default)
  25109. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25110. * @returns the list of animatables created for all nodes
  25111. * @example https://www.babylonjs-playground.com/#MH0VLI
  25112. */
  25113. 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[]>;
  25114. /**
  25115. * Creates a new animation, merges it with the existing animations and starts it
  25116. * @param name Name of the animation
  25117. * @param node Node which contains the scene that begins the animations
  25118. * @param targetProperty Specifies which property to animate
  25119. * @param framePerSecond The frames per second of the animation
  25120. * @param totalFrame The total number of frames
  25121. * @param from The frame at the beginning of the animation
  25122. * @param to The frame at the end of the animation
  25123. * @param loopMode Specifies the loop mode of the animation
  25124. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25125. * @param onAnimationEnd Callback to run once the animation is complete
  25126. * @returns Nullable animation
  25127. */
  25128. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25129. /**
  25130. * Transition property of an host to the target Value
  25131. * @param property The property to transition
  25132. * @param targetValue The target Value of the property
  25133. * @param host The object where the property to animate belongs
  25134. * @param scene Scene used to run the animation
  25135. * @param frameRate Framerate (in frame/s) to use
  25136. * @param transition The transition type we want to use
  25137. * @param duration The duration of the animation, in milliseconds
  25138. * @param onAnimationEnd Callback trigger at the end of the animation
  25139. * @returns Nullable animation
  25140. */
  25141. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25142. /**
  25143. * Return the array of runtime animations currently using this animation
  25144. */
  25145. readonly runtimeAnimations: RuntimeAnimation[];
  25146. /**
  25147. * Specifies if any of the runtime animations are currently running
  25148. */
  25149. readonly hasRunningRuntimeAnimations: boolean;
  25150. /**
  25151. * Initializes the animation
  25152. * @param name Name of the animation
  25153. * @param targetProperty Property to animate
  25154. * @param framePerSecond The frames per second of the animation
  25155. * @param dataType The data type of the animation
  25156. * @param loopMode The loop mode of the animation
  25157. * @param enableBlending Specifies if blending should be enabled
  25158. */
  25159. constructor(
  25160. /**Name of the animation */
  25161. name: string,
  25162. /**Property to animate */
  25163. targetProperty: string,
  25164. /**The frames per second of the animation */
  25165. framePerSecond: number,
  25166. /**The data type of the animation */
  25167. dataType: number,
  25168. /**The loop mode of the animation */
  25169. loopMode?: number | undefined,
  25170. /**Specifies if blending should be enabled */
  25171. enableBlending?: boolean | undefined);
  25172. /**
  25173. * Converts the animation to a string
  25174. * @param fullDetails support for multiple levels of logging within scene loading
  25175. * @returns String form of the animation
  25176. */
  25177. toString(fullDetails?: boolean): string;
  25178. /**
  25179. * Add an event to this animation
  25180. * @param event Event to add
  25181. */
  25182. addEvent(event: AnimationEvent): void;
  25183. /**
  25184. * Remove all events found at the given frame
  25185. * @param frame The frame to remove events from
  25186. */
  25187. removeEvents(frame: number): void;
  25188. /**
  25189. * Retrieves all the events from the animation
  25190. * @returns Events from the animation
  25191. */
  25192. getEvents(): AnimationEvent[];
  25193. /**
  25194. * Creates an animation range
  25195. * @param name Name of the animation range
  25196. * @param from Starting frame of the animation range
  25197. * @param to Ending frame of the animation
  25198. */
  25199. createRange(name: string, from: number, to: number): void;
  25200. /**
  25201. * Deletes an animation range by name
  25202. * @param name Name of the animation range to delete
  25203. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25204. */
  25205. deleteRange(name: string, deleteFrames?: boolean): void;
  25206. /**
  25207. * Gets the animation range by name, or null if not defined
  25208. * @param name Name of the animation range
  25209. * @returns Nullable animation range
  25210. */
  25211. getRange(name: string): Nullable<AnimationRange>;
  25212. /**
  25213. * Gets the key frames from the animation
  25214. * @returns The key frames of the animation
  25215. */
  25216. getKeys(): Array<IAnimationKey>;
  25217. /**
  25218. * Gets the highest frame rate of the animation
  25219. * @returns Highest frame rate of the animation
  25220. */
  25221. getHighestFrame(): number;
  25222. /**
  25223. * Gets the easing function of the animation
  25224. * @returns Easing function of the animation
  25225. */
  25226. getEasingFunction(): IEasingFunction;
  25227. /**
  25228. * Sets the easing function of the animation
  25229. * @param easingFunction A custom mathematical formula for animation
  25230. */
  25231. setEasingFunction(easingFunction: EasingFunction): void;
  25232. /**
  25233. * Interpolates a scalar linearly
  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 scalar value
  25238. */
  25239. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25240. /**
  25241. * Interpolates a scalar cubically
  25242. * @param startValue Start value of the animation curve
  25243. * @param outTangent End tangent of the animation
  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 scalar value
  25248. */
  25249. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25250. /**
  25251. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  25256. */
  25257. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25258. /**
  25259. * Interpolates a quaternion cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation curve
  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 Interpolated quaternion value
  25266. */
  25267. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25268. /**
  25269. * Interpolates a Vector3 linearl
  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 scalar value
  25274. */
  25275. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25276. /**
  25277. * Interpolates a Vector3 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 InterpolatedVector3 value
  25284. */
  25285. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25286. /**
  25287. * Interpolates a Vector2 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 Vector2 value
  25292. */
  25293. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25294. /**
  25295. * Interpolates a Vector2 cubically
  25296. * @param startValue Start value of the animation curve
  25297. * @param outTangent End tangent of the animation
  25298. * @param endValue End value of the animation curve
  25299. * @param inTangent Start tangent of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns Interpolated Vector2 value
  25302. */
  25303. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25304. /**
  25305. * Interpolates a size linearly
  25306. * @param startValue Start value of the animation curve
  25307. * @param endValue End value of the animation curve
  25308. * @param gradient Scalar amount to interpolate
  25309. * @returns Interpolated Size value
  25310. */
  25311. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25312. /**
  25313. * Interpolates a Color3 linearly
  25314. * @param startValue Start value of the animation curve
  25315. * @param endValue End value of the animation curve
  25316. * @param gradient Scalar amount to interpolate
  25317. * @returns Interpolated Color3 value
  25318. */
  25319. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25320. /**
  25321. * @hidden Internal use only
  25322. */
  25323. _getKeyValue(value: any): any;
  25324. /**
  25325. * @hidden Internal use only
  25326. */
  25327. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25328. /**
  25329. * Defines the function to use to interpolate matrices
  25330. * @param startValue defines the start matrix
  25331. * @param endValue defines the end matrix
  25332. * @param gradient defines the gradient between both matrices
  25333. * @param result defines an optional target matrix where to store the interpolation
  25334. * @returns the interpolated matrix
  25335. */
  25336. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25337. /**
  25338. * Makes a copy of the animation
  25339. * @returns Cloned animation
  25340. */
  25341. clone(): Animation;
  25342. /**
  25343. * Sets the key frames of the animation
  25344. * @param values The animation key frames to set
  25345. */
  25346. setKeys(values: Array<IAnimationKey>): void;
  25347. /**
  25348. * Serializes the animation to an object
  25349. * @returns Serialized object
  25350. */
  25351. serialize(): any;
  25352. /**
  25353. * Float animation type
  25354. */
  25355. private static _ANIMATIONTYPE_FLOAT;
  25356. /**
  25357. * Vector3 animation type
  25358. */
  25359. private static _ANIMATIONTYPE_VECTOR3;
  25360. /**
  25361. * Quaternion animation type
  25362. */
  25363. private static _ANIMATIONTYPE_QUATERNION;
  25364. /**
  25365. * Matrix animation type
  25366. */
  25367. private static _ANIMATIONTYPE_MATRIX;
  25368. /**
  25369. * Color3 animation type
  25370. */
  25371. private static _ANIMATIONTYPE_COLOR3;
  25372. /**
  25373. * Vector2 animation type
  25374. */
  25375. private static _ANIMATIONTYPE_VECTOR2;
  25376. /**
  25377. * Size animation type
  25378. */
  25379. private static _ANIMATIONTYPE_SIZE;
  25380. /**
  25381. * Relative Loop Mode
  25382. */
  25383. private static _ANIMATIONLOOPMODE_RELATIVE;
  25384. /**
  25385. * Cycle Loop Mode
  25386. */
  25387. private static _ANIMATIONLOOPMODE_CYCLE;
  25388. /**
  25389. * Constant Loop Mode
  25390. */
  25391. private static _ANIMATIONLOOPMODE_CONSTANT;
  25392. /**
  25393. * Get the float animation type
  25394. */
  25395. static readonly ANIMATIONTYPE_FLOAT: number;
  25396. /**
  25397. * Get the Vector3 animation type
  25398. */
  25399. static readonly ANIMATIONTYPE_VECTOR3: number;
  25400. /**
  25401. * Get the Vector2 animation type
  25402. */
  25403. static readonly ANIMATIONTYPE_VECTOR2: number;
  25404. /**
  25405. * Get the Size animation type
  25406. */
  25407. static readonly ANIMATIONTYPE_SIZE: number;
  25408. /**
  25409. * Get the Quaternion animation type
  25410. */
  25411. static readonly ANIMATIONTYPE_QUATERNION: number;
  25412. /**
  25413. * Get the Matrix animation type
  25414. */
  25415. static readonly ANIMATIONTYPE_MATRIX: number;
  25416. /**
  25417. * Get the Color3 animation type
  25418. */
  25419. static readonly ANIMATIONTYPE_COLOR3: number;
  25420. /**
  25421. * Get the Relative Loop Mode
  25422. */
  25423. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25424. /**
  25425. * Get the Cycle Loop Mode
  25426. */
  25427. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25428. /**
  25429. * Get the Constant Loop Mode
  25430. */
  25431. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25432. /** @hidden */
  25433. static _UniversalLerp(left: any, right: any, amount: number): any;
  25434. /**
  25435. * Parses an animation object and creates an animation
  25436. * @param parsedAnimation Parsed animation object
  25437. * @returns Animation object
  25438. */
  25439. static Parse(parsedAnimation: any): Animation;
  25440. /**
  25441. * Appends the serialized animations from the source animations
  25442. * @param source Source containing the animations
  25443. * @param destination Target to store the animations
  25444. */
  25445. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25446. }
  25447. }
  25448. declare module "babylonjs/Materials/Textures/baseTexture" {
  25449. import { Observable } from "babylonjs/Misc/observable";
  25450. import { IAnimatable } from "babylonjs/Misc/tools";
  25451. import { Nullable } from "babylonjs/types";
  25452. import { Scene } from "babylonjs/scene";
  25453. import { Matrix, ISize } from "babylonjs/Maths/math";
  25454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25456. /**
  25457. * Base class of all the textures in babylon.
  25458. * It groups all the common properties the materials, post process, lights... might need
  25459. * in order to make a correct use of the texture.
  25460. */
  25461. export class BaseTexture implements IAnimatable {
  25462. /**
  25463. * Default anisotropic filtering level for the application.
  25464. * It is set to 4 as a good tradeoff between perf and quality.
  25465. */
  25466. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25467. /**
  25468. * Gets or sets the unique id of the texture
  25469. */
  25470. uniqueId: number;
  25471. /**
  25472. * Define the name of the texture.
  25473. */
  25474. name: string;
  25475. /**
  25476. * Gets or sets an object used to store user defined information.
  25477. */
  25478. metadata: any;
  25479. /**
  25480. * For internal use only. Please do not use.
  25481. */
  25482. reservedDataStore: any;
  25483. private _hasAlpha;
  25484. /**
  25485. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25486. */
  25487. hasAlpha: boolean;
  25488. /**
  25489. * Defines if the alpha value should be determined via the rgb values.
  25490. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25491. */
  25492. getAlphaFromRGB: boolean;
  25493. /**
  25494. * Intensity or strength of the texture.
  25495. * It is commonly used by materials to fine tune the intensity of the texture
  25496. */
  25497. level: number;
  25498. /**
  25499. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25500. * This is part of the texture as textures usually maps to one uv set.
  25501. */
  25502. coordinatesIndex: number;
  25503. private _coordinatesMode;
  25504. /**
  25505. * How a texture is mapped.
  25506. *
  25507. * | Value | Type | Description |
  25508. * | ----- | ----------------------------------- | ----------- |
  25509. * | 0 | EXPLICIT_MODE | |
  25510. * | 1 | SPHERICAL_MODE | |
  25511. * | 2 | PLANAR_MODE | |
  25512. * | 3 | CUBIC_MODE | |
  25513. * | 4 | PROJECTION_MODE | |
  25514. * | 5 | SKYBOX_MODE | |
  25515. * | 6 | INVCUBIC_MODE | |
  25516. * | 7 | EQUIRECTANGULAR_MODE | |
  25517. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25518. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25519. */
  25520. coordinatesMode: number;
  25521. /**
  25522. * | Value | Type | Description |
  25523. * | ----- | ------------------ | ----------- |
  25524. * | 0 | CLAMP_ADDRESSMODE | |
  25525. * | 1 | WRAP_ADDRESSMODE | |
  25526. * | 2 | MIRROR_ADDRESSMODE | |
  25527. */
  25528. wrapU: number;
  25529. /**
  25530. * | Value | Type | Description |
  25531. * | ----- | ------------------ | ----------- |
  25532. * | 0 | CLAMP_ADDRESSMODE | |
  25533. * | 1 | WRAP_ADDRESSMODE | |
  25534. * | 2 | MIRROR_ADDRESSMODE | |
  25535. */
  25536. wrapV: number;
  25537. /**
  25538. * | Value | Type | Description |
  25539. * | ----- | ------------------ | ----------- |
  25540. * | 0 | CLAMP_ADDRESSMODE | |
  25541. * | 1 | WRAP_ADDRESSMODE | |
  25542. * | 2 | MIRROR_ADDRESSMODE | |
  25543. */
  25544. wrapR: number;
  25545. /**
  25546. * With compliant hardware and browser (supporting anisotropic filtering)
  25547. * this defines the level of anisotropic filtering in the texture.
  25548. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25549. */
  25550. anisotropicFilteringLevel: number;
  25551. /**
  25552. * Define if the texture is a cube texture or if false a 2d texture.
  25553. */
  25554. isCube: boolean;
  25555. /**
  25556. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25557. */
  25558. is3D: boolean;
  25559. /**
  25560. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25561. * HDR texture are usually stored in linear space.
  25562. * This only impacts the PBR and Background materials
  25563. */
  25564. gammaSpace: boolean;
  25565. /**
  25566. * Gets whether or not the texture contains RGBD data.
  25567. */
  25568. readonly isRGBD: boolean;
  25569. /**
  25570. * Is Z inverted in the texture (useful in a cube texture).
  25571. */
  25572. invertZ: boolean;
  25573. /**
  25574. * Are mip maps generated for this texture or not.
  25575. */
  25576. readonly noMipmap: boolean;
  25577. /**
  25578. * @hidden
  25579. */
  25580. lodLevelInAlpha: boolean;
  25581. /**
  25582. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25583. */
  25584. lodGenerationOffset: number;
  25585. /**
  25586. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25587. */
  25588. lodGenerationScale: number;
  25589. /**
  25590. * Define if the texture is a render target.
  25591. */
  25592. isRenderTarget: boolean;
  25593. /**
  25594. * Define the unique id of the texture in the scene.
  25595. */
  25596. readonly uid: string;
  25597. /**
  25598. * Return a string representation of the texture.
  25599. * @returns the texture as a string
  25600. */
  25601. toString(): string;
  25602. /**
  25603. * Get the class name of the texture.
  25604. * @returns "BaseTexture"
  25605. */
  25606. getClassName(): string;
  25607. /**
  25608. * Define the list of animation attached to the texture.
  25609. */
  25610. animations: import("babylonjs/Animations/animation").Animation[];
  25611. /**
  25612. * An event triggered when the texture is disposed.
  25613. */
  25614. onDisposeObservable: Observable<BaseTexture>;
  25615. private _onDisposeObserver;
  25616. /**
  25617. * Callback triggered when the texture has been disposed.
  25618. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25619. */
  25620. onDispose: () => void;
  25621. /**
  25622. * Define the current state of the loading sequence when in delayed load mode.
  25623. */
  25624. delayLoadState: number;
  25625. private _scene;
  25626. /** @hidden */
  25627. _texture: Nullable<InternalTexture>;
  25628. private _uid;
  25629. /**
  25630. * Define if the texture is preventinga material to render or not.
  25631. * If not and the texture is not ready, the engine will use a default black texture instead.
  25632. */
  25633. readonly isBlocking: boolean;
  25634. /**
  25635. * Instantiates a new BaseTexture.
  25636. * Base class of all the textures in babylon.
  25637. * It groups all the common properties the materials, post process, lights... might need
  25638. * in order to make a correct use of the texture.
  25639. * @param scene Define the scene the texture blongs to
  25640. */
  25641. constructor(scene: Nullable<Scene>);
  25642. /**
  25643. * Get the scene the texture belongs to.
  25644. * @returns the scene or null if undefined
  25645. */
  25646. getScene(): Nullable<Scene>;
  25647. /**
  25648. * Get the texture transform matrix used to offset tile the texture for istance.
  25649. * @returns the transformation matrix
  25650. */
  25651. getTextureMatrix(): Matrix;
  25652. /**
  25653. * Get the texture reflection matrix used to rotate/transform the reflection.
  25654. * @returns the reflection matrix
  25655. */
  25656. getReflectionTextureMatrix(): Matrix;
  25657. /**
  25658. * Get the underlying lower level texture from Babylon.
  25659. * @returns the insternal texture
  25660. */
  25661. getInternalTexture(): Nullable<InternalTexture>;
  25662. /**
  25663. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25664. * @returns true if ready or not blocking
  25665. */
  25666. isReadyOrNotBlocking(): boolean;
  25667. /**
  25668. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25669. * @returns true if fully ready
  25670. */
  25671. isReady(): boolean;
  25672. private _cachedSize;
  25673. /**
  25674. * Get the size of the texture.
  25675. * @returns the texture size.
  25676. */
  25677. getSize(): ISize;
  25678. /**
  25679. * Get the base size of the texture.
  25680. * It can be different from the size if the texture has been resized for POT for instance
  25681. * @returns the base size
  25682. */
  25683. getBaseSize(): ISize;
  25684. /**
  25685. * Update the sampling mode of the texture.
  25686. * Default is Trilinear mode.
  25687. *
  25688. * | Value | Type | Description |
  25689. * | ----- | ------------------ | ----------- |
  25690. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25691. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25692. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25693. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25694. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25695. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25696. * | 7 | NEAREST_LINEAR | |
  25697. * | 8 | NEAREST_NEAREST | |
  25698. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25699. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25700. * | 11 | LINEAR_LINEAR | |
  25701. * | 12 | LINEAR_NEAREST | |
  25702. *
  25703. * > _mag_: magnification filter (close to the viewer)
  25704. * > _min_: minification filter (far from the viewer)
  25705. * > _mip_: filter used between mip map levels
  25706. *@param samplingMode Define the new sampling mode of the texture
  25707. */
  25708. updateSamplingMode(samplingMode: number): void;
  25709. /**
  25710. * Scales the texture if is `canRescale()`
  25711. * @param ratio the resize factor we want to use to rescale
  25712. */
  25713. scale(ratio: number): void;
  25714. /**
  25715. * Get if the texture can rescale.
  25716. */
  25717. readonly canRescale: boolean;
  25718. /** @hidden */
  25719. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25720. /** @hidden */
  25721. _rebuild(): void;
  25722. /**
  25723. * Triggers the load sequence in delayed load mode.
  25724. */
  25725. delayLoad(): void;
  25726. /**
  25727. * Clones the texture.
  25728. * @returns the cloned texture
  25729. */
  25730. clone(): Nullable<BaseTexture>;
  25731. /**
  25732. * Get the texture underlying type (INT, FLOAT...)
  25733. */
  25734. readonly textureType: number;
  25735. /**
  25736. * Get the texture underlying format (RGB, RGBA...)
  25737. */
  25738. readonly textureFormat: number;
  25739. /**
  25740. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25741. * This will returns an RGBA array buffer containing either in values (0-255) or
  25742. * float values (0-1) depending of the underlying buffer type.
  25743. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25744. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25745. * @param buffer defines a user defined buffer to fill with data (can be null)
  25746. * @returns The Array buffer containing the pixels data.
  25747. */
  25748. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25749. /**
  25750. * Release and destroy the underlying lower level texture aka internalTexture.
  25751. */
  25752. releaseInternalTexture(): void;
  25753. /**
  25754. * Get the polynomial representation of the texture data.
  25755. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25756. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25757. */
  25758. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25759. /** @hidden */
  25760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25761. /** @hidden */
  25762. readonly _lodTextureMid: Nullable<BaseTexture>;
  25763. /** @hidden */
  25764. readonly _lodTextureLow: Nullable<BaseTexture>;
  25765. /**
  25766. * Dispose the texture and release its associated resources.
  25767. */
  25768. dispose(): void;
  25769. /**
  25770. * Serialize the texture into a JSON representation that can be parsed later on.
  25771. * @returns the JSON representation of the texture
  25772. */
  25773. serialize(): any;
  25774. /**
  25775. * Helper function to be called back once a list of texture contains only ready textures.
  25776. * @param textures Define the list of textures to wait for
  25777. * @param callback Define the callback triggered once the entire list will be ready
  25778. */
  25779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25780. }
  25781. }
  25782. declare module "babylonjs/Materials/uniformBuffer" {
  25783. import { Nullable, FloatArray } from "babylonjs/types";
  25784. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25785. import { Engine } from "babylonjs/Engines/engine";
  25786. import { Effect } from "babylonjs/Materials/effect";
  25787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25788. /**
  25789. * Uniform buffer objects.
  25790. *
  25791. * Handles blocks of uniform on the GPU.
  25792. *
  25793. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25794. *
  25795. * For more information, please refer to :
  25796. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25797. */
  25798. export class UniformBuffer {
  25799. private _engine;
  25800. private _buffer;
  25801. private _data;
  25802. private _bufferData;
  25803. private _dynamic?;
  25804. private _uniformLocations;
  25805. private _uniformSizes;
  25806. private _uniformLocationPointer;
  25807. private _needSync;
  25808. private _noUBO;
  25809. private _currentEffect;
  25810. private static _MAX_UNIFORM_SIZE;
  25811. private static _tempBuffer;
  25812. /**
  25813. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25818. /**
  25819. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25824. /**
  25825. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  25830. /**
  25831. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25836. /**
  25837. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25842. /**
  25843. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25848. /**
  25849. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  25854. /**
  25855. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  25860. /**
  25861. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25862. * This is dynamic to allow compat with webgl 1 and 2.
  25863. * You will need to pass the name of the uniform as well as the value.
  25864. */
  25865. updateVector4: (name: string, vector: Vector4) => void;
  25866. /**
  25867. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25868. * This is dynamic to allow compat with webgl 1 and 2.
  25869. * You will need to pass the name of the uniform as well as the value.
  25870. */
  25871. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25872. /**
  25873. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25874. * This is dynamic to allow compat with webgl 1 and 2.
  25875. * You will need to pass the name of the uniform as well as the value.
  25876. */
  25877. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25878. /**
  25879. * Instantiates a new Uniform buffer objects.
  25880. *
  25881. * Handles blocks of uniform on the GPU.
  25882. *
  25883. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25884. *
  25885. * For more information, please refer to :
  25886. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25887. * @param engine Define the engine the buffer is associated with
  25888. * @param data Define the data contained in the buffer
  25889. * @param dynamic Define if the buffer is updatable
  25890. */
  25891. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25892. /**
  25893. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25894. * or just falling back on setUniformXXX calls.
  25895. */
  25896. readonly useUbo: boolean;
  25897. /**
  25898. * Indicates if the WebGL underlying uniform buffer is in sync
  25899. * with the javascript cache data.
  25900. */
  25901. readonly isSync: boolean;
  25902. /**
  25903. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25904. * Also, a dynamic UniformBuffer will disable cache verification and always
  25905. * update the underlying WebGL uniform buffer to the GPU.
  25906. * @returns if Dynamic, otherwise false
  25907. */
  25908. isDynamic(): boolean;
  25909. /**
  25910. * The data cache on JS side.
  25911. * @returns the underlying data as a float array
  25912. */
  25913. getData(): Float32Array;
  25914. /**
  25915. * The underlying WebGL Uniform buffer.
  25916. * @returns the webgl buffer
  25917. */
  25918. getBuffer(): Nullable<WebGLBuffer>;
  25919. /**
  25920. * std140 layout specifies how to align data within an UBO structure.
  25921. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25922. * for specs.
  25923. */
  25924. private _fillAlignment;
  25925. /**
  25926. * Adds an uniform in the buffer.
  25927. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25928. * for the layout to be correct !
  25929. * @param name Name of the uniform, as used in the uniform block in the shader.
  25930. * @param size Data size, or data directly.
  25931. */
  25932. addUniform(name: string, size: number | number[]): void;
  25933. /**
  25934. * Adds a Matrix 4x4 to the uniform buffer.
  25935. * @param name Name of the uniform, as used in the uniform block in the shader.
  25936. * @param mat A 4x4 matrix.
  25937. */
  25938. addMatrix(name: string, mat: Matrix): void;
  25939. /**
  25940. * Adds a vec2 to the uniform buffer.
  25941. * @param name Name of the uniform, as used in the uniform block in the shader.
  25942. * @param x Define the x component value of the vec2
  25943. * @param y Define the y component value of the vec2
  25944. */
  25945. addFloat2(name: string, x: number, y: number): void;
  25946. /**
  25947. * Adds a vec3 to the uniform buffer.
  25948. * @param name Name of the uniform, as used in the uniform block in the shader.
  25949. * @param x Define the x component value of the vec3
  25950. * @param y Define the y component value of the vec3
  25951. * @param z Define the z component value of the vec3
  25952. */
  25953. addFloat3(name: string, x: number, y: number, z: number): void;
  25954. /**
  25955. * Adds a vec3 to the uniform buffer.
  25956. * @param name Name of the uniform, as used in the uniform block in the shader.
  25957. * @param color Define the vec3 from a Color
  25958. */
  25959. addColor3(name: string, color: Color3): void;
  25960. /**
  25961. * Adds a vec4 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. * @param color Define the rgb components from a Color
  25964. * @param alpha Define the a component of the vec4
  25965. */
  25966. addColor4(name: string, color: Color3, alpha: number): void;
  25967. /**
  25968. * Adds a vec3 to the uniform buffer.
  25969. * @param name Name of the uniform, as used in the uniform block in the shader.
  25970. * @param vector Define the vec3 components from a Vector
  25971. */
  25972. addVector3(name: string, vector: Vector3): void;
  25973. /**
  25974. * Adds a Matrix 3x3 to the uniform buffer.
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. */
  25977. addMatrix3x3(name: string): void;
  25978. /**
  25979. * Adds a Matrix 2x2 to the uniform buffer.
  25980. * @param name Name of the uniform, as used in the uniform block in the shader.
  25981. */
  25982. addMatrix2x2(name: string): void;
  25983. /**
  25984. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25985. */
  25986. create(): void;
  25987. /** @hidden */
  25988. _rebuild(): void;
  25989. /**
  25990. * Updates the WebGL Uniform Buffer on the GPU.
  25991. * If the `dynamic` flag is set to true, no cache comparison is done.
  25992. * Otherwise, the buffer will be updated only if the cache differs.
  25993. */
  25994. update(): void;
  25995. /**
  25996. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25997. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25998. * @param data Define the flattened data
  25999. * @param size Define the size of the data.
  26000. */
  26001. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26002. private _updateMatrix3x3ForUniform;
  26003. private _updateMatrix3x3ForEffect;
  26004. private _updateMatrix2x2ForEffect;
  26005. private _updateMatrix2x2ForUniform;
  26006. private _updateFloatForEffect;
  26007. private _updateFloatForUniform;
  26008. private _updateFloat2ForEffect;
  26009. private _updateFloat2ForUniform;
  26010. private _updateFloat3ForEffect;
  26011. private _updateFloat3ForUniform;
  26012. private _updateFloat4ForEffect;
  26013. private _updateFloat4ForUniform;
  26014. private _updateMatrixForEffect;
  26015. private _updateMatrixForUniform;
  26016. private _updateVector3ForEffect;
  26017. private _updateVector3ForUniform;
  26018. private _updateVector4ForEffect;
  26019. private _updateVector4ForUniform;
  26020. private _updateColor3ForEffect;
  26021. private _updateColor3ForUniform;
  26022. private _updateColor4ForEffect;
  26023. private _updateColor4ForUniform;
  26024. /**
  26025. * Sets a sampler uniform on the effect.
  26026. * @param name Define the name of the sampler.
  26027. * @param texture Define the texture to set in the sampler
  26028. */
  26029. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26030. /**
  26031. * Directly updates the value of the uniform in the cache AND on the GPU.
  26032. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26033. * @param data Define the flattened data
  26034. */
  26035. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26036. /**
  26037. * Binds this uniform buffer to an effect.
  26038. * @param effect Define the effect to bind the buffer to
  26039. * @param name Name of the uniform block in the shader.
  26040. */
  26041. bindToEffect(effect: Effect, name: string): void;
  26042. /**
  26043. * Disposes the uniform buffer.
  26044. */
  26045. dispose(): void;
  26046. }
  26047. }
  26048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26049. import { Nullable } from "babylonjs/types";
  26050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26051. /**
  26052. * This represents the required contract to create a new type of texture loader.
  26053. */
  26054. export interface IInternalTextureLoader {
  26055. /**
  26056. * Defines wether the loader supports cascade loading the different faces.
  26057. */
  26058. supportCascades: boolean;
  26059. /**
  26060. * This returns if the loader support the current file information.
  26061. * @param extension defines the file extension of the file being loaded
  26062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26063. * @param fallback defines the fallback internal texture if any
  26064. * @param isBase64 defines whether the texture is encoded as a base64
  26065. * @param isBuffer defines whether the texture data are stored as a buffer
  26066. * @returns true if the loader can load the specified file
  26067. */
  26068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26069. /**
  26070. * Transform the url before loading if required.
  26071. * @param rootUrl the url of the texture
  26072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26073. * @returns the transformed texture
  26074. */
  26075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26076. /**
  26077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26078. * @param rootUrl the url of the texture
  26079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26080. * @returns the fallback texture
  26081. */
  26082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26083. /**
  26084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26085. * @param data contains the texture data
  26086. * @param texture defines the BabylonJS internal texture
  26087. * @param createPolynomials will be true if polynomials have been requested
  26088. * @param onLoad defines the callback to trigger once the texture is ready
  26089. * @param onError defines the callback to trigger in case of error
  26090. */
  26091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26092. /**
  26093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26094. * @param data contains the texture data
  26095. * @param texture defines the BabylonJS internal texture
  26096. * @param callback defines the method to call once ready to upload
  26097. */
  26098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26099. }
  26100. }
  26101. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26102. import { Scene } from "babylonjs/scene";
  26103. import { Engine } from "babylonjs/Engines/engine";
  26104. import { Texture } from "babylonjs/Materials/Textures/texture";
  26105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26106. /**
  26107. * Creation options of the multi render target texture.
  26108. */
  26109. export interface IMultiRenderTargetOptions {
  26110. /**
  26111. * Define if the texture needs to create mip maps after render.
  26112. */
  26113. generateMipMaps?: boolean;
  26114. /**
  26115. * Define the types of all the draw buffers we want to create
  26116. */
  26117. types?: number[];
  26118. /**
  26119. * Define the sampling modes of all the draw buffers we want to create
  26120. */
  26121. samplingModes?: number[];
  26122. /**
  26123. * Define if a depth buffer is required
  26124. */
  26125. generateDepthBuffer?: boolean;
  26126. /**
  26127. * Define if a stencil buffer is required
  26128. */
  26129. generateStencilBuffer?: boolean;
  26130. /**
  26131. * Define if a depth texture is required instead of a depth buffer
  26132. */
  26133. generateDepthTexture?: boolean;
  26134. /**
  26135. * Define the number of desired draw buffers
  26136. */
  26137. textureCount?: number;
  26138. /**
  26139. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26140. */
  26141. doNotChangeAspectRatio?: boolean;
  26142. /**
  26143. * Define the default type of the buffers we are creating
  26144. */
  26145. defaultType?: number;
  26146. }
  26147. /**
  26148. * A multi render target, like a render target provides the ability to render to a texture.
  26149. * Unlike the render target, it can render to several draw buffers in one draw.
  26150. * This is specially interesting in deferred rendering or for any effects requiring more than
  26151. * just one color from a single pass.
  26152. */
  26153. export class MultiRenderTarget extends RenderTargetTexture {
  26154. private _internalTextures;
  26155. private _textures;
  26156. private _multiRenderTargetOptions;
  26157. /**
  26158. * Get if draw buffers are currently supported by the used hardware and browser.
  26159. */
  26160. readonly isSupported: boolean;
  26161. /**
  26162. * Get the list of textures generated by the multi render target.
  26163. */
  26164. readonly textures: Texture[];
  26165. /**
  26166. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26167. */
  26168. readonly depthTexture: Texture;
  26169. /**
  26170. * Set the wrapping mode on U of all the textures we are rendering to.
  26171. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26172. */
  26173. wrapU: number;
  26174. /**
  26175. * Set the wrapping mode on V of all the textures we are rendering to.
  26176. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26177. */
  26178. wrapV: number;
  26179. /**
  26180. * Instantiate a new multi render target texture.
  26181. * A multi render target, like a render target provides the ability to render to a texture.
  26182. * Unlike the render target, it can render to several draw buffers in one draw.
  26183. * This is specially interesting in deferred rendering or for any effects requiring more than
  26184. * just one color from a single pass.
  26185. * @param name Define the name of the texture
  26186. * @param size Define the size of the buffers to render to
  26187. * @param count Define the number of target we are rendering into
  26188. * @param scene Define the scene the texture belongs to
  26189. * @param options Define the options used to create the multi render target
  26190. */
  26191. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26192. /** @hidden */
  26193. _rebuild(): void;
  26194. private _createInternalTextures;
  26195. private _createTextures;
  26196. /**
  26197. * Define the number of samples used if MSAA is enabled.
  26198. */
  26199. samples: number;
  26200. /**
  26201. * Resize all the textures in the multi render target.
  26202. * Be carrefull as it will recreate all the data in the new texture.
  26203. * @param size Define the new size
  26204. */
  26205. resize(size: any): void;
  26206. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26207. /**
  26208. * Dispose the render targets and their associated resources
  26209. */
  26210. dispose(): void;
  26211. /**
  26212. * Release all the underlying texture used as draw buffers.
  26213. */
  26214. releaseInternalTextures(): void;
  26215. }
  26216. }
  26217. declare module "babylonjs/Audio/analyser" {
  26218. import { Scene } from "babylonjs/scene";
  26219. /**
  26220. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26222. */
  26223. export class Analyser {
  26224. /**
  26225. * Gets or sets the smoothing
  26226. * @ignorenaming
  26227. */
  26228. SMOOTHING: number;
  26229. /**
  26230. * Gets or sets the FFT table size
  26231. * @ignorenaming
  26232. */
  26233. FFT_SIZE: number;
  26234. /**
  26235. * Gets or sets the bar graph amplitude
  26236. * @ignorenaming
  26237. */
  26238. BARGRAPHAMPLITUDE: number;
  26239. /**
  26240. * Gets or sets the position of the debug canvas
  26241. * @ignorenaming
  26242. */
  26243. DEBUGCANVASPOS: {
  26244. x: number;
  26245. y: number;
  26246. };
  26247. /**
  26248. * Gets or sets the debug canvas size
  26249. * @ignorenaming
  26250. */
  26251. DEBUGCANVASSIZE: {
  26252. width: number;
  26253. height: number;
  26254. };
  26255. private _byteFreqs;
  26256. private _byteTime;
  26257. private _floatFreqs;
  26258. private _webAudioAnalyser;
  26259. private _debugCanvas;
  26260. private _debugCanvasContext;
  26261. private _scene;
  26262. private _registerFunc;
  26263. private _audioEngine;
  26264. /**
  26265. * Creates a new analyser
  26266. * @param scene defines hosting scene
  26267. */
  26268. constructor(scene: Scene);
  26269. /**
  26270. * Get the number of data values you will have to play with for the visualization
  26271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26272. * @returns a number
  26273. */
  26274. getFrequencyBinCount(): number;
  26275. /**
  26276. * Gets the current frequency data as a byte array
  26277. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26278. * @returns a Uint8Array
  26279. */
  26280. getByteFrequencyData(): Uint8Array;
  26281. /**
  26282. * Gets the current waveform as a byte array
  26283. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26284. * @returns a Uint8Array
  26285. */
  26286. getByteTimeDomainData(): Uint8Array;
  26287. /**
  26288. * Gets the current frequency data as a float array
  26289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26290. * @returns a Float32Array
  26291. */
  26292. getFloatFrequencyData(): Float32Array;
  26293. /**
  26294. * Renders the debug canvas
  26295. */
  26296. drawDebugCanvas(): void;
  26297. /**
  26298. * Stops rendering the debug canvas and removes it
  26299. */
  26300. stopDebugCanvas(): void;
  26301. /**
  26302. * Connects two audio nodes
  26303. * @param inputAudioNode defines first node to connect
  26304. * @param outputAudioNode defines second node to connect
  26305. */
  26306. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26307. /**
  26308. * Releases all associated resources
  26309. */
  26310. dispose(): void;
  26311. }
  26312. }
  26313. declare module "babylonjs/Audio/audioEngine" {
  26314. import { IDisposable } from "babylonjs/scene";
  26315. import { Analyser } from "babylonjs/Audio/analyser";
  26316. import { Nullable } from "babylonjs/types";
  26317. import { Observable } from "babylonjs/Misc/observable";
  26318. /**
  26319. * This represents an audio engine and it is responsible
  26320. * to play, synchronize and analyse sounds throughout the application.
  26321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26322. */
  26323. export interface IAudioEngine extends IDisposable {
  26324. /**
  26325. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26326. */
  26327. readonly canUseWebAudio: boolean;
  26328. /**
  26329. * Gets the current AudioContext if available.
  26330. */
  26331. readonly audioContext: Nullable<AudioContext>;
  26332. /**
  26333. * The master gain node defines the global audio volume of your audio engine.
  26334. */
  26335. readonly masterGain: GainNode;
  26336. /**
  26337. * Gets whether or not mp3 are supported by your browser.
  26338. */
  26339. readonly isMP3supported: boolean;
  26340. /**
  26341. * Gets whether or not ogg are supported by your browser.
  26342. */
  26343. readonly isOGGsupported: boolean;
  26344. /**
  26345. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26346. * @ignoreNaming
  26347. */
  26348. WarnedWebAudioUnsupported: boolean;
  26349. /**
  26350. * Defines if the audio engine relies on a custom unlocked button.
  26351. * In this case, the embedded button will not be displayed.
  26352. */
  26353. useCustomUnlockedButton: boolean;
  26354. /**
  26355. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26356. */
  26357. readonly unlocked: boolean;
  26358. /**
  26359. * Event raised when audio has been unlocked on the browser.
  26360. */
  26361. onAudioUnlockedObservable: Observable<AudioEngine>;
  26362. /**
  26363. * Event raised when audio has been locked on the browser.
  26364. */
  26365. onAudioLockedObservable: Observable<AudioEngine>;
  26366. /**
  26367. * Flags the audio engine in Locked state.
  26368. * This happens due to new browser policies preventing audio to autoplay.
  26369. */
  26370. lock(): void;
  26371. /**
  26372. * Unlocks the audio engine once a user action has been done on the dom.
  26373. * This is helpful to resume play once browser policies have been satisfied.
  26374. */
  26375. unlock(): void;
  26376. }
  26377. /**
  26378. * This represents the default audio engine used in babylon.
  26379. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26381. */
  26382. export class AudioEngine implements IAudioEngine {
  26383. private _audioContext;
  26384. private _audioContextInitialized;
  26385. private _muteButton;
  26386. private _hostElement;
  26387. /**
  26388. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26389. */
  26390. canUseWebAudio: boolean;
  26391. /**
  26392. * The master gain node defines the global audio volume of your audio engine.
  26393. */
  26394. masterGain: GainNode;
  26395. /**
  26396. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26397. * @ignoreNaming
  26398. */
  26399. WarnedWebAudioUnsupported: boolean;
  26400. /**
  26401. * Gets whether or not mp3 are supported by your browser.
  26402. */
  26403. isMP3supported: boolean;
  26404. /**
  26405. * Gets whether or not ogg are supported by your browser.
  26406. */
  26407. isOGGsupported: boolean;
  26408. /**
  26409. * Gets whether audio has been unlocked on the device.
  26410. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26411. * a user interaction has happened.
  26412. */
  26413. unlocked: boolean;
  26414. /**
  26415. * Defines if the audio engine relies on a custom unlocked button.
  26416. * In this case, the embedded button will not be displayed.
  26417. */
  26418. useCustomUnlockedButton: boolean;
  26419. /**
  26420. * Event raised when audio has been unlocked on the browser.
  26421. */
  26422. onAudioUnlockedObservable: Observable<AudioEngine>;
  26423. /**
  26424. * Event raised when audio has been locked on the browser.
  26425. */
  26426. onAudioLockedObservable: Observable<AudioEngine>;
  26427. /**
  26428. * Gets the current AudioContext if available.
  26429. */
  26430. readonly audioContext: Nullable<AudioContext>;
  26431. private _connectedAnalyser;
  26432. /**
  26433. * Instantiates a new audio engine.
  26434. *
  26435. * There should be only one per page as some browsers restrict the number
  26436. * of audio contexts you can create.
  26437. * @param hostElement defines the host element where to display the mute icon if necessary
  26438. */
  26439. constructor(hostElement?: Nullable<HTMLElement>);
  26440. /**
  26441. * Flags the audio engine in Locked state.
  26442. * This happens due to new browser policies preventing audio to autoplay.
  26443. */
  26444. lock(): void;
  26445. /**
  26446. * Unlocks the audio engine once a user action has been done on the dom.
  26447. * This is helpful to resume play once browser policies have been satisfied.
  26448. */
  26449. unlock(): void;
  26450. private _resumeAudioContext;
  26451. private _initializeAudioContext;
  26452. private _tryToRun;
  26453. private _triggerRunningState;
  26454. private _triggerSuspendedState;
  26455. private _displayMuteButton;
  26456. private _moveButtonToTopLeft;
  26457. private _onResize;
  26458. private _hideMuteButton;
  26459. /**
  26460. * Destroy and release the resources associated with the audio ccontext.
  26461. */
  26462. dispose(): void;
  26463. /**
  26464. * Gets the global volume sets on the master gain.
  26465. * @returns the global volume if set or -1 otherwise
  26466. */
  26467. getGlobalVolume(): number;
  26468. /**
  26469. * Sets the global volume of your experience (sets on the master gain).
  26470. * @param newVolume Defines the new global volume of the application
  26471. */
  26472. setGlobalVolume(newVolume: number): void;
  26473. /**
  26474. * Connect the audio engine to an audio analyser allowing some amazing
  26475. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26477. * @param analyser The analyser to connect to the engine
  26478. */
  26479. connectToAnalyser(analyser: Analyser): void;
  26480. }
  26481. }
  26482. declare module "babylonjs/Loading/loadingScreen" {
  26483. /**
  26484. * Interface used to present a loading screen while loading a scene
  26485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26486. */
  26487. export interface ILoadingScreen {
  26488. /**
  26489. * Function called to display the loading screen
  26490. */
  26491. displayLoadingUI: () => void;
  26492. /**
  26493. * Function called to hide the loading screen
  26494. */
  26495. hideLoadingUI: () => void;
  26496. /**
  26497. * Gets or sets the color to use for the background
  26498. */
  26499. loadingUIBackgroundColor: string;
  26500. /**
  26501. * Gets or sets the text to display while loading
  26502. */
  26503. loadingUIText: string;
  26504. }
  26505. /**
  26506. * Class used for the default loading screen
  26507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26508. */
  26509. export class DefaultLoadingScreen implements ILoadingScreen {
  26510. private _renderingCanvas;
  26511. private _loadingText;
  26512. private _loadingDivBackgroundColor;
  26513. private _loadingDiv;
  26514. private _loadingTextDiv;
  26515. /**
  26516. * Creates a new default loading screen
  26517. * @param _renderingCanvas defines the canvas used to render the scene
  26518. * @param _loadingText defines the default text to display
  26519. * @param _loadingDivBackgroundColor defines the default background color
  26520. */
  26521. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26522. /**
  26523. * Function called to display the loading screen
  26524. */
  26525. displayLoadingUI(): void;
  26526. /**
  26527. * Function called to hide the loading screen
  26528. */
  26529. hideLoadingUI(): void;
  26530. /**
  26531. * Gets or sets the text to display while loading
  26532. */
  26533. loadingUIText: string;
  26534. /**
  26535. * Gets or sets the color to use for the background
  26536. */
  26537. loadingUIBackgroundColor: string;
  26538. private _resizeLoadingUI;
  26539. }
  26540. }
  26541. declare module "babylonjs/Materials/Textures/videoTexture" {
  26542. import { Observable } from "babylonjs/Misc/observable";
  26543. import { Nullable } from "babylonjs/types";
  26544. import { Scene } from "babylonjs/scene";
  26545. import { Texture } from "babylonjs/Materials/Textures/texture";
  26546. /**
  26547. * Settings for finer control over video usage
  26548. */
  26549. export interface VideoTextureSettings {
  26550. /**
  26551. * Applies `autoplay` to video, if specified
  26552. */
  26553. autoPlay?: boolean;
  26554. /**
  26555. * Applies `loop` to video, if specified
  26556. */
  26557. loop?: boolean;
  26558. /**
  26559. * Automatically updates internal texture from video at every frame in the render loop
  26560. */
  26561. autoUpdateTexture: boolean;
  26562. /**
  26563. * Image src displayed during the video loading or until the user interacts with the video.
  26564. */
  26565. poster?: string;
  26566. }
  26567. /**
  26568. * If you want to display a video in your scene, this is the special texture for that.
  26569. * This special texture works similar to other textures, with the exception of a few parameters.
  26570. * @see https://doc.babylonjs.com/how_to/video_texture
  26571. */
  26572. export class VideoTexture extends Texture {
  26573. /**
  26574. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26575. */
  26576. readonly autoUpdateTexture: boolean;
  26577. /**
  26578. * The video instance used by the texture internally
  26579. */
  26580. readonly video: HTMLVideoElement;
  26581. private _onUserActionRequestedObservable;
  26582. /**
  26583. * Event triggerd when a dom action is required by the user to play the video.
  26584. * This happens due to recent changes in browser policies preventing video to auto start.
  26585. */
  26586. readonly onUserActionRequestedObservable: Observable<Texture>;
  26587. private _generateMipMaps;
  26588. private _engine;
  26589. private _stillImageCaptured;
  26590. private _displayingPosterTexture;
  26591. private _settings;
  26592. private _createInternalTextureOnEvent;
  26593. /**
  26594. * Creates a video texture.
  26595. * If you want to display a video in your scene, this is the special texture for that.
  26596. * This special texture works similar to other textures, with the exception of a few parameters.
  26597. * @see https://doc.babylonjs.com/how_to/video_texture
  26598. * @param name optional name, will detect from video source, if not defined
  26599. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26600. * @param scene is obviously the current scene.
  26601. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26602. * @param invertY is false by default but can be used to invert video on Y axis
  26603. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26604. * @param settings allows finer control over video usage
  26605. */
  26606. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26607. private _getName;
  26608. private _getVideo;
  26609. private _createInternalTexture;
  26610. private reset;
  26611. /**
  26612. * @hidden Internal method to initiate `update`.
  26613. */
  26614. _rebuild(): void;
  26615. /**
  26616. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26617. */
  26618. update(): void;
  26619. /**
  26620. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26621. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26622. */
  26623. updateTexture(isVisible: boolean): void;
  26624. protected _updateInternalTexture: () => void;
  26625. /**
  26626. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26627. * @param url New url.
  26628. */
  26629. updateURL(url: string): void;
  26630. /**
  26631. * Dispose the texture and release its associated resources.
  26632. */
  26633. dispose(): void;
  26634. /**
  26635. * Creates a video texture straight from your WebCam video feed.
  26636. * @param scene Define the scene the texture should be created in
  26637. * @param onReady Define a callback to triggered once the texture will be ready
  26638. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26639. */
  26640. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26641. minWidth: number;
  26642. maxWidth: number;
  26643. minHeight: number;
  26644. maxHeight: number;
  26645. deviceId: string;
  26646. }): void;
  26647. }
  26648. }
  26649. declare module "babylonjs/Engines/engine" {
  26650. import { Observable } from "babylonjs/Misc/observable";
  26651. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26652. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26653. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26654. import { Camera } from "babylonjs/Cameras/camera";
  26655. import { Scene } from "babylonjs/scene";
  26656. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26657. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26658. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26659. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26660. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26661. import { Material } from "babylonjs/Materials/material";
  26662. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26665. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26666. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26667. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26668. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26669. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26673. /**
  26674. * Interface for attribute information associated with buffer instanciation
  26675. */
  26676. export class InstancingAttributeInfo {
  26677. /**
  26678. * Index/offset of the attribute in the vertex shader
  26679. */
  26680. index: number;
  26681. /**
  26682. * size of the attribute, 1, 2, 3 or 4
  26683. */
  26684. attributeSize: number;
  26685. /**
  26686. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26687. * default is FLOAT
  26688. */
  26689. attribyteType: number;
  26690. /**
  26691. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26692. */
  26693. normalized: boolean;
  26694. /**
  26695. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26696. */
  26697. offset: number;
  26698. /**
  26699. * Name of the GLSL attribute, for debugging purpose only
  26700. */
  26701. attributeName: string;
  26702. }
  26703. /**
  26704. * Define options used to create a depth texture
  26705. */
  26706. export class DepthTextureCreationOptions {
  26707. /** Specifies whether or not a stencil should be allocated in the texture */
  26708. generateStencil?: boolean;
  26709. /** Specifies whether or not bilinear filtering is enable on the texture */
  26710. bilinearFiltering?: boolean;
  26711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26712. comparisonFunction?: number;
  26713. /** Specifies if the created texture is a cube texture */
  26714. isCube?: boolean;
  26715. }
  26716. /**
  26717. * Class used to describe the capabilities of the engine relatively to the current browser
  26718. */
  26719. export class EngineCapabilities {
  26720. /** Maximum textures units per fragment shader */
  26721. maxTexturesImageUnits: number;
  26722. /** Maximum texture units per vertex shader */
  26723. maxVertexTextureImageUnits: number;
  26724. /** Maximum textures units in the entire pipeline */
  26725. maxCombinedTexturesImageUnits: number;
  26726. /** Maximum texture size */
  26727. maxTextureSize: number;
  26728. /** Maximum cube texture size */
  26729. maxCubemapTextureSize: number;
  26730. /** Maximum render texture size */
  26731. maxRenderTextureSize: number;
  26732. /** Maximum number of vertex attributes */
  26733. maxVertexAttribs: number;
  26734. /** Maximum number of varyings */
  26735. maxVaryingVectors: number;
  26736. /** Maximum number of uniforms per vertex shader */
  26737. maxVertexUniformVectors: number;
  26738. /** Maximum number of uniforms per fragment shader */
  26739. maxFragmentUniformVectors: number;
  26740. /** Defines if standard derivates (dx/dy) are supported */
  26741. standardDerivatives: boolean;
  26742. /** Defines if s3tc texture compression is supported */
  26743. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26744. /** Defines if pvrtc texture compression is supported */
  26745. pvrtc: any;
  26746. /** Defines if etc1 texture compression is supported */
  26747. etc1: any;
  26748. /** Defines if etc2 texture compression is supported */
  26749. etc2: any;
  26750. /** Defines if astc texture compression is supported */
  26751. astc: any;
  26752. /** Defines if float textures are supported */
  26753. textureFloat: boolean;
  26754. /** Defines if vertex array objects are supported */
  26755. vertexArrayObject: boolean;
  26756. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26757. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26758. /** Gets the maximum level of anisotropy supported */
  26759. maxAnisotropy: number;
  26760. /** Defines if instancing is supported */
  26761. instancedArrays: boolean;
  26762. /** Defines if 32 bits indices are supported */
  26763. uintIndices: boolean;
  26764. /** Defines if high precision shaders are supported */
  26765. highPrecisionShaderSupported: boolean;
  26766. /** Defines if depth reading in the fragment shader is supported */
  26767. fragmentDepthSupported: boolean;
  26768. /** Defines if float texture linear filtering is supported*/
  26769. textureFloatLinearFiltering: boolean;
  26770. /** Defines if rendering to float textures is supported */
  26771. textureFloatRender: boolean;
  26772. /** Defines if half float textures are supported*/
  26773. textureHalfFloat: boolean;
  26774. /** Defines if half float texture linear filtering is supported*/
  26775. textureHalfFloatLinearFiltering: boolean;
  26776. /** Defines if rendering to half float textures is supported */
  26777. textureHalfFloatRender: boolean;
  26778. /** Defines if textureLOD shader command is supported */
  26779. textureLOD: boolean;
  26780. /** Defines if draw buffers extension is supported */
  26781. drawBuffersExtension: boolean;
  26782. /** Defines if depth textures are supported */
  26783. depthTextureExtension: boolean;
  26784. /** Defines if float color buffer are supported */
  26785. colorBufferFloat: boolean;
  26786. /** Gets disjoint timer query extension (null if not supported) */
  26787. timerQuery: EXT_disjoint_timer_query;
  26788. /** Defines if timestamp can be used with timer query */
  26789. canUseTimestampForTimerQuery: boolean;
  26790. /** Function used to let the system compiles shaders in background */
  26791. parallelShaderCompile: {
  26792. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26793. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26794. COMPLETION_STATUS_KHR: number;
  26795. };
  26796. }
  26797. /** Interface defining initialization parameters for Engine class */
  26798. export interface EngineOptions extends WebGLContextAttributes {
  26799. /**
  26800. * Defines if the engine should no exceed a specified device ratio
  26801. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26802. */
  26803. limitDeviceRatio?: number;
  26804. /**
  26805. * Defines if webvr should be enabled automatically
  26806. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26807. */
  26808. autoEnableWebVR?: boolean;
  26809. /**
  26810. * Defines if webgl2 should be turned off even if supported
  26811. * @see http://doc.babylonjs.com/features/webgl2
  26812. */
  26813. disableWebGL2Support?: boolean;
  26814. /**
  26815. * Defines if webaudio should be initialized as well
  26816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26817. */
  26818. audioEngine?: boolean;
  26819. /**
  26820. * Defines if animations should run using a deterministic lock step
  26821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26822. */
  26823. deterministicLockstep?: boolean;
  26824. /** Defines the maximum steps to use with deterministic lock step mode */
  26825. lockstepMaxSteps?: number;
  26826. /**
  26827. * Defines that engine should ignore context lost events
  26828. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26829. */
  26830. doNotHandleContextLost?: boolean;
  26831. /**
  26832. * Defines that engine should ignore modifying touch action attribute and style
  26833. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26834. */
  26835. doNotHandleTouchAction?: boolean;
  26836. }
  26837. /**
  26838. * Defines the interface used by display changed events
  26839. */
  26840. export interface IDisplayChangedEventArgs {
  26841. /** Gets the vrDisplay object (if any) */
  26842. vrDisplay: Nullable<any>;
  26843. /** Gets a boolean indicating if webVR is supported */
  26844. vrSupported: boolean;
  26845. }
  26846. /**
  26847. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26848. */
  26849. export class Engine {
  26850. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26851. static ExceptionList: ({
  26852. key: string;
  26853. capture: string;
  26854. captureConstraint: number;
  26855. targets: string[];
  26856. } | {
  26857. key: string;
  26858. capture: null;
  26859. captureConstraint: null;
  26860. targets: string[];
  26861. })[];
  26862. /** Gets the list of created engines */
  26863. static readonly Instances: Engine[];
  26864. /**
  26865. * Gets the latest created engine
  26866. */
  26867. static readonly LastCreatedEngine: Nullable<Engine>;
  26868. /**
  26869. * Gets the latest created scene
  26870. */
  26871. static readonly LastCreatedScene: Nullable<Scene>;
  26872. /**
  26873. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26874. * @param flag defines which part of the materials must be marked as dirty
  26875. * @param predicate defines a predicate used to filter which materials should be affected
  26876. */
  26877. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26878. /**
  26879. * Hidden
  26880. */
  26881. static _TextureLoaders: IInternalTextureLoader[];
  26882. /** Defines that alpha blending is disabled */
  26883. static readonly ALPHA_DISABLE: number;
  26884. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26885. static readonly ALPHA_ADD: number;
  26886. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26887. static readonly ALPHA_COMBINE: number;
  26888. /** Defines that alpha blending to DEST - SRC * DEST */
  26889. static readonly ALPHA_SUBTRACT: number;
  26890. /** Defines that alpha blending to SRC * DEST */
  26891. static readonly ALPHA_MULTIPLY: number;
  26892. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26893. static readonly ALPHA_MAXIMIZED: number;
  26894. /** Defines that alpha blending to SRC + DEST */
  26895. static readonly ALPHA_ONEONE: number;
  26896. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26897. static readonly ALPHA_PREMULTIPLIED: number;
  26898. /**
  26899. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26900. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26901. */
  26902. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26903. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26904. static readonly ALPHA_INTERPOLATE: number;
  26905. /**
  26906. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26907. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26908. */
  26909. static readonly ALPHA_SCREENMODE: number;
  26910. /** Defines that the ressource is not delayed*/
  26911. static readonly DELAYLOADSTATE_NONE: number;
  26912. /** Defines that the ressource was successfully delay loaded */
  26913. static readonly DELAYLOADSTATE_LOADED: number;
  26914. /** Defines that the ressource is currently delay loading */
  26915. static readonly DELAYLOADSTATE_LOADING: number;
  26916. /** Defines that the ressource is delayed and has not started loading */
  26917. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26918. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26919. static readonly NEVER: number;
  26920. /** 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 */
  26921. static readonly ALWAYS: number;
  26922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26923. static readonly LESS: number;
  26924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26925. static readonly EQUAL: number;
  26926. /** 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 */
  26927. static readonly LEQUAL: number;
  26928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26929. static readonly GREATER: number;
  26930. /** 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 */
  26931. static readonly GEQUAL: number;
  26932. /** 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 */
  26933. static readonly NOTEQUAL: number;
  26934. /** Passed to stencilOperation to specify that stencil value must be kept */
  26935. static readonly KEEP: number;
  26936. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26937. static readonly REPLACE: number;
  26938. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26939. static readonly INCR: number;
  26940. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26941. static readonly DECR: number;
  26942. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26943. static readonly INVERT: number;
  26944. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26945. static readonly INCR_WRAP: number;
  26946. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26947. static readonly DECR_WRAP: number;
  26948. /** Texture is not repeating outside of 0..1 UVs */
  26949. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26950. /** Texture is repeating outside of 0..1 UVs */
  26951. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26952. /** Texture is repeating and mirrored */
  26953. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26954. /** ALPHA */
  26955. static readonly TEXTUREFORMAT_ALPHA: number;
  26956. /** LUMINANCE */
  26957. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26958. /** LUMINANCE_ALPHA */
  26959. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26960. /** RGB */
  26961. static readonly TEXTUREFORMAT_RGB: number;
  26962. /** RGBA */
  26963. static readonly TEXTUREFORMAT_RGBA: number;
  26964. /** RED */
  26965. static readonly TEXTUREFORMAT_RED: number;
  26966. /** RED (2nd reference) */
  26967. static readonly TEXTUREFORMAT_R: number;
  26968. /** RG */
  26969. static readonly TEXTUREFORMAT_RG: number;
  26970. /** RED_INTEGER */
  26971. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26972. /** RED_INTEGER (2nd reference) */
  26973. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26974. /** RG_INTEGER */
  26975. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26976. /** RGB_INTEGER */
  26977. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26978. /** RGBA_INTEGER */
  26979. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26980. /** UNSIGNED_BYTE */
  26981. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26982. /** UNSIGNED_BYTE (2nd reference) */
  26983. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26984. /** FLOAT */
  26985. static readonly TEXTURETYPE_FLOAT: number;
  26986. /** HALF_FLOAT */
  26987. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26988. /** BYTE */
  26989. static readonly TEXTURETYPE_BYTE: number;
  26990. /** SHORT */
  26991. static readonly TEXTURETYPE_SHORT: number;
  26992. /** UNSIGNED_SHORT */
  26993. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26994. /** INT */
  26995. static readonly TEXTURETYPE_INT: number;
  26996. /** UNSIGNED_INT */
  26997. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26998. /** UNSIGNED_SHORT_4_4_4_4 */
  26999. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27000. /** UNSIGNED_SHORT_5_5_5_1 */
  27001. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27002. /** UNSIGNED_SHORT_5_6_5 */
  27003. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27004. /** UNSIGNED_INT_2_10_10_10_REV */
  27005. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27006. /** UNSIGNED_INT_24_8 */
  27007. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27008. /** UNSIGNED_INT_10F_11F_11F_REV */
  27009. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27010. /** UNSIGNED_INT_5_9_9_9_REV */
  27011. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27012. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27013. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27014. /** nearest is mag = nearest and min = nearest and mip = linear */
  27015. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27016. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27017. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27018. /** Trilinear is mag = linear and min = linear and mip = linear */
  27019. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27020. /** nearest is mag = nearest and min = nearest and mip = linear */
  27021. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27023. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27024. /** Trilinear is mag = linear and min = linear and mip = linear */
  27025. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27026. /** mag = nearest and min = nearest and mip = nearest */
  27027. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27028. /** mag = nearest and min = linear and mip = nearest */
  27029. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27030. /** mag = nearest and min = linear and mip = linear */
  27031. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27032. /** mag = nearest and min = linear and mip = none */
  27033. static readonly TEXTURE_NEAREST_LINEAR: number;
  27034. /** mag = nearest and min = nearest and mip = none */
  27035. static readonly TEXTURE_NEAREST_NEAREST: number;
  27036. /** mag = linear and min = nearest and mip = nearest */
  27037. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27038. /** mag = linear and min = nearest and mip = linear */
  27039. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27040. /** mag = linear and min = linear and mip = none */
  27041. static readonly TEXTURE_LINEAR_LINEAR: number;
  27042. /** mag = linear and min = nearest and mip = none */
  27043. static readonly TEXTURE_LINEAR_NEAREST: number;
  27044. /** Explicit coordinates mode */
  27045. static readonly TEXTURE_EXPLICIT_MODE: number;
  27046. /** Spherical coordinates mode */
  27047. static readonly TEXTURE_SPHERICAL_MODE: number;
  27048. /** Planar coordinates mode */
  27049. static readonly TEXTURE_PLANAR_MODE: number;
  27050. /** Cubic coordinates mode */
  27051. static readonly TEXTURE_CUBIC_MODE: number;
  27052. /** Projection coordinates mode */
  27053. static readonly TEXTURE_PROJECTION_MODE: number;
  27054. /** Skybox coordinates mode */
  27055. static readonly TEXTURE_SKYBOX_MODE: number;
  27056. /** Inverse Cubic coordinates mode */
  27057. static readonly TEXTURE_INVCUBIC_MODE: number;
  27058. /** Equirectangular coordinates mode */
  27059. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27060. /** Equirectangular Fixed coordinates mode */
  27061. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27062. /** Equirectangular Fixed Mirrored coordinates mode */
  27063. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27064. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27065. static readonly SCALEMODE_FLOOR: number;
  27066. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27067. static readonly SCALEMODE_NEAREST: number;
  27068. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27069. static readonly SCALEMODE_CEILING: number;
  27070. /**
  27071. * Returns the current version of the framework
  27072. */
  27073. static readonly Version: string;
  27074. /**
  27075. * Returns a string describing the current engine
  27076. */
  27077. readonly description: string;
  27078. /**
  27079. * Gets or sets the epsilon value used by collision engine
  27080. */
  27081. static CollisionsEpsilon: number;
  27082. /**
  27083. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27084. */
  27085. static ShadersRepository: string;
  27086. /**
  27087. * Method called to create the default loading screen.
  27088. * This can be overriden in your own app.
  27089. * @param canvas The rendering canvas element
  27090. * @returns The loading screen
  27091. */
  27092. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27093. /**
  27094. * Method called to create the default rescale post process on each engine.
  27095. */
  27096. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27097. /**
  27098. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27099. */
  27100. forcePOTTextures: boolean;
  27101. /**
  27102. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27103. */
  27104. isFullscreen: boolean;
  27105. /**
  27106. * Gets a boolean indicating if the pointer is currently locked
  27107. */
  27108. isPointerLock: boolean;
  27109. /**
  27110. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27111. */
  27112. cullBackFaces: boolean;
  27113. /**
  27114. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27115. */
  27116. renderEvenInBackground: boolean;
  27117. /**
  27118. * Gets or sets a boolean indicating that cache can be kept between frames
  27119. */
  27120. preventCacheWipeBetweenFrames: boolean;
  27121. /**
  27122. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27123. **/
  27124. enableOfflineSupport: boolean;
  27125. /**
  27126. * 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)
  27127. **/
  27128. disableManifestCheck: boolean;
  27129. /**
  27130. * Gets the list of created scenes
  27131. */
  27132. scenes: Scene[];
  27133. /**
  27134. * Event raised when a new scene is created
  27135. */
  27136. onNewSceneAddedObservable: Observable<Scene>;
  27137. /**
  27138. * Gets the list of created postprocesses
  27139. */
  27140. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27141. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27142. validateShaderPrograms: boolean;
  27143. /**
  27144. * Observable event triggered each time the rendering canvas is resized
  27145. */
  27146. onResizeObservable: Observable<Engine>;
  27147. /**
  27148. * Observable event triggered each time the canvas loses focus
  27149. */
  27150. onCanvasBlurObservable: Observable<Engine>;
  27151. /**
  27152. * Observable event triggered each time the canvas gains focus
  27153. */
  27154. onCanvasFocusObservable: Observable<Engine>;
  27155. /**
  27156. * Observable event triggered each time the canvas receives pointerout event
  27157. */
  27158. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27159. /**
  27160. * Observable event triggered before each texture is initialized
  27161. */
  27162. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27163. private _vrDisplay;
  27164. private _vrSupported;
  27165. private _oldSize;
  27166. private _oldHardwareScaleFactor;
  27167. private _vrExclusivePointerMode;
  27168. private _webVRInitPromise;
  27169. /**
  27170. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27171. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27172. */
  27173. readonly isInVRExclusivePointerMode: boolean;
  27174. /**
  27175. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27176. */
  27177. disableUniformBuffers: boolean;
  27178. /** @hidden */
  27179. _uniformBuffers: UniformBuffer[];
  27180. /**
  27181. * Gets a boolean indicating that the engine supports uniform buffers
  27182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27183. */
  27184. readonly supportsUniformBuffers: boolean;
  27185. /**
  27186. * Observable raised when the engine begins a new frame
  27187. */
  27188. onBeginFrameObservable: Observable<Engine>;
  27189. /**
  27190. * If set, will be used to request the next animation frame for the render loop
  27191. */
  27192. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27193. /**
  27194. * Observable raised when the engine ends the current frame
  27195. */
  27196. onEndFrameObservable: Observable<Engine>;
  27197. /**
  27198. * Observable raised when the engine is about to compile a shader
  27199. */
  27200. onBeforeShaderCompilationObservable: Observable<Engine>;
  27201. /**
  27202. * Observable raised when the engine has jsut compiled a shader
  27203. */
  27204. onAfterShaderCompilationObservable: Observable<Engine>;
  27205. /** @hidden */
  27206. _gl: WebGLRenderingContext;
  27207. private _renderingCanvas;
  27208. private _windowIsBackground;
  27209. private _webGLVersion;
  27210. /**
  27211. * Gets a boolean indicating that only power of 2 textures are supported
  27212. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27213. */
  27214. readonly needPOTTextures: boolean;
  27215. /** @hidden */
  27216. _badOS: boolean;
  27217. /** @hidden */
  27218. _badDesktopOS: boolean;
  27219. /**
  27220. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27221. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27222. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27223. */
  27224. disableTextureBindingOptimization: boolean;
  27225. /**
  27226. * Gets the audio engine
  27227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27228. * @ignorenaming
  27229. */
  27230. static audioEngine: IAudioEngine;
  27231. /**
  27232. * Default AudioEngine factory responsible of creating the Audio Engine.
  27233. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27234. */
  27235. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27236. /**
  27237. * Default offline support factory responsible of creating a tool used to store data locally.
  27238. * By default, this will create a Database object if the workload has been embedded.
  27239. */
  27240. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27241. private _onFocus;
  27242. private _onBlur;
  27243. private _onCanvasPointerOut;
  27244. private _onCanvasBlur;
  27245. private _onCanvasFocus;
  27246. private _onFullscreenChange;
  27247. private _onPointerLockChange;
  27248. private _onVRDisplayPointerRestricted;
  27249. private _onVRDisplayPointerUnrestricted;
  27250. private _onVrDisplayConnect;
  27251. private _onVrDisplayDisconnect;
  27252. private _onVrDisplayPresentChange;
  27253. /**
  27254. * Observable signaled when VR display mode changes
  27255. */
  27256. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27257. /**
  27258. * Observable signaled when VR request present is complete
  27259. */
  27260. onVRRequestPresentComplete: Observable<boolean>;
  27261. /**
  27262. * Observable signaled when VR request present starts
  27263. */
  27264. onVRRequestPresentStart: Observable<Engine>;
  27265. private _hardwareScalingLevel;
  27266. /** @hidden */
  27267. protected _caps: EngineCapabilities;
  27268. private _pointerLockRequested;
  27269. private _isStencilEnable;
  27270. private _colorWrite;
  27271. private _loadingScreen;
  27272. /** @hidden */
  27273. _drawCalls: PerfCounter;
  27274. /** @hidden */
  27275. _textureCollisions: PerfCounter;
  27276. private _glVersion;
  27277. private _glRenderer;
  27278. private _glVendor;
  27279. private _videoTextureSupported;
  27280. private _renderingQueueLaunched;
  27281. private _activeRenderLoops;
  27282. private _deterministicLockstep;
  27283. private _lockstepMaxSteps;
  27284. /**
  27285. * Observable signaled when a context lost event is raised
  27286. */
  27287. onContextLostObservable: Observable<Engine>;
  27288. /**
  27289. * Observable signaled when a context restored event is raised
  27290. */
  27291. onContextRestoredObservable: Observable<Engine>;
  27292. private _onContextLost;
  27293. private _onContextRestored;
  27294. private _contextWasLost;
  27295. private _doNotHandleContextLost;
  27296. /**
  27297. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27299. */
  27300. doNotHandleContextLost: boolean;
  27301. private _performanceMonitor;
  27302. private _fps;
  27303. private _deltaTime;
  27304. /**
  27305. * Turn this value on if you want to pause FPS computation when in background
  27306. */
  27307. disablePerformanceMonitorInBackground: boolean;
  27308. /**
  27309. * Gets the performance monitor attached to this engine
  27310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27311. */
  27312. readonly performanceMonitor: PerformanceMonitor;
  27313. /** @hidden */
  27314. protected _depthCullingState: _DepthCullingState;
  27315. /** @hidden */
  27316. protected _stencilState: _StencilState;
  27317. /** @hidden */
  27318. protected _alphaState: _AlphaState;
  27319. /** @hidden */
  27320. protected _alphaMode: number;
  27321. protected _internalTexturesCache: InternalTexture[];
  27322. /** @hidden */
  27323. protected _activeChannel: number;
  27324. private _currentTextureChannel;
  27325. /** @hidden */
  27326. protected _boundTexturesCache: {
  27327. [key: string]: Nullable<InternalTexture>;
  27328. };
  27329. /** @hidden */
  27330. protected _currentEffect: Nullable<Effect>;
  27331. /** @hidden */
  27332. protected _currentProgram: Nullable<WebGLProgram>;
  27333. private _compiledEffects;
  27334. private _vertexAttribArraysEnabled;
  27335. /** @hidden */
  27336. protected _cachedViewport: Nullable<Viewport>;
  27337. private _cachedVertexArrayObject;
  27338. /** @hidden */
  27339. protected _cachedVertexBuffers: any;
  27340. /** @hidden */
  27341. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27342. /** @hidden */
  27343. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27344. /** @hidden */
  27345. protected _currentRenderTarget: Nullable<InternalTexture>;
  27346. private _uintIndicesCurrentlySet;
  27347. private _currentBoundBuffer;
  27348. /** @hidden */
  27349. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27350. private _currentBufferPointers;
  27351. private _currentInstanceLocations;
  27352. private _currentInstanceBuffers;
  27353. private _textureUnits;
  27354. private _firstBoundInternalTextureTracker;
  27355. private _lastBoundInternalTextureTracker;
  27356. private _workingCanvas;
  27357. private _workingContext;
  27358. private _rescalePostProcess;
  27359. private _dummyFramebuffer;
  27360. private _externalData;
  27361. private _bindedRenderFunction;
  27362. private _vaoRecordInProgress;
  27363. private _mustWipeVertexAttributes;
  27364. private _emptyTexture;
  27365. private _emptyCubeTexture;
  27366. private _emptyTexture3D;
  27367. /** @hidden */
  27368. _frameHandler: number;
  27369. private _nextFreeTextureSlots;
  27370. private _maxSimultaneousTextures;
  27371. private _activeRequests;
  27372. private _texturesSupported;
  27373. private _textureFormatInUse;
  27374. /**
  27375. * Gets the list of texture formats supported
  27376. */
  27377. readonly texturesSupported: Array<string>;
  27378. /**
  27379. * Gets the list of texture formats in use
  27380. */
  27381. readonly textureFormatInUse: Nullable<string>;
  27382. /**
  27383. * Gets the current viewport
  27384. */
  27385. readonly currentViewport: Nullable<Viewport>;
  27386. /**
  27387. * Gets the default empty texture
  27388. */
  27389. readonly emptyTexture: InternalTexture;
  27390. /**
  27391. * Gets the default empty 3D texture
  27392. */
  27393. readonly emptyTexture3D: InternalTexture;
  27394. /**
  27395. * Gets the default empty cube texture
  27396. */
  27397. readonly emptyCubeTexture: InternalTexture;
  27398. /**
  27399. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27400. */
  27401. readonly premultipliedAlpha: boolean;
  27402. /**
  27403. * Creates a new engine
  27404. * @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
  27405. * @param antialias defines enable antialiasing (default: false)
  27406. * @param options defines further options to be sent to the getContext() function
  27407. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27408. */
  27409. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27410. private _disableTouchAction;
  27411. private _rebuildInternalTextures;
  27412. private _rebuildEffects;
  27413. /**
  27414. * Gets a boolean indicating if all created effects are ready
  27415. * @returns true if all effects are ready
  27416. */
  27417. areAllEffectsReady(): boolean;
  27418. private _rebuildBuffers;
  27419. private _initGLContext;
  27420. /**
  27421. * Gets version of the current webGL context
  27422. */
  27423. readonly webGLVersion: number;
  27424. /**
  27425. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27426. */
  27427. readonly isStencilEnable: boolean;
  27428. private _prepareWorkingCanvas;
  27429. /**
  27430. * Reset the texture cache to empty state
  27431. */
  27432. resetTextureCache(): void;
  27433. /**
  27434. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27436. * @returns true if engine is in deterministic lock step mode
  27437. */
  27438. isDeterministicLockStep(): boolean;
  27439. /**
  27440. * Gets the max steps when engine is running in deterministic lock step
  27441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27442. * @returns the max steps
  27443. */
  27444. getLockstepMaxSteps(): number;
  27445. /**
  27446. * Gets an object containing information about the current webGL context
  27447. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27448. */
  27449. getGlInfo(): {
  27450. vendor: string;
  27451. renderer: string;
  27452. version: string;
  27453. };
  27454. /**
  27455. * Gets current aspect ratio
  27456. * @param camera defines the camera to use to get the aspect ratio
  27457. * @param useScreen defines if screen size must be used (or the current render target if any)
  27458. * @returns a number defining the aspect ratio
  27459. */
  27460. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27461. /**
  27462. * Gets current screen aspect ratio
  27463. * @returns a number defining the aspect ratio
  27464. */
  27465. getScreenAspectRatio(): number;
  27466. /**
  27467. * Gets the current render width
  27468. * @param useScreen defines if screen size must be used (or the current render target if any)
  27469. * @returns a number defining the current render width
  27470. */
  27471. getRenderWidth(useScreen?: boolean): number;
  27472. /**
  27473. * Gets the current render height
  27474. * @param useScreen defines if screen size must be used (or the current render target if any)
  27475. * @returns a number defining the current render height
  27476. */
  27477. getRenderHeight(useScreen?: boolean): number;
  27478. /**
  27479. * Gets the HTML canvas attached with the current webGL context
  27480. * @returns a HTML canvas
  27481. */
  27482. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27483. /**
  27484. * Gets the client rect of the HTML canvas attached with the current webGL context
  27485. * @returns a client rectanglee
  27486. */
  27487. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27488. /**
  27489. * Defines the hardware scaling level.
  27490. * By default the hardware scaling level is computed from the window device ratio.
  27491. * 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.
  27492. * @param level defines the level to use
  27493. */
  27494. setHardwareScalingLevel(level: number): void;
  27495. /**
  27496. * Gets the current hardware scaling level.
  27497. * By default the hardware scaling level is computed from the window device ratio.
  27498. * 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.
  27499. * @returns a number indicating the current hardware scaling level
  27500. */
  27501. getHardwareScalingLevel(): number;
  27502. /**
  27503. * Gets the list of loaded textures
  27504. * @returns an array containing all loaded textures
  27505. */
  27506. getLoadedTexturesCache(): InternalTexture[];
  27507. /**
  27508. * Gets the object containing all engine capabilities
  27509. * @returns the EngineCapabilities object
  27510. */
  27511. getCaps(): EngineCapabilities;
  27512. /**
  27513. * Gets the current depth function
  27514. * @returns a number defining the depth function
  27515. */
  27516. getDepthFunction(): Nullable<number>;
  27517. /**
  27518. * Sets the current depth function
  27519. * @param depthFunc defines the function to use
  27520. */
  27521. setDepthFunction(depthFunc: number): void;
  27522. /**
  27523. * Sets the current depth function to GREATER
  27524. */
  27525. setDepthFunctionToGreater(): void;
  27526. /**
  27527. * Sets the current depth function to GEQUAL
  27528. */
  27529. setDepthFunctionToGreaterOrEqual(): void;
  27530. /**
  27531. * Sets the current depth function to LESS
  27532. */
  27533. setDepthFunctionToLess(): void;
  27534. /**
  27535. * Sets the current depth function to LEQUAL
  27536. */
  27537. setDepthFunctionToLessOrEqual(): void;
  27538. /**
  27539. * Gets a boolean indicating if stencil buffer is enabled
  27540. * @returns the current stencil buffer state
  27541. */
  27542. getStencilBuffer(): boolean;
  27543. /**
  27544. * Enable or disable the stencil buffer
  27545. * @param enable defines if the stencil buffer must be enabled or disabled
  27546. */
  27547. setStencilBuffer(enable: boolean): void;
  27548. /**
  27549. * Gets the current stencil mask
  27550. * @returns a number defining the new stencil mask to use
  27551. */
  27552. getStencilMask(): number;
  27553. /**
  27554. * Sets the current stencil mask
  27555. * @param mask defines the new stencil mask to use
  27556. */
  27557. setStencilMask(mask: number): void;
  27558. /**
  27559. * Gets the current stencil function
  27560. * @returns a number defining the stencil function to use
  27561. */
  27562. getStencilFunction(): number;
  27563. /**
  27564. * Gets the current stencil reference value
  27565. * @returns a number defining the stencil reference value to use
  27566. */
  27567. getStencilFunctionReference(): number;
  27568. /**
  27569. * Gets the current stencil mask
  27570. * @returns a number defining the stencil mask to use
  27571. */
  27572. getStencilFunctionMask(): number;
  27573. /**
  27574. * Sets the current stencil function
  27575. * @param stencilFunc defines the new stencil function to use
  27576. */
  27577. setStencilFunction(stencilFunc: number): void;
  27578. /**
  27579. * Sets the current stencil reference
  27580. * @param reference defines the new stencil reference to use
  27581. */
  27582. setStencilFunctionReference(reference: number): void;
  27583. /**
  27584. * Sets the current stencil mask
  27585. * @param mask defines the new stencil mask to use
  27586. */
  27587. setStencilFunctionMask(mask: number): void;
  27588. /**
  27589. * Gets the current stencil operation when stencil fails
  27590. * @returns a number defining stencil operation to use when stencil fails
  27591. */
  27592. getStencilOperationFail(): number;
  27593. /**
  27594. * Gets the current stencil operation when depth fails
  27595. * @returns a number defining stencil operation to use when depth fails
  27596. */
  27597. getStencilOperationDepthFail(): number;
  27598. /**
  27599. * Gets the current stencil operation when stencil passes
  27600. * @returns a number defining stencil operation to use when stencil passes
  27601. */
  27602. getStencilOperationPass(): number;
  27603. /**
  27604. * Sets the stencil operation to use when stencil fails
  27605. * @param operation defines the stencil operation to use when stencil fails
  27606. */
  27607. setStencilOperationFail(operation: number): void;
  27608. /**
  27609. * Sets the stencil operation to use when depth fails
  27610. * @param operation defines the stencil operation to use when depth fails
  27611. */
  27612. setStencilOperationDepthFail(operation: number): void;
  27613. /**
  27614. * Sets the stencil operation to use when stencil passes
  27615. * @param operation defines the stencil operation to use when stencil passes
  27616. */
  27617. setStencilOperationPass(operation: number): void;
  27618. /**
  27619. * Sets a boolean indicating if the dithering state is enabled or disabled
  27620. * @param value defines the dithering state
  27621. */
  27622. setDitheringState(value: boolean): void;
  27623. /**
  27624. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27625. * @param value defines the rasterizer state
  27626. */
  27627. setRasterizerState(value: boolean): void;
  27628. /**
  27629. * stop executing a render loop function and remove it from the execution array
  27630. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27631. */
  27632. stopRenderLoop(renderFunction?: () => void): void;
  27633. /** @hidden */
  27634. _renderLoop(): void;
  27635. /**
  27636. * Register and execute a render loop. The engine can have more than one render function
  27637. * @param renderFunction defines the function to continuously execute
  27638. */
  27639. runRenderLoop(renderFunction: () => void): void;
  27640. /**
  27641. * Toggle full screen mode
  27642. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27643. */
  27644. switchFullscreen(requestPointerLock: boolean): void;
  27645. /**
  27646. * Enters full screen mode
  27647. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27648. */
  27649. enterFullscreen(requestPointerLock: boolean): void;
  27650. /**
  27651. * Exits full screen mode
  27652. */
  27653. exitFullscreen(): void;
  27654. /**
  27655. * Clear the current render buffer or the current render target (if any is set up)
  27656. * @param color defines the color to use
  27657. * @param backBuffer defines if the back buffer must be cleared
  27658. * @param depth defines if the depth buffer must be cleared
  27659. * @param stencil defines if the stencil buffer must be cleared
  27660. */
  27661. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27662. /**
  27663. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27664. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27665. * @param y defines the y-coordinate of the corner of the clear rectangle
  27666. * @param width defines the width of the clear rectangle
  27667. * @param height defines the height of the clear rectangle
  27668. * @param clearColor defines the clear color
  27669. */
  27670. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27671. /**
  27672. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27673. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27674. * @param y defines the y-coordinate of the corner of the clear rectangle
  27675. * @param width defines the width of the clear rectangle
  27676. * @param height defines the height of the clear rectangle
  27677. */
  27678. enableScissor(x: number, y: number, width: number, height: number): void;
  27679. /**
  27680. * Disable previously set scissor test rectangle
  27681. */
  27682. disableScissor(): void;
  27683. private _viewportCached;
  27684. /** @hidden */
  27685. _viewport(x: number, y: number, width: number, height: number): void;
  27686. /**
  27687. * Set the WebGL's viewport
  27688. * @param viewport defines the viewport element to be used
  27689. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27690. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27691. */
  27692. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27693. /**
  27694. * Directly set the WebGL Viewport
  27695. * @param x defines the x coordinate of the viewport (in screen space)
  27696. * @param y defines the y coordinate of the viewport (in screen space)
  27697. * @param width defines the width of the viewport (in screen space)
  27698. * @param height defines the height of the viewport (in screen space)
  27699. * @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
  27700. */
  27701. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27702. /**
  27703. * Begin a new frame
  27704. */
  27705. beginFrame(): void;
  27706. /**
  27707. * Enf the current frame
  27708. */
  27709. endFrame(): void;
  27710. /**
  27711. * Resize the view according to the canvas' size
  27712. */
  27713. resize(): void;
  27714. /**
  27715. * Force a specific size of the canvas
  27716. * @param width defines the new canvas' width
  27717. * @param height defines the new canvas' height
  27718. */
  27719. setSize(width: number, height: number): void;
  27720. /**
  27721. * Gets a boolean indicating if a webVR device was detected
  27722. * @returns true if a webVR device was detected
  27723. */
  27724. isVRDevicePresent(): boolean;
  27725. /**
  27726. * Gets the current webVR device
  27727. * @returns the current webVR device (or null)
  27728. */
  27729. getVRDevice(): any;
  27730. /**
  27731. * Initializes a webVR display and starts listening to display change events
  27732. * The onVRDisplayChangedObservable will be notified upon these changes
  27733. * @returns The onVRDisplayChangedObservable
  27734. */
  27735. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27736. /**
  27737. * Initializes a webVR display and starts listening to display change events
  27738. * The onVRDisplayChangedObservable will be notified upon these changes
  27739. * @returns A promise containing a VRDisplay and if vr is supported
  27740. */
  27741. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27742. /**
  27743. * Call this function to switch to webVR mode
  27744. * Will do nothing if webVR is not supported or if there is no webVR device
  27745. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27746. */
  27747. enableVR(): void;
  27748. /**
  27749. * Call this function to leave webVR mode
  27750. * Will do nothing if webVR is not supported or if there is no webVR device
  27751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27752. */
  27753. disableVR(): void;
  27754. private _onVRFullScreenTriggered;
  27755. private _getVRDisplaysAsync;
  27756. /**
  27757. * Binds the frame buffer to the specified texture.
  27758. * @param texture The texture to render to or null for the default canvas
  27759. * @param faceIndex The face of the texture to render to in case of cube texture
  27760. * @param requiredWidth The width of the target to render to
  27761. * @param requiredHeight The height of the target to render to
  27762. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27763. * @param depthStencilTexture The depth stencil texture to use to render
  27764. * @param lodLevel defines le lod level to bind to the frame buffer
  27765. */
  27766. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27767. private bindUnboundFramebuffer;
  27768. /**
  27769. * Unbind the current render target texture from the webGL context
  27770. * @param texture defines the render target texture to unbind
  27771. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27772. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27773. */
  27774. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27775. /**
  27776. * Unbind a list of render target textures from the webGL context
  27777. * This is used only when drawBuffer extension or webGL2 are active
  27778. * @param textures defines the render target textures to unbind
  27779. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27780. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27781. */
  27782. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27783. /**
  27784. * Force the mipmap generation for the given render target texture
  27785. * @param texture defines the render target texture to use
  27786. */
  27787. generateMipMapsForCubemap(texture: InternalTexture): void;
  27788. /**
  27789. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27790. */
  27791. flushFramebuffer(): void;
  27792. /**
  27793. * Unbind the current render target and bind the default framebuffer
  27794. */
  27795. restoreDefaultFramebuffer(): void;
  27796. /**
  27797. * Create an uniform buffer
  27798. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27799. * @param elements defines the content of the uniform buffer
  27800. * @returns the webGL uniform buffer
  27801. */
  27802. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27803. /**
  27804. * Create a dynamic uniform buffer
  27805. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27806. * @param elements defines the content of the uniform buffer
  27807. * @returns the webGL uniform buffer
  27808. */
  27809. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27810. /**
  27811. * Update an existing uniform buffer
  27812. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27813. * @param uniformBuffer defines the target uniform buffer
  27814. * @param elements defines the content to update
  27815. * @param offset defines the offset in the uniform buffer where update should start
  27816. * @param count defines the size of the data to update
  27817. */
  27818. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27819. private _resetVertexBufferBinding;
  27820. /**
  27821. * Creates a vertex buffer
  27822. * @param data the data for the vertex buffer
  27823. * @returns the new WebGL static buffer
  27824. */
  27825. createVertexBuffer(data: DataArray): WebGLBuffer;
  27826. /**
  27827. * Creates a dynamic vertex buffer
  27828. * @param data the data for the dynamic vertex buffer
  27829. * @returns the new WebGL dynamic buffer
  27830. */
  27831. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27832. /**
  27833. * Update a dynamic index buffer
  27834. * @param indexBuffer defines the target index buffer
  27835. * @param indices defines the data to update
  27836. * @param offset defines the offset in the target index buffer where update should start
  27837. */
  27838. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27839. /**
  27840. * Updates a dynamic vertex buffer.
  27841. * @param vertexBuffer the vertex buffer to update
  27842. * @param data the data used to update the vertex buffer
  27843. * @param byteOffset the byte offset of the data
  27844. * @param byteLength the byte length of the data
  27845. */
  27846. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27847. private _resetIndexBufferBinding;
  27848. /**
  27849. * Creates a new index buffer
  27850. * @param indices defines the content of the index buffer
  27851. * @param updatable defines if the index buffer must be updatable
  27852. * @returns a new webGL buffer
  27853. */
  27854. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27855. /**
  27856. * Bind a webGL buffer to the webGL context
  27857. * @param buffer defines the buffer to bind
  27858. */
  27859. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27860. /**
  27861. * Bind an uniform buffer to the current webGL context
  27862. * @param buffer defines the buffer to bind
  27863. */
  27864. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27865. /**
  27866. * Bind a buffer to the current webGL context at a given location
  27867. * @param buffer defines the buffer to bind
  27868. * @param location defines the index where to bind the buffer
  27869. */
  27870. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27871. /**
  27872. * Bind a specific block at a given index in a specific shader program
  27873. * @param shaderProgram defines the shader program
  27874. * @param blockName defines the block name
  27875. * @param index defines the index where to bind the block
  27876. */
  27877. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27878. private bindIndexBuffer;
  27879. private bindBuffer;
  27880. /**
  27881. * update the bound buffer with the given data
  27882. * @param data defines the data to update
  27883. */
  27884. updateArrayBuffer(data: Float32Array): void;
  27885. private _vertexAttribPointer;
  27886. private _bindIndexBufferWithCache;
  27887. private _bindVertexBuffersAttributes;
  27888. /**
  27889. * Records a vertex array object
  27890. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27891. * @param vertexBuffers defines the list of vertex buffers to store
  27892. * @param indexBuffer defines the index buffer to store
  27893. * @param effect defines the effect to store
  27894. * @returns the new vertex array object
  27895. */
  27896. recordVertexArrayObject(vertexBuffers: {
  27897. [key: string]: VertexBuffer;
  27898. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27899. /**
  27900. * Bind a specific vertex array object
  27901. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27902. * @param vertexArrayObject defines the vertex array object to bind
  27903. * @param indexBuffer defines the index buffer to bind
  27904. */
  27905. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27906. /**
  27907. * Bind webGl buffers directly to the webGL context
  27908. * @param vertexBuffer defines the vertex buffer to bind
  27909. * @param indexBuffer defines the index buffer to bind
  27910. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27911. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27912. * @param effect defines the effect associated with the vertex buffer
  27913. */
  27914. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27915. private _unbindVertexArrayObject;
  27916. /**
  27917. * Bind a list of vertex buffers to the webGL context
  27918. * @param vertexBuffers defines the list of vertex buffers to bind
  27919. * @param indexBuffer defines the index buffer to bind
  27920. * @param effect defines the effect associated with the vertex buffers
  27921. */
  27922. bindBuffers(vertexBuffers: {
  27923. [key: string]: Nullable<VertexBuffer>;
  27924. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27925. /**
  27926. * Unbind all instance attributes
  27927. */
  27928. unbindInstanceAttributes(): void;
  27929. /**
  27930. * Release and free the memory of a vertex array object
  27931. * @param vao defines the vertex array object to delete
  27932. */
  27933. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27934. /** @hidden */
  27935. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27936. /**
  27937. * Creates a webGL buffer to use with instanciation
  27938. * @param capacity defines the size of the buffer
  27939. * @returns the webGL buffer
  27940. */
  27941. createInstancesBuffer(capacity: number): WebGLBuffer;
  27942. /**
  27943. * Delete a webGL buffer used with instanciation
  27944. * @param buffer defines the webGL buffer to delete
  27945. */
  27946. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27947. /**
  27948. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27949. * @param instancesBuffer defines the webGL buffer to update and bind
  27950. * @param data defines the data to store in the buffer
  27951. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27952. */
  27953. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27954. /**
  27955. * Apply all cached states (depth, culling, stencil and alpha)
  27956. */
  27957. applyStates(): void;
  27958. /**
  27959. * Send a draw order
  27960. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27961. * @param indexStart defines the starting index
  27962. * @param indexCount defines the number of index to draw
  27963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27964. */
  27965. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27966. /**
  27967. * Draw a list of points
  27968. * @param verticesStart defines the index of first vertex to draw
  27969. * @param verticesCount defines the count of vertices to draw
  27970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27971. */
  27972. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27973. /**
  27974. * Draw a list of unindexed primitives
  27975. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27976. * @param verticesStart defines the index of first vertex to draw
  27977. * @param verticesCount defines the count of vertices to draw
  27978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27979. */
  27980. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27981. /**
  27982. * Draw a list of indexed primitives
  27983. * @param fillMode defines the primitive to use
  27984. * @param indexStart defines the starting index
  27985. * @param indexCount defines the number of index to draw
  27986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27987. */
  27988. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27989. /**
  27990. * Draw a list of unindexed primitives
  27991. * @param fillMode defines the primitive to use
  27992. * @param verticesStart defines the index of first vertex to draw
  27993. * @param verticesCount defines the count of vertices to draw
  27994. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27995. */
  27996. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27997. private _drawMode;
  27998. /** @hidden */
  27999. _releaseEffect(effect: Effect): void;
  28000. /** @hidden */
  28001. _deleteProgram(program: WebGLProgram): void;
  28002. /**
  28003. * Create a new effect (used to store vertex/fragment shaders)
  28004. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28005. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28006. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28007. * @param samplers defines an array of string used to represent textures
  28008. * @param defines defines the string containing the defines to use to compile the shaders
  28009. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28010. * @param onCompiled defines a function to call when the effect creation is successful
  28011. * @param onError defines a function to call when the effect creation has failed
  28012. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28013. * @returns the new Effect
  28014. */
  28015. 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;
  28016. private _compileShader;
  28017. private _compileRawShader;
  28018. /**
  28019. * Directly creates a webGL program
  28020. * @param vertexCode defines the vertex shader code to use
  28021. * @param fragmentCode defines the fragment shader code to use
  28022. * @param context defines the webGL context to use (if not set, the current one will be used)
  28023. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28024. * @returns the new webGL program
  28025. */
  28026. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28027. /**
  28028. * Creates a webGL program
  28029. * @param vertexCode defines the vertex shader code to use
  28030. * @param fragmentCode defines the fragment shader code to use
  28031. * @param defines defines the string containing the defines to use to compile the shaders
  28032. * @param context defines the webGL context to use (if not set, the current one will be used)
  28033. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28034. * @returns the new webGL program
  28035. */
  28036. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28037. private _createShaderProgram;
  28038. private _finalizeProgram;
  28039. /** @hidden */
  28040. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28041. /** @hidden */
  28042. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28043. /**
  28044. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28045. * @param shaderProgram defines the webGL program to use
  28046. * @param uniformsNames defines the list of uniform names
  28047. * @returns an array of webGL uniform locations
  28048. */
  28049. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28050. /**
  28051. * Gets the lsit of active attributes for a given webGL program
  28052. * @param shaderProgram defines the webGL program to use
  28053. * @param attributesNames defines the list of attribute names to get
  28054. * @returns an array of indices indicating the offset of each attribute
  28055. */
  28056. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28057. /**
  28058. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28059. * @param effect defines the effect to activate
  28060. */
  28061. enableEffect(effect: Nullable<Effect>): void;
  28062. /**
  28063. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28068. /**
  28069. * Set the value of an uniform to an array of int32 (stored as vec2)
  28070. * @param uniform defines the webGL uniform location where to store the value
  28071. * @param array defines the array of int32 to store
  28072. */
  28073. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28074. /**
  28075. * Set the value of an uniform to an array of int32 (stored as vec3)
  28076. * @param uniform defines the webGL uniform location where to store the value
  28077. * @param array defines the array of int32 to store
  28078. */
  28079. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28080. /**
  28081. * Set the value of an uniform to an array of int32 (stored as vec4)
  28082. * @param uniform defines the webGL uniform location where to store the value
  28083. * @param array defines the array of int32 to store
  28084. */
  28085. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28086. /**
  28087. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28092. /**
  28093. * Set the value of an uniform to an array of float32 (stored as vec2)
  28094. * @param uniform defines the webGL uniform location where to store the value
  28095. * @param array defines the array of float32 to store
  28096. */
  28097. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28098. /**
  28099. * Set the value of an uniform to an array of float32 (stored as vec3)
  28100. * @param uniform defines the webGL uniform location where to store the value
  28101. * @param array defines the array of float32 to store
  28102. */
  28103. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28104. /**
  28105. * Set the value of an uniform to an array of float32 (stored as vec4)
  28106. * @param uniform defines the webGL uniform location where to store the value
  28107. * @param array defines the array of float32 to store
  28108. */
  28109. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28110. /**
  28111. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28116. /**
  28117. * Set the value of an uniform to an array of number (stored as vec2)
  28118. * @param uniform defines the webGL uniform location where to store the value
  28119. * @param array defines the array of number to store
  28120. */
  28121. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28122. /**
  28123. * Set the value of an uniform to an array of number (stored as vec3)
  28124. * @param uniform defines the webGL uniform location where to store the value
  28125. * @param array defines the array of number to store
  28126. */
  28127. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28128. /**
  28129. * Set the value of an uniform to an array of number (stored as vec4)
  28130. * @param uniform defines the webGL uniform location where to store the value
  28131. * @param array defines the array of number to store
  28132. */
  28133. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28134. /**
  28135. * Set the value of an uniform to an array of float32 (stored as matrices)
  28136. * @param uniform defines the webGL uniform location where to store the value
  28137. * @param matrices defines the array of float32 to store
  28138. */
  28139. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28140. /**
  28141. * Set the value of an uniform to a matrix
  28142. * @param uniform defines the webGL uniform location where to store the value
  28143. * @param matrix defines the matrix to store
  28144. */
  28145. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28146. /**
  28147. * Set the value of an uniform to a matrix (3x3)
  28148. * @param uniform defines the webGL uniform location where to store the value
  28149. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28150. */
  28151. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28152. /**
  28153. * Set the value of an uniform to a matrix (2x2)
  28154. * @param uniform defines the webGL uniform location where to store the value
  28155. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28156. */
  28157. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28158. /**
  28159. * Set the value of an uniform to a number (int)
  28160. * @param uniform defines the webGL uniform location where to store the value
  28161. * @param value defines the int number to store
  28162. */
  28163. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28164. /**
  28165. * Set the value of an uniform to a number (float)
  28166. * @param uniform defines the webGL uniform location where to store the value
  28167. * @param value defines the float number to store
  28168. */
  28169. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28170. /**
  28171. * Set the value of an uniform to a vec2
  28172. * @param uniform defines the webGL uniform location where to store the value
  28173. * @param x defines the 1st component of the value
  28174. * @param y defines the 2nd component of the value
  28175. */
  28176. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28177. /**
  28178. * Set the value of an uniform to a vec3
  28179. * @param uniform defines the webGL uniform location where to store the value
  28180. * @param x defines the 1st component of the value
  28181. * @param y defines the 2nd component of the value
  28182. * @param z defines the 3rd component of the value
  28183. */
  28184. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28185. /**
  28186. * Set the value of an uniform to a boolean
  28187. * @param uniform defines the webGL uniform location where to store the value
  28188. * @param bool defines the boolean to store
  28189. */
  28190. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28191. /**
  28192. * Set the value of an uniform to a vec4
  28193. * @param uniform defines the webGL uniform location where to store the value
  28194. * @param x defines the 1st component of the value
  28195. * @param y defines the 2nd component of the value
  28196. * @param z defines the 3rd component of the value
  28197. * @param w defines the 4th component of the value
  28198. */
  28199. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28200. /**
  28201. * Set the value of an uniform to a Color3
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param color3 defines the color to store
  28204. */
  28205. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28206. /**
  28207. * Set the value of an uniform to a Color3 and an alpha value
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param color3 defines the color to store
  28210. * @param alpha defines the alpha component to store
  28211. */
  28212. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28213. /**
  28214. * Sets a Color4 on a uniform variable
  28215. * @param uniform defines the uniform location
  28216. * @param color4 defines the value to be set
  28217. */
  28218. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28219. /**
  28220. * Set various states to the webGL context
  28221. * @param culling defines backface culling state
  28222. * @param zOffset defines the value to apply to zOffset (0 by default)
  28223. * @param force defines if states must be applied even if cache is up to date
  28224. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28225. */
  28226. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28227. /**
  28228. * Set the z offset to apply to current rendering
  28229. * @param value defines the offset to apply
  28230. */
  28231. setZOffset(value: number): void;
  28232. /**
  28233. * Gets the current value of the zOffset
  28234. * @returns the current zOffset state
  28235. */
  28236. getZOffset(): number;
  28237. /**
  28238. * Enable or disable depth buffering
  28239. * @param enable defines the state to set
  28240. */
  28241. setDepthBuffer(enable: boolean): void;
  28242. /**
  28243. * Gets a boolean indicating if depth writing is enabled
  28244. * @returns the current depth writing state
  28245. */
  28246. getDepthWrite(): boolean;
  28247. /**
  28248. * Enable or disable depth writing
  28249. * @param enable defines the state to set
  28250. */
  28251. setDepthWrite(enable: boolean): void;
  28252. /**
  28253. * Enable or disable color writing
  28254. * @param enable defines the state to set
  28255. */
  28256. setColorWrite(enable: boolean): void;
  28257. /**
  28258. * Gets a boolean indicating if color writing is enabled
  28259. * @returns the current color writing state
  28260. */
  28261. getColorWrite(): boolean;
  28262. /**
  28263. * Sets alpha constants used by some alpha blending modes
  28264. * @param r defines the red component
  28265. * @param g defines the green component
  28266. * @param b defines the blue component
  28267. * @param a defines the alpha component
  28268. */
  28269. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28270. /**
  28271. * Sets the current alpha mode
  28272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28275. */
  28276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28277. /**
  28278. * Gets the current alpha mode
  28279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28280. * @returns the current alpha mode
  28281. */
  28282. getAlphaMode(): number;
  28283. /**
  28284. * Clears the list of texture accessible through engine.
  28285. * This can help preventing texture load conflict due to name collision.
  28286. */
  28287. clearInternalTexturesCache(): void;
  28288. /**
  28289. * Force the entire cache to be cleared
  28290. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28291. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28292. */
  28293. wipeCaches(bruteForce?: boolean): void;
  28294. /**
  28295. * Set the compressed texture format to use, based on the formats you have, and the formats
  28296. * supported by the hardware / browser.
  28297. *
  28298. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28299. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28300. * to API arguments needed to compressed textures. This puts the burden on the container
  28301. * generator to house the arcane code for determining these for current & future formats.
  28302. *
  28303. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28304. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28305. *
  28306. * Note: The result of this call is not taken into account when a texture is base64.
  28307. *
  28308. * @param formatsAvailable defines the list of those format families you have created
  28309. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28310. *
  28311. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28312. * @returns The extension selected.
  28313. */
  28314. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28315. private _getSamplingParameters;
  28316. private _partialLoadImg;
  28317. private _cascadeLoadImgs;
  28318. /** @hidden */
  28319. _createTexture(): WebGLTexture;
  28320. /**
  28321. * Usually called from Texture.ts.
  28322. * Passed information to create a WebGLTexture
  28323. * @param urlArg defines a value which contains one of the following:
  28324. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28325. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28326. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28328. * @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)
  28329. * @param scene needed for loading to the correct scene
  28330. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28331. * @param onLoad optional callback to be called upon successful completion
  28332. * @param onError optional callback to be called upon failure
  28333. * @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
  28334. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28335. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28336. * @param forcedExtension defines the extension to use to pick the right loader
  28337. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28338. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28339. */
  28340. 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;
  28341. private _rescaleTexture;
  28342. /**
  28343. * Update a raw texture
  28344. * @param texture defines the texture to update
  28345. * @param data defines the data to store in the texture
  28346. * @param format defines the format of the data
  28347. * @param invertY defines if data must be stored with Y axis inverted
  28348. * @param compression defines the compression used (null by default)
  28349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28350. */
  28351. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28352. /**
  28353. * Creates a raw texture
  28354. * @param data defines the data to store in the texture
  28355. * @param width defines the width of the texture
  28356. * @param height defines the height of the texture
  28357. * @param format defines the format of the data
  28358. * @param generateMipMaps defines if the engine should generate the mip levels
  28359. * @param invertY defines if data must be stored with Y axis inverted
  28360. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28361. * @param compression defines the compression used (null by default)
  28362. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28363. * @returns the raw texture inside an InternalTexture
  28364. */
  28365. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28366. private _unpackFlipYCached;
  28367. /**
  28368. * In case you are sharing the context with other applications, it might
  28369. * be interested to not cache the unpack flip y state to ensure a consistent
  28370. * value would be set.
  28371. */
  28372. enableUnpackFlipYCached: boolean;
  28373. /** @hidden */
  28374. _unpackFlipY(value: boolean): void;
  28375. /** @hidden */
  28376. _getUnpackAlignement(): number;
  28377. /**
  28378. * Creates a dynamic texture
  28379. * @param width defines the width of the texture
  28380. * @param height defines the height of the texture
  28381. * @param generateMipMaps defines if the engine should generate the mip levels
  28382. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28383. * @returns the dynamic texture inside an InternalTexture
  28384. */
  28385. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28386. /**
  28387. * Update the sampling mode of a given texture
  28388. * @param samplingMode defines the required sampling mode
  28389. * @param texture defines the texture to update
  28390. */
  28391. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28392. /**
  28393. * Update the content of a dynamic texture
  28394. * @param texture defines the texture to update
  28395. * @param canvas defines the canvas containing the source
  28396. * @param invertY defines if data must be stored with Y axis inverted
  28397. * @param premulAlpha defines if alpha is stored as premultiplied
  28398. * @param format defines the format of the data
  28399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28400. */
  28401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28402. /**
  28403. * Update a video texture
  28404. * @param texture defines the texture to update
  28405. * @param video defines the video element to use
  28406. * @param invertY defines if data must be stored with Y axis inverted
  28407. */
  28408. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28409. /**
  28410. * Updates a depth texture Comparison Mode and Function.
  28411. * If the comparison Function is equal to 0, the mode will be set to none.
  28412. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28413. * @param texture The texture to set the comparison function for
  28414. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28415. */
  28416. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28417. private _setupDepthStencilTexture;
  28418. /**
  28419. * Creates a depth stencil texture.
  28420. * This is only available in WebGL 2 or with the depth texture extension available.
  28421. * @param size The size of face edge in the texture.
  28422. * @param options The options defining the texture.
  28423. * @returns The texture
  28424. */
  28425. createDepthStencilTexture(size: number | {
  28426. width: number;
  28427. height: number;
  28428. }, options: DepthTextureCreationOptions): InternalTexture;
  28429. /**
  28430. * Creates a depth stencil texture.
  28431. * This is only available in WebGL 2 or with the depth texture extension available.
  28432. * @param size The size of face edge in the texture.
  28433. * @param options The options defining the texture.
  28434. * @returns The texture
  28435. */
  28436. private _createDepthStencilTexture;
  28437. /**
  28438. * Creates a depth stencil cube texture.
  28439. * This is only available in WebGL 2.
  28440. * @param size The size of face edge in the cube texture.
  28441. * @param options The options defining the cube texture.
  28442. * @returns The cube texture
  28443. */
  28444. private _createDepthStencilCubeTexture;
  28445. /**
  28446. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28447. * @param renderTarget The render target to set the frame buffer for
  28448. */
  28449. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28450. /**
  28451. * Creates a new render target texture
  28452. * @param size defines the size of the texture
  28453. * @param options defines the options used to create the texture
  28454. * @returns a new render target texture stored in an InternalTexture
  28455. */
  28456. createRenderTargetTexture(size: number | {
  28457. width: number;
  28458. height: number;
  28459. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28460. /**
  28461. * Create a multi render target texture
  28462. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28463. * @param size defines the size of the texture
  28464. * @param options defines the creation options
  28465. * @returns the cube texture as an InternalTexture
  28466. */
  28467. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28468. private _setupFramebufferDepthAttachments;
  28469. /**
  28470. * Updates the sample count of a render target texture
  28471. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28472. * @param texture defines the texture to update
  28473. * @param samples defines the sample count to set
  28474. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28475. */
  28476. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28477. /**
  28478. * Update the sample count for a given multiple render target texture
  28479. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28480. * @param textures defines the textures to update
  28481. * @param samples defines the sample count to set
  28482. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28483. */
  28484. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28485. /** @hidden */
  28486. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28487. /** @hidden */
  28488. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28489. /** @hidden */
  28490. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28491. /** @hidden */
  28492. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28493. /**
  28494. * Creates a new render target cube texture
  28495. * @param size defines the size of the texture
  28496. * @param options defines the options used to create the texture
  28497. * @returns a new render target cube texture stored in an InternalTexture
  28498. */
  28499. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28500. /**
  28501. * Creates a cube texture
  28502. * @param rootUrl defines the url where the files to load is located
  28503. * @param scene defines the current scene
  28504. * @param files defines the list of files to load (1 per face)
  28505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28506. * @param onLoad defines an optional callback raised when the texture is loaded
  28507. * @param onError defines an optional callback raised if there is an issue to load the texture
  28508. * @param format defines the format of the data
  28509. * @param forcedExtension defines the extension to use to pick the right loader
  28510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28513. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28514. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28515. * @returns the cube texture as an InternalTexture
  28516. */
  28517. 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;
  28518. /**
  28519. * @hidden
  28520. */
  28521. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28522. /**
  28523. * Update a raw cube texture
  28524. * @param texture defines the texture to udpdate
  28525. * @param data defines the data to store
  28526. * @param format defines the data format
  28527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28528. * @param invertY defines if data must be stored with Y axis inverted
  28529. * @param compression defines the compression used (null by default)
  28530. * @param level defines which level of the texture to update
  28531. */
  28532. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28533. /**
  28534. * Creates a new raw cube texture
  28535. * @param data defines the array of data to use to create each face
  28536. * @param size defines the size of the textures
  28537. * @param format defines the format of the data
  28538. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28539. * @param generateMipMaps defines if the engine should generate the mip levels
  28540. * @param invertY defines if data must be stored with Y axis inverted
  28541. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28542. * @param compression defines the compression used (null by default)
  28543. * @returns the cube texture as an InternalTexture
  28544. */
  28545. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28546. /**
  28547. * Creates a new raw cube texture from a specified url
  28548. * @param url defines the url where the data is located
  28549. * @param scene defines the current scene
  28550. * @param size defines the size of the textures
  28551. * @param format defines the format of the data
  28552. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28553. * @param noMipmap defines if the engine should avoid generating the mip levels
  28554. * @param callback defines a callback used to extract texture data from loaded data
  28555. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28556. * @param onLoad defines a callback called when texture is loaded
  28557. * @param onError defines a callback called if there is an error
  28558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28559. * @param invertY defines if data must be stored with Y axis inverted
  28560. * @returns the cube texture as an InternalTexture
  28561. */
  28562. 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;
  28563. /**
  28564. * Update a raw 3D texture
  28565. * @param texture defines the texture to update
  28566. * @param data defines the data to store
  28567. * @param format defines the data format
  28568. * @param invertY defines if data must be stored with Y axis inverted
  28569. * @param compression defines the used compression (can be null)
  28570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28571. */
  28572. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28573. /**
  28574. * Creates a new raw 3D texture
  28575. * @param data defines the data used to create the texture
  28576. * @param width defines the width of the texture
  28577. * @param height defines the height of the texture
  28578. * @param depth defines the depth of the texture
  28579. * @param format defines the format of the texture
  28580. * @param generateMipMaps defines if the engine must generate mip levels
  28581. * @param invertY defines if data must be stored with Y axis inverted
  28582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28583. * @param compression defines the compressed used (can be null)
  28584. * @param textureType defines the compressed used (can be null)
  28585. * @returns a new raw 3D texture (stored in an InternalTexture)
  28586. */
  28587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28588. private _prepareWebGLTextureContinuation;
  28589. private _prepareWebGLTexture;
  28590. private _convertRGBtoRGBATextureData;
  28591. /** @hidden */
  28592. _releaseFramebufferObjects(texture: InternalTexture): void;
  28593. /** @hidden */
  28594. _releaseTexture(texture: InternalTexture): void;
  28595. private setProgram;
  28596. private _boundUniforms;
  28597. /**
  28598. * Binds an effect to the webGL context
  28599. * @param effect defines the effect to bind
  28600. */
  28601. bindSamplers(effect: Effect): void;
  28602. private _moveBoundTextureOnTop;
  28603. private _getCorrectTextureChannel;
  28604. private _linkTrackers;
  28605. private _removeDesignatedSlot;
  28606. private _activateCurrentTexture;
  28607. /** @hidden */
  28608. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28609. /** @hidden */
  28610. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28611. /**
  28612. * Sets a texture to the webGL context from a postprocess
  28613. * @param channel defines the channel to use
  28614. * @param postProcess defines the source postprocess
  28615. */
  28616. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28617. /**
  28618. * Binds the output of the passed in post process to the texture channel specified
  28619. * @param channel The channel the texture should be bound to
  28620. * @param postProcess The post process which's output should be bound
  28621. */
  28622. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28623. /**
  28624. * Unbind all textures from the webGL context
  28625. */
  28626. unbindAllTextures(): void;
  28627. /**
  28628. * Sets a texture to the according uniform.
  28629. * @param channel The texture channel
  28630. * @param uniform The uniform to set
  28631. * @param texture The texture to apply
  28632. */
  28633. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28634. /**
  28635. * Sets a depth stencil texture from a render target to the according uniform.
  28636. * @param channel The texture channel
  28637. * @param uniform The uniform to set
  28638. * @param texture The render target texture containing the depth stencil texture to apply
  28639. */
  28640. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28641. private _bindSamplerUniformToChannel;
  28642. private _getTextureWrapMode;
  28643. private _setTexture;
  28644. /**
  28645. * Sets an array of texture to the webGL context
  28646. * @param channel defines the channel where the texture array must be set
  28647. * @param uniform defines the associated uniform location
  28648. * @param textures defines the array of textures to bind
  28649. */
  28650. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28651. /** @hidden */
  28652. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28653. private _setTextureParameterFloat;
  28654. private _setTextureParameterInteger;
  28655. /**
  28656. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28657. * @param x defines the x coordinate of the rectangle where pixels must be read
  28658. * @param y defines the y coordinate of the rectangle where pixels must be read
  28659. * @param width defines the width of the rectangle where pixels must be read
  28660. * @param height defines the height of the rectangle where pixels must be read
  28661. * @returns a Uint8Array containing RGBA colors
  28662. */
  28663. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28664. /**
  28665. * Add an externaly attached data from its key.
  28666. * This method call will fail and return false, if such key already exists.
  28667. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28668. * @param key the unique key that identifies the data
  28669. * @param data the data object to associate to the key for this Engine instance
  28670. * @return true if no such key were already present and the data was added successfully, false otherwise
  28671. */
  28672. addExternalData<T>(key: string, data: T): boolean;
  28673. /**
  28674. * Get an externaly attached data from its key
  28675. * @param key the unique key that identifies the data
  28676. * @return the associated data, if present (can be null), or undefined if not present
  28677. */
  28678. getExternalData<T>(key: string): T;
  28679. /**
  28680. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28681. * @param key the unique key that identifies the data
  28682. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28683. * @return the associated data, can be null if the factory returned null.
  28684. */
  28685. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28686. /**
  28687. * Remove an externaly attached data from the Engine instance
  28688. * @param key the unique key that identifies the data
  28689. * @return true if the data was successfully removed, false if it doesn't exist
  28690. */
  28691. removeExternalData(key: string): boolean;
  28692. /**
  28693. * Unbind all vertex attributes from the webGL context
  28694. */
  28695. unbindAllAttributes(): void;
  28696. /**
  28697. * 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
  28698. */
  28699. releaseEffects(): void;
  28700. /**
  28701. * Dispose and release all associated resources
  28702. */
  28703. dispose(): void;
  28704. /**
  28705. * Display the loading screen
  28706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28707. */
  28708. displayLoadingUI(): void;
  28709. /**
  28710. * Hide the loading screen
  28711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28712. */
  28713. hideLoadingUI(): void;
  28714. /**
  28715. * Gets the current loading screen object
  28716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28717. */
  28718. /**
  28719. * Sets the current loading screen object
  28720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28721. */
  28722. loadingScreen: ILoadingScreen;
  28723. /**
  28724. * Sets the current loading screen text
  28725. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28726. */
  28727. loadingUIText: string;
  28728. /**
  28729. * Sets the current loading screen background color
  28730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28731. */
  28732. loadingUIBackgroundColor: string;
  28733. /**
  28734. * Attach a new callback raised when context lost event is fired
  28735. * @param callback defines the callback to call
  28736. */
  28737. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28738. /**
  28739. * Attach a new callback raised when context restored event is fired
  28740. * @param callback defines the callback to call
  28741. */
  28742. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28743. /**
  28744. * Gets the source code of the vertex shader associated with a specific webGL program
  28745. * @param program defines the program to use
  28746. * @returns a string containing the source code of the vertex shader associated with the program
  28747. */
  28748. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28749. /**
  28750. * Gets the source code of the fragment shader associated with a specific webGL program
  28751. * @param program defines the program to use
  28752. * @returns a string containing the source code of the fragment shader associated with the program
  28753. */
  28754. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28755. /**
  28756. * Get the current error code of the webGL context
  28757. * @returns the error code
  28758. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28759. */
  28760. getError(): number;
  28761. /**
  28762. * Gets the current framerate
  28763. * @returns a number representing the framerate
  28764. */
  28765. getFps(): number;
  28766. /**
  28767. * Gets the time spent between current and previous frame
  28768. * @returns a number representing the delta time in ms
  28769. */
  28770. getDeltaTime(): number;
  28771. private _measureFps;
  28772. /** @hidden */
  28773. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28774. private _canRenderToFloatFramebuffer;
  28775. private _canRenderToHalfFloatFramebuffer;
  28776. private _canRenderToFramebuffer;
  28777. /** @hidden */
  28778. _getWebGLTextureType(type: number): number;
  28779. private _getInternalFormat;
  28780. /** @hidden */
  28781. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28782. /** @hidden */
  28783. _getRGBAMultiSampleBufferFormat(type: number): number;
  28784. /** @hidden */
  28785. _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;
  28786. /** @hidden */
  28787. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28788. private _partialLoadFile;
  28789. private _cascadeLoadFiles;
  28790. /**
  28791. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28792. * @returns true if the engine can be created
  28793. * @ignorenaming
  28794. */
  28795. static isSupported(): boolean;
  28796. }
  28797. }
  28798. declare module "babylonjs/Materials/effect" {
  28799. import { Observable } from "babylonjs/Misc/observable";
  28800. import { Nullable } from "babylonjs/types";
  28801. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28802. import { Engine } from "babylonjs/Engines/engine";
  28803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28804. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28808. /**
  28809. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28810. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28811. */
  28812. export class EffectFallbacks {
  28813. private _defines;
  28814. private _currentRank;
  28815. private _maxRank;
  28816. private _mesh;
  28817. /**
  28818. * Removes the fallback from the bound mesh.
  28819. */
  28820. unBindMesh(): void;
  28821. /**
  28822. * Adds a fallback on the specified property.
  28823. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28824. * @param define The name of the define in the shader
  28825. */
  28826. addFallback(rank: number, define: string): void;
  28827. /**
  28828. * Sets the mesh to use CPU skinning when needing to fallback.
  28829. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28830. * @param mesh The mesh to use the fallbacks.
  28831. */
  28832. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28833. /**
  28834. * Checks to see if more fallbacks are still availible.
  28835. */
  28836. readonly isMoreFallbacks: boolean;
  28837. /**
  28838. * Removes the defines that shoould be removed when falling back.
  28839. * @param currentDefines defines the current define statements for the shader.
  28840. * @param effect defines the current effect we try to compile
  28841. * @returns The resulting defines with defines of the current rank removed.
  28842. */
  28843. reduce(currentDefines: string, effect: Effect): string;
  28844. }
  28845. /**
  28846. * Options to be used when creating an effect.
  28847. */
  28848. export class EffectCreationOptions {
  28849. /**
  28850. * Atrributes that will be used in the shader.
  28851. */
  28852. attributes: string[];
  28853. /**
  28854. * Uniform varible names that will be set in the shader.
  28855. */
  28856. uniformsNames: string[];
  28857. /**
  28858. * Uniform buffer varible names that will be set in the shader.
  28859. */
  28860. uniformBuffersNames: string[];
  28861. /**
  28862. * Sampler texture variable names that will be set in the shader.
  28863. */
  28864. samplers: string[];
  28865. /**
  28866. * Define statements that will be set in the shader.
  28867. */
  28868. defines: any;
  28869. /**
  28870. * Possible fallbacks for this effect to improve performance when needed.
  28871. */
  28872. fallbacks: Nullable<EffectFallbacks>;
  28873. /**
  28874. * Callback that will be called when the shader is compiled.
  28875. */
  28876. onCompiled: Nullable<(effect: Effect) => void>;
  28877. /**
  28878. * Callback that will be called if an error occurs during shader compilation.
  28879. */
  28880. onError: Nullable<(effect: Effect, errors: string) => void>;
  28881. /**
  28882. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28883. */
  28884. indexParameters: any;
  28885. /**
  28886. * Max number of lights that can be used in the shader.
  28887. */
  28888. maxSimultaneousLights: number;
  28889. /**
  28890. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28891. */
  28892. transformFeedbackVaryings: Nullable<string[]>;
  28893. }
  28894. /**
  28895. * Effect containing vertex and fragment shader that can be executed on an object.
  28896. */
  28897. export class Effect {
  28898. /**
  28899. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28900. */
  28901. static ShadersRepository: string;
  28902. /**
  28903. * Name of the effect.
  28904. */
  28905. name: any;
  28906. /**
  28907. * String container all the define statements that should be set on the shader.
  28908. */
  28909. defines: string;
  28910. /**
  28911. * Callback that will be called when the shader is compiled.
  28912. */
  28913. onCompiled: Nullable<(effect: Effect) => void>;
  28914. /**
  28915. * Callback that will be called if an error occurs during shader compilation.
  28916. */
  28917. onError: Nullable<(effect: Effect, errors: string) => void>;
  28918. /**
  28919. * Callback that will be called when effect is bound.
  28920. */
  28921. onBind: Nullable<(effect: Effect) => void>;
  28922. /**
  28923. * Unique ID of the effect.
  28924. */
  28925. uniqueId: number;
  28926. /**
  28927. * Observable that will be called when the shader is compiled.
  28928. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28929. */
  28930. onCompileObservable: Observable<Effect>;
  28931. /**
  28932. * Observable that will be called if an error occurs during shader compilation.
  28933. */
  28934. onErrorObservable: Observable<Effect>;
  28935. /** @hidden */
  28936. _onBindObservable: Nullable<Observable<Effect>>;
  28937. /**
  28938. * Observable that will be called when effect is bound.
  28939. */
  28940. readonly onBindObservable: Observable<Effect>;
  28941. /** @hidden */
  28942. _bonesComputationForcedToCPU: boolean;
  28943. private static _uniqueIdSeed;
  28944. private _engine;
  28945. private _uniformBuffersNames;
  28946. private _uniformsNames;
  28947. private _samplers;
  28948. private _isReady;
  28949. private _compilationError;
  28950. private _attributesNames;
  28951. private _attributes;
  28952. private _uniforms;
  28953. /**
  28954. * Key for the effect.
  28955. * @hidden
  28956. */
  28957. _key: string;
  28958. private _indexParameters;
  28959. private _fallbacks;
  28960. private _vertexSourceCode;
  28961. private _fragmentSourceCode;
  28962. private _vertexSourceCodeOverride;
  28963. private _fragmentSourceCodeOverride;
  28964. private _transformFeedbackVaryings;
  28965. /**
  28966. * Compiled shader to webGL program.
  28967. * @hidden
  28968. */
  28969. _program: WebGLProgram;
  28970. private _valueCache;
  28971. private static _baseCache;
  28972. /**
  28973. * Instantiates an effect.
  28974. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28975. * @param baseName Name of the effect.
  28976. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28977. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28978. * @param samplers List of sampler variables that will be passed to the shader.
  28979. * @param engine Engine to be used to render the effect
  28980. * @param defines Define statements to be added to the shader.
  28981. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28982. * @param onCompiled Callback that will be called when the shader is compiled.
  28983. * @param onError Callback that will be called if an error occurs during shader compilation.
  28984. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28985. */
  28986. 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);
  28987. /**
  28988. * Unique key for this effect
  28989. */
  28990. readonly key: string;
  28991. /**
  28992. * If the effect has been compiled and prepared.
  28993. * @returns if the effect is compiled and prepared.
  28994. */
  28995. isReady(): boolean;
  28996. /**
  28997. * The engine the effect was initialized with.
  28998. * @returns the engine.
  28999. */
  29000. getEngine(): Engine;
  29001. /**
  29002. * The compiled webGL program for the effect
  29003. * @returns the webGL program.
  29004. */
  29005. getProgram(): WebGLProgram;
  29006. /**
  29007. * The set of names of attribute variables for the shader.
  29008. * @returns An array of attribute names.
  29009. */
  29010. getAttributesNames(): string[];
  29011. /**
  29012. * Returns the attribute at the given index.
  29013. * @param index The index of the attribute.
  29014. * @returns The location of the attribute.
  29015. */
  29016. getAttributeLocation(index: number): number;
  29017. /**
  29018. * Returns the attribute based on the name of the variable.
  29019. * @param name of the attribute to look up.
  29020. * @returns the attribute location.
  29021. */
  29022. getAttributeLocationByName(name: string): number;
  29023. /**
  29024. * The number of attributes.
  29025. * @returns the numnber of attributes.
  29026. */
  29027. getAttributesCount(): number;
  29028. /**
  29029. * Gets the index of a uniform variable.
  29030. * @param uniformName of the uniform to look up.
  29031. * @returns the index.
  29032. */
  29033. getUniformIndex(uniformName: string): number;
  29034. /**
  29035. * Returns the attribute based on the name of the variable.
  29036. * @param uniformName of the uniform to look up.
  29037. * @returns the location of the uniform.
  29038. */
  29039. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29040. /**
  29041. * Returns an array of sampler variable names
  29042. * @returns The array of sampler variable neames.
  29043. */
  29044. getSamplers(): string[];
  29045. /**
  29046. * The error from the last compilation.
  29047. * @returns the error string.
  29048. */
  29049. getCompilationError(): string;
  29050. /**
  29051. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29052. * @param func The callback to be used.
  29053. */
  29054. executeWhenCompiled(func: (effect: Effect) => void): void;
  29055. private _checkIsReady;
  29056. /** @hidden */
  29057. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29058. /** @hidden */
  29059. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29060. /** @hidden */
  29061. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29062. private _processShaderConversion;
  29063. private _processIncludes;
  29064. private _processPrecision;
  29065. /**
  29066. * Recompiles the webGL program
  29067. * @param vertexSourceCode The source code for the vertex shader.
  29068. * @param fragmentSourceCode The source code for the fragment shader.
  29069. * @param onCompiled Callback called when completed.
  29070. * @param onError Callback called on error.
  29071. * @hidden
  29072. */
  29073. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29074. /**
  29075. * Gets the uniform locations of the the specified variable names
  29076. * @param names THe names of the variables to lookup.
  29077. * @returns Array of locations in the same order as variable names.
  29078. */
  29079. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29080. /**
  29081. * Prepares the effect
  29082. * @hidden
  29083. */
  29084. _prepareEffect(): void;
  29085. /**
  29086. * Checks if the effect is supported. (Must be called after compilation)
  29087. */
  29088. readonly isSupported: boolean;
  29089. /**
  29090. * Binds a texture to the engine to be used as output of the shader.
  29091. * @param channel Name of the output variable.
  29092. * @param texture Texture to bind.
  29093. * @hidden
  29094. */
  29095. _bindTexture(channel: string, texture: InternalTexture): void;
  29096. /**
  29097. * Sets a texture on the engine to be used in the shader.
  29098. * @param channel Name of the sampler variable.
  29099. * @param texture Texture to set.
  29100. */
  29101. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29102. /**
  29103. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29104. * @param channel Name of the sampler variable.
  29105. * @param texture Texture to set.
  29106. */
  29107. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29108. /**
  29109. * Sets an array of textures on the engine to be used in the shader.
  29110. * @param channel Name of the variable.
  29111. * @param textures Textures to set.
  29112. */
  29113. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29114. /**
  29115. * 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)
  29116. * @param channel Name of the sampler variable.
  29117. * @param postProcess Post process to get the input texture from.
  29118. */
  29119. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29120. /**
  29121. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29122. * 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)
  29123. * @param channel Name of the sampler variable.
  29124. * @param postProcess Post process to get the output texture from.
  29125. */
  29126. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29127. /** @hidden */
  29128. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29129. /** @hidden */
  29130. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29131. /** @hidden */
  29132. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29133. /** @hidden */
  29134. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29135. /**
  29136. * Binds a buffer to a uniform.
  29137. * @param buffer Buffer to bind.
  29138. * @param name Name of the uniform variable to bind to.
  29139. */
  29140. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29141. /**
  29142. * Binds block to a uniform.
  29143. * @param blockName Name of the block to bind.
  29144. * @param index Index to bind.
  29145. */
  29146. bindUniformBlock(blockName: string, index: number): void;
  29147. /**
  29148. * Sets an interger value on a uniform variable.
  29149. * @param uniformName Name of the variable.
  29150. * @param value Value to be set.
  29151. * @returns this effect.
  29152. */
  29153. setInt(uniformName: string, value: number): Effect;
  29154. /**
  29155. * Sets an int array on a uniform variable.
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setIntArray(uniformName: string, array: Int32Array): Effect;
  29161. /**
  29162. * 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)
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29175. /**
  29176. * 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)
  29177. * @param uniformName Name of the variable.
  29178. * @param array array to be set.
  29179. * @returns this effect.
  29180. */
  29181. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29182. /**
  29183. * Sets an float array on a uniform variable.
  29184. * @param uniformName Name of the variable.
  29185. * @param array array to be set.
  29186. * @returns this effect.
  29187. */
  29188. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29189. /**
  29190. * 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)
  29191. * @param uniformName Name of the variable.
  29192. * @param array array to be set.
  29193. * @returns this effect.
  29194. */
  29195. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29196. /**
  29197. * 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)
  29198. * @param uniformName Name of the variable.
  29199. * @param array array to be set.
  29200. * @returns this effect.
  29201. */
  29202. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29203. /**
  29204. * 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)
  29205. * @param uniformName Name of the variable.
  29206. * @param array array to be set.
  29207. * @returns this effect.
  29208. */
  29209. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29210. /**
  29211. * Sets an array on a uniform variable.
  29212. * @param uniformName Name of the variable.
  29213. * @param array array to be set.
  29214. * @returns this effect.
  29215. */
  29216. setArray(uniformName: string, array: number[]): Effect;
  29217. /**
  29218. * 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)
  29219. * @param uniformName Name of the variable.
  29220. * @param array array to be set.
  29221. * @returns this effect.
  29222. */
  29223. setArray2(uniformName: string, array: number[]): Effect;
  29224. /**
  29225. * 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)
  29226. * @param uniformName Name of the variable.
  29227. * @param array array to be set.
  29228. * @returns this effect.
  29229. */
  29230. setArray3(uniformName: string, array: number[]): Effect;
  29231. /**
  29232. * 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)
  29233. * @param uniformName Name of the variable.
  29234. * @param array array to be set.
  29235. * @returns this effect.
  29236. */
  29237. setArray4(uniformName: string, array: number[]): Effect;
  29238. /**
  29239. * Sets matrices on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param matrices matrices to be set.
  29242. * @returns this effect.
  29243. */
  29244. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29245. /**
  29246. * Sets matrix on a uniform variable.
  29247. * @param uniformName Name of the variable.
  29248. * @param matrix matrix to be set.
  29249. * @returns this effect.
  29250. */
  29251. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29252. /**
  29253. * 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)
  29254. * @param uniformName Name of the variable.
  29255. * @param matrix matrix to be set.
  29256. * @returns this effect.
  29257. */
  29258. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29259. /**
  29260. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29261. * @param uniformName Name of the variable.
  29262. * @param matrix matrix to be set.
  29263. * @returns this effect.
  29264. */
  29265. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29266. /**
  29267. * Sets a float on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param value value to be set.
  29270. * @returns this effect.
  29271. */
  29272. setFloat(uniformName: string, value: number): Effect;
  29273. /**
  29274. * Sets a boolean on a uniform variable.
  29275. * @param uniformName Name of the variable.
  29276. * @param bool value to be set.
  29277. * @returns this effect.
  29278. */
  29279. setBool(uniformName: string, bool: boolean): Effect;
  29280. /**
  29281. * Sets a Vector2 on a uniform variable.
  29282. * @param uniformName Name of the variable.
  29283. * @param vector2 vector2 to be set.
  29284. * @returns this effect.
  29285. */
  29286. setVector2(uniformName: string, vector2: Vector2): Effect;
  29287. /**
  29288. * Sets a float2 on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param x First float in float2.
  29291. * @param y Second float in float2.
  29292. * @returns this effect.
  29293. */
  29294. setFloat2(uniformName: string, x: number, y: number): Effect;
  29295. /**
  29296. * Sets a Vector3 on a uniform variable.
  29297. * @param uniformName Name of the variable.
  29298. * @param vector3 Value to be set.
  29299. * @returns this effect.
  29300. */
  29301. setVector3(uniformName: string, vector3: Vector3): Effect;
  29302. /**
  29303. * Sets a float3 on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param x First float in float3.
  29306. * @param y Second float in float3.
  29307. * @param z Third float in float3.
  29308. * @returns this effect.
  29309. */
  29310. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29311. /**
  29312. * Sets a Vector4 on a uniform variable.
  29313. * @param uniformName Name of the variable.
  29314. * @param vector4 Value to be set.
  29315. * @returns this effect.
  29316. */
  29317. setVector4(uniformName: string, vector4: Vector4): Effect;
  29318. /**
  29319. * Sets a float4 on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param x First float in float4.
  29322. * @param y Second float in float4.
  29323. * @param z Third float in float4.
  29324. * @param w Fourth float in float4.
  29325. * @returns this effect.
  29326. */
  29327. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29328. /**
  29329. * Sets a Color3 on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param color3 Value to be set.
  29332. * @returns this effect.
  29333. */
  29334. setColor3(uniformName: string, color3: Color3): Effect;
  29335. /**
  29336. * Sets a Color4 on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param color3 Value to be set.
  29339. * @param alpha Alpha value to be set.
  29340. * @returns this effect.
  29341. */
  29342. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29343. /**
  29344. * Sets a Color4 on a uniform variable
  29345. * @param uniformName defines the name of the variable
  29346. * @param color4 defines the value to be set
  29347. * @returns this effect.
  29348. */
  29349. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29350. /**
  29351. * This function will add a new shader to the shader store
  29352. * @param name the name of the shader
  29353. * @param pixelShader optional pixel shader content
  29354. * @param vertexShader optional vertex shader content
  29355. */
  29356. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29357. /**
  29358. * Store of each shader (The can be looked up using effect.key)
  29359. */
  29360. static ShadersStore: {
  29361. [key: string]: string;
  29362. };
  29363. /**
  29364. * Store of each included file for a shader (The can be looked up using effect.key)
  29365. */
  29366. static IncludesShadersStore: {
  29367. [key: string]: string;
  29368. };
  29369. /**
  29370. * Resets the cache of effects.
  29371. */
  29372. static ResetCache(): void;
  29373. }
  29374. }
  29375. declare module "babylonjs/Materials/colorCurves" {
  29376. import { Effect } from "babylonjs/Materials/effect";
  29377. /**
  29378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29380. * 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;
  29381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29382. */
  29383. export class ColorCurves {
  29384. private _dirty;
  29385. private _tempColor;
  29386. private _globalCurve;
  29387. private _highlightsCurve;
  29388. private _midtonesCurve;
  29389. private _shadowsCurve;
  29390. private _positiveCurve;
  29391. private _negativeCurve;
  29392. private _globalHue;
  29393. private _globalDensity;
  29394. private _globalSaturation;
  29395. private _globalExposure;
  29396. /**
  29397. * Gets the global Hue value.
  29398. * 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).
  29399. */
  29400. /**
  29401. * Sets the global Hue value.
  29402. * 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).
  29403. */
  29404. globalHue: number;
  29405. /**
  29406. * Gets the global Density value.
  29407. * 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.
  29408. * Values less than zero provide a filter of opposite hue.
  29409. */
  29410. /**
  29411. * Sets the global Density value.
  29412. * 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.
  29413. * Values less than zero provide a filter of opposite hue.
  29414. */
  29415. globalDensity: number;
  29416. /**
  29417. * Gets the global Saturation value.
  29418. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29419. */
  29420. /**
  29421. * Sets the global Saturation value.
  29422. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29423. */
  29424. globalSaturation: number;
  29425. /**
  29426. * Gets the global Exposure value.
  29427. * 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.
  29428. */
  29429. /**
  29430. * Sets the global Exposure value.
  29431. * 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.
  29432. */
  29433. globalExposure: number;
  29434. private _highlightsHue;
  29435. private _highlightsDensity;
  29436. private _highlightsSaturation;
  29437. private _highlightsExposure;
  29438. /**
  29439. * Gets the highlights Hue value.
  29440. * 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).
  29441. */
  29442. /**
  29443. * Sets the highlights Hue value.
  29444. * 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).
  29445. */
  29446. highlightsHue: number;
  29447. /**
  29448. * Gets the highlights Density value.
  29449. * 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.
  29450. * Values less than zero provide a filter of opposite hue.
  29451. */
  29452. /**
  29453. * Sets the highlights Density value.
  29454. * 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.
  29455. * Values less than zero provide a filter of opposite hue.
  29456. */
  29457. highlightsDensity: number;
  29458. /**
  29459. * Gets the highlights Saturation value.
  29460. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29461. */
  29462. /**
  29463. * Sets the highlights Saturation value.
  29464. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29465. */
  29466. highlightsSaturation: number;
  29467. /**
  29468. * Gets the highlights Exposure value.
  29469. * 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.
  29470. */
  29471. /**
  29472. * Sets the highlights Exposure value.
  29473. * 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.
  29474. */
  29475. highlightsExposure: number;
  29476. private _midtonesHue;
  29477. private _midtonesDensity;
  29478. private _midtonesSaturation;
  29479. private _midtonesExposure;
  29480. /**
  29481. * Gets the midtones Hue value.
  29482. * 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).
  29483. */
  29484. /**
  29485. * Sets the midtones Hue value.
  29486. * 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).
  29487. */
  29488. midtonesHue: number;
  29489. /**
  29490. * Gets the midtones Density value.
  29491. * 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.
  29492. * Values less than zero provide a filter of opposite hue.
  29493. */
  29494. /**
  29495. * Sets the midtones Density value.
  29496. * 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.
  29497. * Values less than zero provide a filter of opposite hue.
  29498. */
  29499. midtonesDensity: number;
  29500. /**
  29501. * Gets the midtones Saturation value.
  29502. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29503. */
  29504. /**
  29505. * Sets the midtones Saturation value.
  29506. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29507. */
  29508. midtonesSaturation: number;
  29509. /**
  29510. * Gets the midtones Exposure value.
  29511. * 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.
  29512. */
  29513. /**
  29514. * Sets the midtones Exposure value.
  29515. * 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.
  29516. */
  29517. midtonesExposure: number;
  29518. private _shadowsHue;
  29519. private _shadowsDensity;
  29520. private _shadowsSaturation;
  29521. private _shadowsExposure;
  29522. /**
  29523. * Gets the shadows Hue value.
  29524. * 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).
  29525. */
  29526. /**
  29527. * Sets the shadows Hue value.
  29528. * 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).
  29529. */
  29530. shadowsHue: number;
  29531. /**
  29532. * Gets the shadows Density value.
  29533. * 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.
  29534. * Values less than zero provide a filter of opposite hue.
  29535. */
  29536. /**
  29537. * Sets the shadows Density value.
  29538. * 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.
  29539. * Values less than zero provide a filter of opposite hue.
  29540. */
  29541. shadowsDensity: number;
  29542. /**
  29543. * Gets the shadows Saturation value.
  29544. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29545. */
  29546. /**
  29547. * Sets the shadows Saturation value.
  29548. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29549. */
  29550. shadowsSaturation: number;
  29551. /**
  29552. * Gets the shadows Exposure value.
  29553. * 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.
  29554. */
  29555. /**
  29556. * Sets the shadows Exposure value.
  29557. * 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.
  29558. */
  29559. shadowsExposure: number;
  29560. /**
  29561. * Returns the class name
  29562. * @returns The class name
  29563. */
  29564. getClassName(): string;
  29565. /**
  29566. * Binds the color curves to the shader.
  29567. * @param colorCurves The color curve to bind
  29568. * @param effect The effect to bind to
  29569. * @param positiveUniform The positive uniform shader parameter
  29570. * @param neutralUniform The neutral uniform shader parameter
  29571. * @param negativeUniform The negative uniform shader parameter
  29572. */
  29573. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29574. /**
  29575. * Prepare the list of uniforms associated with the ColorCurves effects.
  29576. * @param uniformsList The list of uniforms used in the effect
  29577. */
  29578. static PrepareUniforms(uniformsList: string[]): void;
  29579. /**
  29580. * Returns color grading data based on a hue, density, saturation and exposure value.
  29581. * @param filterHue The hue of the color filter.
  29582. * @param filterDensity The density of the color filter.
  29583. * @param saturation The saturation.
  29584. * @param exposure The exposure.
  29585. * @param result The result data container.
  29586. */
  29587. private getColorGradingDataToRef;
  29588. /**
  29589. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29590. * @param value The input slider value in range [-100,100].
  29591. * @returns Adjusted value.
  29592. */
  29593. private static applyColorGradingSliderNonlinear;
  29594. /**
  29595. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29596. * @param hue The hue (H) input.
  29597. * @param saturation The saturation (S) input.
  29598. * @param brightness The brightness (B) input.
  29599. * @result An RGBA color represented as Vector4.
  29600. */
  29601. private static fromHSBToRef;
  29602. /**
  29603. * Returns a value clamped between min and max
  29604. * @param value The value to clamp
  29605. * @param min The minimum of value
  29606. * @param max The maximum of value
  29607. * @returns The clamped value.
  29608. */
  29609. private static clamp;
  29610. /**
  29611. * Clones the current color curve instance.
  29612. * @return The cloned curves
  29613. */
  29614. clone(): ColorCurves;
  29615. /**
  29616. * Serializes the current color curve instance to a json representation.
  29617. * @return a JSON representation
  29618. */
  29619. serialize(): any;
  29620. /**
  29621. * Parses the color curve from a json representation.
  29622. * @param source the JSON source to parse
  29623. * @return The parsed curves
  29624. */
  29625. static Parse(source: any): ColorCurves;
  29626. }
  29627. }
  29628. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29629. import { Observable } from "babylonjs/Misc/observable";
  29630. import { Nullable } from "babylonjs/types";
  29631. import { Color4 } from "babylonjs/Maths/math";
  29632. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29633. import { Effect } from "babylonjs/Materials/effect";
  29634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29635. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29636. /**
  29637. * Interface to follow in your material defines to integrate easily the
  29638. * Image proccessing functions.
  29639. * @hidden
  29640. */
  29641. export interface IImageProcessingConfigurationDefines {
  29642. IMAGEPROCESSING: boolean;
  29643. VIGNETTE: boolean;
  29644. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29645. VIGNETTEBLENDMODEOPAQUE: boolean;
  29646. TONEMAPPING: boolean;
  29647. TONEMAPPING_ACES: boolean;
  29648. CONTRAST: boolean;
  29649. EXPOSURE: boolean;
  29650. COLORCURVES: boolean;
  29651. COLORGRADING: boolean;
  29652. COLORGRADING3D: boolean;
  29653. SAMPLER3DGREENDEPTH: boolean;
  29654. SAMPLER3DBGRMAP: boolean;
  29655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29656. }
  29657. /**
  29658. * @hidden
  29659. */
  29660. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29661. IMAGEPROCESSING: boolean;
  29662. VIGNETTE: boolean;
  29663. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29664. VIGNETTEBLENDMODEOPAQUE: boolean;
  29665. TONEMAPPING: boolean;
  29666. TONEMAPPING_ACES: boolean;
  29667. CONTRAST: boolean;
  29668. COLORCURVES: boolean;
  29669. COLORGRADING: boolean;
  29670. COLORGRADING3D: boolean;
  29671. SAMPLER3DGREENDEPTH: boolean;
  29672. SAMPLER3DBGRMAP: boolean;
  29673. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29674. EXPOSURE: boolean;
  29675. constructor();
  29676. }
  29677. /**
  29678. * This groups together the common properties used for image processing either in direct forward pass
  29679. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29680. * or not.
  29681. */
  29682. export class ImageProcessingConfiguration {
  29683. /**
  29684. * Default tone mapping applied in BabylonJS.
  29685. */
  29686. static readonly TONEMAPPING_STANDARD: number;
  29687. /**
  29688. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29689. * to other engines rendering to increase portability.
  29690. */
  29691. static readonly TONEMAPPING_ACES: number;
  29692. /**
  29693. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29694. */
  29695. colorCurves: Nullable<ColorCurves>;
  29696. private _colorCurvesEnabled;
  29697. /**
  29698. * Gets wether the color curves effect is enabled.
  29699. */
  29700. /**
  29701. * Sets wether the color curves effect is enabled.
  29702. */
  29703. colorCurvesEnabled: boolean;
  29704. private _colorGradingTexture;
  29705. /**
  29706. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29707. */
  29708. /**
  29709. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29710. */
  29711. colorGradingTexture: Nullable<BaseTexture>;
  29712. private _colorGradingEnabled;
  29713. /**
  29714. * Gets wether the color grading effect is enabled.
  29715. */
  29716. /**
  29717. * Sets wether the color grading effect is enabled.
  29718. */
  29719. colorGradingEnabled: boolean;
  29720. private _colorGradingWithGreenDepth;
  29721. /**
  29722. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29723. */
  29724. /**
  29725. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29726. */
  29727. colorGradingWithGreenDepth: boolean;
  29728. private _colorGradingBGR;
  29729. /**
  29730. * Gets wether the color grading texture contains BGR values.
  29731. */
  29732. /**
  29733. * Sets wether the color grading texture contains BGR values.
  29734. */
  29735. colorGradingBGR: boolean;
  29736. /** @hidden */
  29737. _exposure: number;
  29738. /**
  29739. * Gets the Exposure used in the effect.
  29740. */
  29741. /**
  29742. * Sets the Exposure used in the effect.
  29743. */
  29744. exposure: number;
  29745. private _toneMappingEnabled;
  29746. /**
  29747. * Gets wether the tone mapping effect is enabled.
  29748. */
  29749. /**
  29750. * Sets wether the tone mapping effect is enabled.
  29751. */
  29752. toneMappingEnabled: boolean;
  29753. private _toneMappingType;
  29754. /**
  29755. * Gets the type of tone mapping effect.
  29756. */
  29757. /**
  29758. * Sets the type of tone mapping effect used in BabylonJS.
  29759. */
  29760. toneMappingType: number;
  29761. protected _contrast: number;
  29762. /**
  29763. * Gets the contrast used in the effect.
  29764. */
  29765. /**
  29766. * Sets the contrast used in the effect.
  29767. */
  29768. contrast: number;
  29769. /**
  29770. * Vignette stretch size.
  29771. */
  29772. vignetteStretch: number;
  29773. /**
  29774. * Vignette centre X Offset.
  29775. */
  29776. vignetteCentreX: number;
  29777. /**
  29778. * Vignette centre Y Offset.
  29779. */
  29780. vignetteCentreY: number;
  29781. /**
  29782. * Vignette weight or intensity of the vignette effect.
  29783. */
  29784. vignetteWeight: number;
  29785. /**
  29786. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29787. * if vignetteEnabled is set to true.
  29788. */
  29789. vignetteColor: Color4;
  29790. /**
  29791. * Camera field of view used by the Vignette effect.
  29792. */
  29793. vignetteCameraFov: number;
  29794. private _vignetteBlendMode;
  29795. /**
  29796. * Gets the vignette blend mode allowing different kind of effect.
  29797. */
  29798. /**
  29799. * Sets the vignette blend mode allowing different kind of effect.
  29800. */
  29801. vignetteBlendMode: number;
  29802. private _vignetteEnabled;
  29803. /**
  29804. * Gets wether the vignette effect is enabled.
  29805. */
  29806. /**
  29807. * Sets wether the vignette effect is enabled.
  29808. */
  29809. vignetteEnabled: boolean;
  29810. private _applyByPostProcess;
  29811. /**
  29812. * Gets wether the image processing is applied through a post process or not.
  29813. */
  29814. /**
  29815. * Sets wether the image processing is applied through a post process or not.
  29816. */
  29817. applyByPostProcess: boolean;
  29818. private _isEnabled;
  29819. /**
  29820. * Gets wether the image processing is enabled or not.
  29821. */
  29822. /**
  29823. * Sets wether the image processing is enabled or not.
  29824. */
  29825. isEnabled: boolean;
  29826. /**
  29827. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29828. */
  29829. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29830. /**
  29831. * Method called each time the image processing information changes requires to recompile the effect.
  29832. */
  29833. protected _updateParameters(): void;
  29834. /**
  29835. * Gets the current class name.
  29836. * @return "ImageProcessingConfiguration"
  29837. */
  29838. getClassName(): string;
  29839. /**
  29840. * Prepare the list of uniforms associated with the Image Processing effects.
  29841. * @param uniforms The list of uniforms used in the effect
  29842. * @param defines the list of defines currently in use
  29843. */
  29844. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29845. /**
  29846. * Prepare the list of samplers associated with the Image Processing effects.
  29847. * @param samplersList The list of uniforms used in the effect
  29848. * @param defines the list of defines currently in use
  29849. */
  29850. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29851. /**
  29852. * Prepare the list of defines associated to the shader.
  29853. * @param defines the list of defines to complete
  29854. * @param forPostProcess Define if we are currently in post process mode or not
  29855. */
  29856. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29857. /**
  29858. * Returns true if all the image processing information are ready.
  29859. * @returns True if ready, otherwise, false
  29860. */
  29861. isReady(): boolean;
  29862. /**
  29863. * Binds the image processing to the shader.
  29864. * @param effect The effect to bind to
  29865. * @param aspectRatio Define the current aspect ratio of the effect
  29866. */
  29867. bind(effect: Effect, aspectRatio?: number): void;
  29868. /**
  29869. * Clones the current image processing instance.
  29870. * @return The cloned image processing
  29871. */
  29872. clone(): ImageProcessingConfiguration;
  29873. /**
  29874. * Serializes the current image processing instance to a json representation.
  29875. * @return a JSON representation
  29876. */
  29877. serialize(): any;
  29878. /**
  29879. * Parses the image processing from a json representation.
  29880. * @param source the JSON source to parse
  29881. * @return The parsed image processing
  29882. */
  29883. static Parse(source: any): ImageProcessingConfiguration;
  29884. private static _VIGNETTEMODE_MULTIPLY;
  29885. private static _VIGNETTEMODE_OPAQUE;
  29886. /**
  29887. * Used to apply the vignette as a mix with the pixel color.
  29888. */
  29889. static readonly VIGNETTEMODE_MULTIPLY: number;
  29890. /**
  29891. * Used to apply the vignette as a replacement of the pixel color.
  29892. */
  29893. static readonly VIGNETTEMODE_OPAQUE: number;
  29894. }
  29895. }
  29896. declare module "babylonjs/Materials/fresnelParameters" {
  29897. import { Color3 } from "babylonjs/Maths/math";
  29898. /**
  29899. * This represents all the required information to add a fresnel effect on a material:
  29900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29901. */
  29902. export class FresnelParameters {
  29903. private _isEnabled;
  29904. /**
  29905. * Define if the fresnel effect is enable or not.
  29906. */
  29907. isEnabled: boolean;
  29908. /**
  29909. * Define the color used on edges (grazing angle)
  29910. */
  29911. leftColor: Color3;
  29912. /**
  29913. * Define the color used on center
  29914. */
  29915. rightColor: Color3;
  29916. /**
  29917. * Define bias applied to computed fresnel term
  29918. */
  29919. bias: number;
  29920. /**
  29921. * Defined the power exponent applied to fresnel term
  29922. */
  29923. power: number;
  29924. /**
  29925. * Clones the current fresnel and its valuues
  29926. * @returns a clone fresnel configuration
  29927. */
  29928. clone(): FresnelParameters;
  29929. /**
  29930. * Serializes the current fresnel parameters to a JSON representation.
  29931. * @return the JSON serialization
  29932. */
  29933. serialize(): any;
  29934. /**
  29935. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29936. * @param parsedFresnelParameters Define the JSON representation
  29937. * @returns the parsed parameters
  29938. */
  29939. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29940. }
  29941. }
  29942. declare module "babylonjs/Misc/decorators" {
  29943. import { Nullable } from "babylonjs/types";
  29944. import { Scene } from "babylonjs/scene";
  29945. import { IAnimatable } from "babylonjs/Misc/tools";
  29946. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29947. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29948. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29949. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29950. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29951. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29952. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29953. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29954. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29955. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29956. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29957. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29958. /**
  29959. * Decorator used to define property that can be serialized as reference to a camera
  29960. * @param sourceName defines the name of the property to decorate
  29961. */
  29962. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29963. /**
  29964. * Class used to help serialization objects
  29965. */
  29966. export class SerializationHelper {
  29967. /** hidden */
  29968. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29969. /** hidden */
  29970. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29971. /** hidden */
  29972. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29973. /** hidden */
  29974. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29975. /**
  29976. * Appends the serialized animations from the source animations
  29977. * @param source Source containing the animations
  29978. * @param destination Target to store the animations
  29979. */
  29980. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29981. /**
  29982. * Static function used to serialized a specific entity
  29983. * @param entity defines the entity to serialize
  29984. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29985. * @returns a JSON compatible object representing the serialization of the entity
  29986. */
  29987. static Serialize<T>(entity: T, serializationObject?: any): any;
  29988. /**
  29989. * Creates a new entity from a serialization data object
  29990. * @param creationFunction defines a function used to instanciated the new entity
  29991. * @param source defines the source serialization data
  29992. * @param scene defines the hosting scene
  29993. * @param rootUrl defines the root url for resources
  29994. * @returns a new entity
  29995. */
  29996. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29997. /**
  29998. * Clones an object
  29999. * @param creationFunction defines the function used to instanciate the new object
  30000. * @param source defines the source object
  30001. * @returns the cloned object
  30002. */
  30003. static Clone<T>(creationFunction: () => T, source: T): T;
  30004. /**
  30005. * Instanciates a new object based on a source one (some data will be shared between both object)
  30006. * @param creationFunction defines the function used to instanciate the new object
  30007. * @param source defines the source object
  30008. * @returns the new object
  30009. */
  30010. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30011. }
  30012. }
  30013. declare module "babylonjs/Cameras/camera" {
  30014. import { SmartArray } from "babylonjs/Misc/smartArray";
  30015. import { Observable } from "babylonjs/Misc/observable";
  30016. import { Nullable } from "babylonjs/types";
  30017. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30018. import { Scene } from "babylonjs/scene";
  30019. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30020. import { Node } from "babylonjs/node";
  30021. import { Mesh } from "babylonjs/Meshes/mesh";
  30022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30023. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30026. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30027. import { Ray } from "babylonjs/Culling/ray";
  30028. /**
  30029. * This is the base class of all the camera used in the application.
  30030. * @see http://doc.babylonjs.com/features/cameras
  30031. */
  30032. export class Camera extends Node {
  30033. /** @hidden */
  30034. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30035. /**
  30036. * This is the default projection mode used by the cameras.
  30037. * It helps recreating a feeling of perspective and better appreciate depth.
  30038. * This is the best way to simulate real life cameras.
  30039. */
  30040. static readonly PERSPECTIVE_CAMERA: number;
  30041. /**
  30042. * This helps creating camera with an orthographic mode.
  30043. * 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.
  30044. */
  30045. static readonly ORTHOGRAPHIC_CAMERA: number;
  30046. /**
  30047. * This is the default FOV mode for perspective cameras.
  30048. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30049. */
  30050. static readonly FOVMODE_VERTICAL_FIXED: number;
  30051. /**
  30052. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30053. */
  30054. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30055. /**
  30056. * This specifies ther is no need for a camera rig.
  30057. * Basically only one eye is rendered corresponding to the camera.
  30058. */
  30059. static readonly RIG_MODE_NONE: number;
  30060. /**
  30061. * Simulates a camera Rig with one blue eye and one red eye.
  30062. * This can be use with 3d blue and red glasses.
  30063. */
  30064. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30065. /**
  30066. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30067. */
  30068. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30069. /**
  30070. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30071. */
  30072. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30073. /**
  30074. * Defines that both eyes of the camera will be rendered over under each other.
  30075. */
  30076. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30077. /**
  30078. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30079. */
  30080. static readonly RIG_MODE_VR: number;
  30081. /**
  30082. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30083. */
  30084. static readonly RIG_MODE_WEBVR: number;
  30085. /**
  30086. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30087. */
  30088. static readonly RIG_MODE_CUSTOM: number;
  30089. /**
  30090. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30091. */
  30092. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30093. /**
  30094. * @hidden
  30095. * Might be removed once multiview will be a thing
  30096. */
  30097. static UseAlternateWebVRRendering: boolean;
  30098. /**
  30099. * Define the input manager associated with the camera.
  30100. */
  30101. inputs: CameraInputsManager<Camera>;
  30102. /** @hidden */
  30103. _position: Vector3;
  30104. /**
  30105. * Define the current local position of the camera in the scene
  30106. */
  30107. position: Vector3;
  30108. /**
  30109. * The vector the camera should consider as up.
  30110. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30111. */
  30112. upVector: Vector3;
  30113. /**
  30114. * Define the current limit on the left side for an orthographic camera
  30115. * In scene unit
  30116. */
  30117. orthoLeft: Nullable<number>;
  30118. /**
  30119. * Define the current limit on the right side for an orthographic camera
  30120. * In scene unit
  30121. */
  30122. orthoRight: Nullable<number>;
  30123. /**
  30124. * Define the current limit on the bottom side for an orthographic camera
  30125. * In scene unit
  30126. */
  30127. orthoBottom: Nullable<number>;
  30128. /**
  30129. * Define the current limit on the top side for an orthographic camera
  30130. * In scene unit
  30131. */
  30132. orthoTop: Nullable<number>;
  30133. /**
  30134. * Field Of View is set in Radians. (default is 0.8)
  30135. */
  30136. fov: number;
  30137. /**
  30138. * Define the minimum distance the camera can see from.
  30139. * This is important to note that the depth buffer are not infinite and the closer it starts
  30140. * the more your scene might encounter depth fighting issue.
  30141. */
  30142. minZ: number;
  30143. /**
  30144. * Define the maximum distance the camera can see to.
  30145. * This is important to note that the depth buffer are not infinite and the further it end
  30146. * the more your scene might encounter depth fighting issue.
  30147. */
  30148. maxZ: number;
  30149. /**
  30150. * Define the default inertia of the camera.
  30151. * This helps giving a smooth feeling to the camera movement.
  30152. */
  30153. inertia: number;
  30154. /**
  30155. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30156. */
  30157. mode: number;
  30158. /**
  30159. * Define wether the camera is intermediate.
  30160. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30161. */
  30162. isIntermediate: boolean;
  30163. /**
  30164. * Define the viewport of the camera.
  30165. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30166. */
  30167. viewport: Viewport;
  30168. /**
  30169. * Restricts the camera to viewing objects with the same layerMask.
  30170. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30171. */
  30172. layerMask: number;
  30173. /**
  30174. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30175. */
  30176. fovMode: number;
  30177. /**
  30178. * Rig mode of the camera.
  30179. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30180. * This is normally controlled byt the camera themselves as internal use.
  30181. */
  30182. cameraRigMode: number;
  30183. /**
  30184. * Defines the distance between both "eyes" in case of a RIG
  30185. */
  30186. interaxialDistance: number;
  30187. /**
  30188. * Defines if stereoscopic rendering is done side by side or over under.
  30189. */
  30190. isStereoscopicSideBySide: boolean;
  30191. /**
  30192. * 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
  30193. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30194. * else in the scene.
  30195. */
  30196. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30197. /**
  30198. * When set, the camera will render to this render target instead of the default canvas
  30199. */
  30200. outputRenderTarget: Nullable<RenderTargetTexture>;
  30201. /**
  30202. * Observable triggered when the camera view matrix has changed.
  30203. */
  30204. onViewMatrixChangedObservable: Observable<Camera>;
  30205. /**
  30206. * Observable triggered when the camera Projection matrix has changed.
  30207. */
  30208. onProjectionMatrixChangedObservable: Observable<Camera>;
  30209. /**
  30210. * Observable triggered when the inputs have been processed.
  30211. */
  30212. onAfterCheckInputsObservable: Observable<Camera>;
  30213. /**
  30214. * Observable triggered when reset has been called and applied to the camera.
  30215. */
  30216. onRestoreStateObservable: Observable<Camera>;
  30217. /** @hidden */
  30218. _cameraRigParams: any;
  30219. /** @hidden */
  30220. _rigCameras: Camera[];
  30221. /** @hidden */
  30222. _rigPostProcess: Nullable<PostProcess>;
  30223. protected _webvrViewMatrix: Matrix;
  30224. /** @hidden */
  30225. _skipRendering: boolean;
  30226. /** @hidden */
  30227. _alternateCamera: Camera;
  30228. /** @hidden */
  30229. _projectionMatrix: Matrix;
  30230. /** @hidden */
  30231. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30232. /** @hidden */
  30233. _activeMeshes: SmartArray<AbstractMesh>;
  30234. protected _globalPosition: Vector3;
  30235. /** hidden */
  30236. _computedViewMatrix: Matrix;
  30237. private _doNotComputeProjectionMatrix;
  30238. private _transformMatrix;
  30239. private _frustumPlanes;
  30240. private _refreshFrustumPlanes;
  30241. private _storedFov;
  30242. private _stateStored;
  30243. /**
  30244. * Instantiates a new camera object.
  30245. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30246. * @see http://doc.babylonjs.com/features/cameras
  30247. * @param name Defines the name of the camera in the scene
  30248. * @param position Defines the position of the camera
  30249. * @param scene Defines the scene the camera belongs too
  30250. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30251. */
  30252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30253. /**
  30254. * Store current camera state (fov, position, etc..)
  30255. * @returns the camera
  30256. */
  30257. storeState(): Camera;
  30258. /**
  30259. * Restores the camera state values if it has been stored. You must call storeState() first
  30260. */
  30261. protected _restoreStateValues(): boolean;
  30262. /**
  30263. * Restored camera state. You must call storeState() first.
  30264. * @returns true if restored and false otherwise
  30265. */
  30266. restoreState(): boolean;
  30267. /**
  30268. * Gets the class name of the camera.
  30269. * @returns the class name
  30270. */
  30271. getClassName(): string;
  30272. /** @hidden */
  30273. readonly _isCamera: boolean;
  30274. /**
  30275. * Gets a string representation of the camera useful for debug purpose.
  30276. * @param fullDetails Defines that a more verboe level of logging is required
  30277. * @returns the string representation
  30278. */
  30279. toString(fullDetails?: boolean): string;
  30280. /**
  30281. * Gets the current world space position of the camera.
  30282. */
  30283. readonly globalPosition: Vector3;
  30284. /**
  30285. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30286. * @returns the active meshe list
  30287. */
  30288. getActiveMeshes(): SmartArray<AbstractMesh>;
  30289. /**
  30290. * Check wether a mesh is part of the current active mesh list of the camera
  30291. * @param mesh Defines the mesh to check
  30292. * @returns true if active, false otherwise
  30293. */
  30294. isActiveMesh(mesh: Mesh): boolean;
  30295. /**
  30296. * Is this camera ready to be used/rendered
  30297. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30298. * @return true if the camera is ready
  30299. */
  30300. isReady(completeCheck?: boolean): boolean;
  30301. /** @hidden */
  30302. _initCache(): void;
  30303. /** @hidden */
  30304. _updateCache(ignoreParentClass?: boolean): void;
  30305. /** @hidden */
  30306. _isSynchronized(): boolean;
  30307. /** @hidden */
  30308. _isSynchronizedViewMatrix(): boolean;
  30309. /** @hidden */
  30310. _isSynchronizedProjectionMatrix(): boolean;
  30311. /**
  30312. * Attach the input controls to a specific dom element to get the input from.
  30313. * @param element Defines the element the controls should be listened from
  30314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30315. */
  30316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30317. /**
  30318. * Detach the current controls from the specified dom element.
  30319. * @param element Defines the element to stop listening the inputs from
  30320. */
  30321. detachControl(element: HTMLElement): void;
  30322. /**
  30323. * Update the camera state according to the different inputs gathered during the frame.
  30324. */
  30325. update(): void;
  30326. /** @hidden */
  30327. _checkInputs(): void;
  30328. /** @hidden */
  30329. readonly rigCameras: Camera[];
  30330. /**
  30331. * Gets the post process used by the rig cameras
  30332. */
  30333. readonly rigPostProcess: Nullable<PostProcess>;
  30334. /**
  30335. * Internal, gets the first post proces.
  30336. * @returns the first post process to be run on this camera.
  30337. */
  30338. _getFirstPostProcess(): Nullable<PostProcess>;
  30339. private _cascadePostProcessesToRigCams;
  30340. /**
  30341. * Attach a post process to the camera.
  30342. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30343. * @param postProcess The post process to attach to the camera
  30344. * @param insertAt The position of the post process in case several of them are in use in the scene
  30345. * @returns the position the post process has been inserted at
  30346. */
  30347. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30348. /**
  30349. * Detach a post process to the camera.
  30350. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30351. * @param postProcess The post process to detach from the camera
  30352. */
  30353. detachPostProcess(postProcess: PostProcess): void;
  30354. /**
  30355. * Gets the current world matrix of the camera
  30356. */
  30357. getWorldMatrix(): Matrix;
  30358. /** @hidden */
  30359. _getViewMatrix(): Matrix;
  30360. /**
  30361. * Gets the current view matrix of the camera.
  30362. * @param force forces the camera to recompute the matrix without looking at the cached state
  30363. * @returns the view matrix
  30364. */
  30365. getViewMatrix(force?: boolean): Matrix;
  30366. /**
  30367. * Freeze the projection matrix.
  30368. * It will prevent the cache check of the camera projection compute and can speed up perf
  30369. * if no parameter of the camera are meant to change
  30370. * @param projection Defines manually a projection if necessary
  30371. */
  30372. freezeProjectionMatrix(projection?: Matrix): void;
  30373. /**
  30374. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30375. */
  30376. unfreezeProjectionMatrix(): void;
  30377. /**
  30378. * Gets the current projection matrix of the camera.
  30379. * @param force forces the camera to recompute the matrix without looking at the cached state
  30380. * @returns the projection matrix
  30381. */
  30382. getProjectionMatrix(force?: boolean): Matrix;
  30383. /**
  30384. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30385. * @returns a Matrix
  30386. */
  30387. getTransformationMatrix(): Matrix;
  30388. private _updateFrustumPlanes;
  30389. /**
  30390. * Checks if a cullable object (mesh...) is in the camera frustum
  30391. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30392. * @param target The object to check
  30393. * @returns true if the object is in frustum otherwise false
  30394. */
  30395. isInFrustum(target: ICullable): boolean;
  30396. /**
  30397. * Checks if a cullable object (mesh...) is in the camera frustum
  30398. * Unlike isInFrustum this cheks the full bounding box
  30399. * @param target The object to check
  30400. * @returns true if the object is in frustum otherwise false
  30401. */
  30402. isCompletelyInFrustum(target: ICullable): boolean;
  30403. /**
  30404. * Gets a ray in the forward direction from the camera.
  30405. * @param length Defines the length of the ray to create
  30406. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30407. * @param origin Defines the start point of the ray which defaults to the camera position
  30408. * @returns the forward ray
  30409. */
  30410. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30411. /**
  30412. * Releases resources associated with this node.
  30413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30415. */
  30416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30417. /**
  30418. * Gets the left camera of a rig setup in case of Rigged Camera
  30419. */
  30420. readonly leftCamera: Nullable<FreeCamera>;
  30421. /**
  30422. * Gets the right camera of a rig setup in case of Rigged Camera
  30423. */
  30424. readonly rightCamera: Nullable<FreeCamera>;
  30425. /**
  30426. * Gets the left camera target of a rig setup in case of Rigged Camera
  30427. * @returns the target position
  30428. */
  30429. getLeftTarget(): Nullable<Vector3>;
  30430. /**
  30431. * Gets the right camera target of a rig setup in case of Rigged Camera
  30432. * @returns the target position
  30433. */
  30434. getRightTarget(): Nullable<Vector3>;
  30435. /**
  30436. * @hidden
  30437. */
  30438. setCameraRigMode(mode: number, rigParams: any): void;
  30439. /** @hidden */
  30440. static _setStereoscopicRigMode(camera: Camera): void;
  30441. /** @hidden */
  30442. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30443. /** @hidden */
  30444. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30445. /** @hidden */
  30446. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30447. /** @hidden */
  30448. _getVRProjectionMatrix(): Matrix;
  30449. protected _updateCameraRotationMatrix(): void;
  30450. protected _updateWebVRCameraRotationMatrix(): void;
  30451. /**
  30452. * This function MUST be overwritten by the different WebVR cameras available.
  30453. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30454. * @hidden
  30455. */
  30456. _getWebVRProjectionMatrix(): Matrix;
  30457. /**
  30458. * This function MUST be overwritten by the different WebVR cameras available.
  30459. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30460. * @hidden
  30461. */
  30462. _getWebVRViewMatrix(): Matrix;
  30463. /** @hidden */
  30464. setCameraRigParameter(name: string, value: any): void;
  30465. /**
  30466. * needs to be overridden by children so sub has required properties to be copied
  30467. * @hidden
  30468. */
  30469. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30470. /**
  30471. * May need to be overridden by children
  30472. * @hidden
  30473. */
  30474. _updateRigCameras(): void;
  30475. /** @hidden */
  30476. _setupInputs(): void;
  30477. /**
  30478. * Serialiaze the camera setup to a json represention
  30479. * @returns the JSON representation
  30480. */
  30481. serialize(): any;
  30482. /**
  30483. * Clones the current camera.
  30484. * @param name The cloned camera name
  30485. * @returns the cloned camera
  30486. */
  30487. clone(name: string): Camera;
  30488. /**
  30489. * Gets the direction of the camera relative to a given local axis.
  30490. * @param localAxis Defines the reference axis to provide a relative direction.
  30491. * @return the direction
  30492. */
  30493. getDirection(localAxis: Vector3): Vector3;
  30494. /**
  30495. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30496. * @param localAxis Defines the reference axis to provide a relative direction.
  30497. * @param result Defines the vector to store the result in
  30498. */
  30499. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30500. /**
  30501. * Gets a camera constructor for a given camera type
  30502. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30503. * @param name The name of the camera the result will be able to instantiate
  30504. * @param scene The scene the result will construct the camera in
  30505. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30506. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30507. * @returns a factory method to construc the camera
  30508. */
  30509. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30510. /**
  30511. * Compute the world matrix of the camera.
  30512. * @returns the camera workd matrix
  30513. */
  30514. computeWorldMatrix(): Matrix;
  30515. /**
  30516. * Parse a JSON and creates the camera from the parsed information
  30517. * @param parsedCamera The JSON to parse
  30518. * @param scene The scene to instantiate the camera in
  30519. * @returns the newly constructed camera
  30520. */
  30521. static Parse(parsedCamera: any, scene: Scene): Camera;
  30522. }
  30523. }
  30524. declare module "babylonjs/Misc/tools" {
  30525. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30526. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30527. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30528. import { Observable } from "babylonjs/Misc/observable";
  30529. import { DomManagement } from "babylonjs/Misc/domManagement";
  30530. import { Camera } from "babylonjs/Cameras/camera";
  30531. import { Engine } from "babylonjs/Engines/engine";
  30532. import { Animation } from "babylonjs/Animations/animation";
  30533. /**
  30534. * Interface for any object that can request an animation frame
  30535. */
  30536. export interface ICustomAnimationFrameRequester {
  30537. /**
  30538. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30539. */
  30540. renderFunction?: Function;
  30541. /**
  30542. * Called to request the next frame to render to
  30543. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30544. */
  30545. requestAnimationFrame: Function;
  30546. /**
  30547. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30548. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30549. */
  30550. requestID?: number;
  30551. }
  30552. /**
  30553. * Interface containing an array of animations
  30554. */
  30555. export interface IAnimatable {
  30556. /**
  30557. * Array of animations
  30558. */
  30559. animations: Array<Animation>;
  30560. }
  30561. /** Interface used by value gradients (color, factor, ...) */
  30562. export interface IValueGradient {
  30563. /**
  30564. * Gets or sets the gradient value (between 0 and 1)
  30565. */
  30566. gradient: number;
  30567. }
  30568. /** Class used to store color4 gradient */
  30569. export class ColorGradient implements IValueGradient {
  30570. /**
  30571. * Gets or sets the gradient value (between 0 and 1)
  30572. */
  30573. gradient: number;
  30574. /**
  30575. * Gets or sets first associated color
  30576. */
  30577. color1: Color4;
  30578. /**
  30579. * Gets or sets second associated color
  30580. */
  30581. color2?: Color4;
  30582. /**
  30583. * Will get a color picked randomly between color1 and color2.
  30584. * If color2 is undefined then color1 will be used
  30585. * @param result defines the target Color4 to store the result in
  30586. */
  30587. getColorToRef(result: Color4): void;
  30588. }
  30589. /** Class used to store color 3 gradient */
  30590. export class Color3Gradient implements IValueGradient {
  30591. /**
  30592. * Gets or sets the gradient value (between 0 and 1)
  30593. */
  30594. gradient: number;
  30595. /**
  30596. * Gets or sets the associated color
  30597. */
  30598. color: Color3;
  30599. }
  30600. /** Class used to store factor gradient */
  30601. export class FactorGradient implements IValueGradient {
  30602. /**
  30603. * Gets or sets the gradient value (between 0 and 1)
  30604. */
  30605. gradient: number;
  30606. /**
  30607. * Gets or sets first associated factor
  30608. */
  30609. factor1: number;
  30610. /**
  30611. * Gets or sets second associated factor
  30612. */
  30613. factor2?: number;
  30614. /**
  30615. * Will get a number picked randomly between factor1 and factor2.
  30616. * If factor2 is undefined then factor1 will be used
  30617. * @returns the picked number
  30618. */
  30619. getFactor(): number;
  30620. }
  30621. /**
  30622. * @ignore
  30623. * Application error to support additional information when loading a file
  30624. */
  30625. export class LoadFileError extends Error {
  30626. /** defines the optional XHR request */
  30627. request?: XMLHttpRequest | undefined;
  30628. private static _setPrototypeOf;
  30629. /**
  30630. * Creates a new LoadFileError
  30631. * @param message defines the message of the error
  30632. * @param request defines the optional XHR request
  30633. */
  30634. constructor(message: string,
  30635. /** defines the optional XHR request */
  30636. request?: XMLHttpRequest | undefined);
  30637. }
  30638. /**
  30639. * Class used to define a retry strategy when error happens while loading assets
  30640. */
  30641. export class RetryStrategy {
  30642. /**
  30643. * Function used to defines an exponential back off strategy
  30644. * @param maxRetries defines the maximum number of retries (3 by default)
  30645. * @param baseInterval defines the interval between retries
  30646. * @returns the strategy function to use
  30647. */
  30648. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30649. }
  30650. /**
  30651. * File request interface
  30652. */
  30653. export interface IFileRequest {
  30654. /**
  30655. * Raised when the request is complete (success or error).
  30656. */
  30657. onCompleteObservable: Observable<IFileRequest>;
  30658. /**
  30659. * Aborts the request for a file.
  30660. */
  30661. abort: () => void;
  30662. }
  30663. /**
  30664. * Class containing a set of static utilities functions
  30665. */
  30666. export class Tools {
  30667. /**
  30668. * Gets or sets the base URL to use to load assets
  30669. */
  30670. static BaseUrl: string;
  30671. /**
  30672. * Enable/Disable Custom HTTP Request Headers globally.
  30673. * default = false
  30674. * @see CustomRequestHeaders
  30675. */
  30676. static UseCustomRequestHeaders: boolean;
  30677. /**
  30678. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30679. * i.e. when loading files, where the server/service expects an Authorization header.
  30680. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30681. */
  30682. static CustomRequestHeaders: {
  30683. [key: string]: string;
  30684. };
  30685. /**
  30686. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30687. */
  30688. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30689. /**
  30690. * Default behaviour for cors in the application.
  30691. * It can be a string if the expected behavior is identical in the entire app.
  30692. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30693. */
  30694. static CorsBehavior: string | ((url: string | string[]) => string);
  30695. /**
  30696. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30697. * @ignorenaming
  30698. */
  30699. static UseFallbackTexture: boolean;
  30700. /**
  30701. * Use this object to register external classes like custom textures or material
  30702. * to allow the laoders to instantiate them
  30703. */
  30704. static RegisteredExternalClasses: {
  30705. [key: string]: Object;
  30706. };
  30707. /**
  30708. * Texture content used if a texture cannot loaded
  30709. * @ignorenaming
  30710. */
  30711. static fallbackTexture: string;
  30712. /**
  30713. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30714. * @param u defines the coordinate on X axis
  30715. * @param v defines the coordinate on Y axis
  30716. * @param width defines the width of the source data
  30717. * @param height defines the height of the source data
  30718. * @param pixels defines the source byte array
  30719. * @param color defines the output color
  30720. */
  30721. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30722. /**
  30723. * Interpolates between a and b via alpha
  30724. * @param a The lower value (returned when alpha = 0)
  30725. * @param b The upper value (returned when alpha = 1)
  30726. * @param alpha The interpolation-factor
  30727. * @return The mixed value
  30728. */
  30729. static Mix(a: number, b: number, alpha: number): number;
  30730. /**
  30731. * Tries to instantiate a new object from a given class name
  30732. * @param className defines the class name to instantiate
  30733. * @returns the new object or null if the system was not able to do the instantiation
  30734. */
  30735. static Instantiate(className: string): any;
  30736. /**
  30737. * Provides a slice function that will work even on IE
  30738. * @param data defines the array to slice
  30739. * @param start defines the start of the data (optional)
  30740. * @param end defines the end of the data (optional)
  30741. * @returns the new sliced array
  30742. */
  30743. static Slice<T>(data: T, start?: number, end?: number): T;
  30744. /**
  30745. * Polyfill for setImmediate
  30746. * @param action defines the action to execute after the current execution block
  30747. */
  30748. static SetImmediate(action: () => void): void;
  30749. /**
  30750. * Function indicating if a number is an exponent of 2
  30751. * @param value defines the value to test
  30752. * @returns true if the value is an exponent of 2
  30753. */
  30754. static IsExponentOfTwo(value: number): boolean;
  30755. private static _tmpFloatArray;
  30756. /**
  30757. * Returns the nearest 32-bit single precision float representation of a Number
  30758. * @param value A Number. If the parameter is of a different type, it will get converted
  30759. * to a number or to NaN if it cannot be converted
  30760. * @returns number
  30761. */
  30762. static FloatRound(value: number): number;
  30763. /**
  30764. * Find the next highest power of two.
  30765. * @param x Number to start search from.
  30766. * @return Next highest power of two.
  30767. */
  30768. static CeilingPOT(x: number): number;
  30769. /**
  30770. * Find the next lowest power of two.
  30771. * @param x Number to start search from.
  30772. * @return Next lowest power of two.
  30773. */
  30774. static FloorPOT(x: number): number;
  30775. /**
  30776. * Find the nearest power of two.
  30777. * @param x Number to start search from.
  30778. * @return Next nearest power of two.
  30779. */
  30780. static NearestPOT(x: number): number;
  30781. /**
  30782. * Get the closest exponent of two
  30783. * @param value defines the value to approximate
  30784. * @param max defines the maximum value to return
  30785. * @param mode defines how to define the closest value
  30786. * @returns closest exponent of two of the given value
  30787. */
  30788. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30789. /**
  30790. * Extracts the filename from a path
  30791. * @param path defines the path to use
  30792. * @returns the filename
  30793. */
  30794. static GetFilename(path: string): string;
  30795. /**
  30796. * Extracts the "folder" part of a path (everything before the filename).
  30797. * @param uri The URI to extract the info from
  30798. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30799. * @returns The "folder" part of the path
  30800. */
  30801. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30802. /**
  30803. * Extracts text content from a DOM element hierarchy
  30804. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30805. */
  30806. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30807. /**
  30808. * Convert an angle in radians to degrees
  30809. * @param angle defines the angle to convert
  30810. * @returns the angle in degrees
  30811. */
  30812. static ToDegrees(angle: number): number;
  30813. /**
  30814. * Convert an angle in degrees to radians
  30815. * @param angle defines the angle to convert
  30816. * @returns the angle in radians
  30817. */
  30818. static ToRadians(angle: number): number;
  30819. /**
  30820. * Encode a buffer to a base64 string
  30821. * @param buffer defines the buffer to encode
  30822. * @returns the encoded string
  30823. */
  30824. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30825. /**
  30826. * Extracts minimum and maximum values from a list of indexed positions
  30827. * @param positions defines the positions to use
  30828. * @param indices defines the indices to the positions
  30829. * @param indexStart defines the start index
  30830. * @param indexCount defines the end index
  30831. * @param bias defines bias value to add to the result
  30832. * @return minimum and maximum values
  30833. */
  30834. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30835. minimum: Vector3;
  30836. maximum: Vector3;
  30837. };
  30838. /**
  30839. * Extracts minimum and maximum values from a list of positions
  30840. * @param positions defines the positions to use
  30841. * @param start defines the start index in the positions array
  30842. * @param count defines the number of positions to handle
  30843. * @param bias defines bias value to add to the result
  30844. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30845. * @return minimum and maximum values
  30846. */
  30847. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30848. minimum: Vector3;
  30849. maximum: Vector3;
  30850. };
  30851. /**
  30852. * Returns an array if obj is not an array
  30853. * @param obj defines the object to evaluate as an array
  30854. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30855. * @returns either obj directly if obj is an array or a new array containing obj
  30856. */
  30857. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30858. /**
  30859. * Gets the pointer prefix to use
  30860. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30861. */
  30862. static GetPointerPrefix(): string;
  30863. /**
  30864. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30865. * @param func - the function to be called
  30866. * @param requester - the object that will request the next frame. Falls back to window.
  30867. * @returns frame number
  30868. */
  30869. static QueueNewFrame(func: () => void, requester?: any): number;
  30870. /**
  30871. * Ask the browser to promote the current element to fullscreen rendering mode
  30872. * @param element defines the DOM element to promote
  30873. */
  30874. static RequestFullscreen(element: HTMLElement): void;
  30875. /**
  30876. * Asks the browser to exit fullscreen mode
  30877. */
  30878. static ExitFullscreen(): void;
  30879. /**
  30880. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30881. * @param url define the url we are trying
  30882. * @param element define the dom element where to configure the cors policy
  30883. */
  30884. static SetCorsBehavior(url: string | string[], element: {
  30885. crossOrigin: string | null;
  30886. }): void;
  30887. /**
  30888. * Removes unwanted characters from an url
  30889. * @param url defines the url to clean
  30890. * @returns the cleaned url
  30891. */
  30892. static CleanUrl(url: string): string;
  30893. /**
  30894. * Gets or sets a function used to pre-process url before using them to load assets
  30895. */
  30896. static PreprocessUrl: (url: string) => string;
  30897. /**
  30898. * Loads an image as an HTMLImageElement.
  30899. * @param input url string, ArrayBuffer, or Blob to load
  30900. * @param onLoad callback called when the image successfully loads
  30901. * @param onError callback called when the image fails to load
  30902. * @param offlineProvider offline provider for caching
  30903. * @returns the HTMLImageElement of the loaded image
  30904. */
  30905. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30906. /**
  30907. * Loads a file
  30908. * @param url url string, ArrayBuffer, or Blob to load
  30909. * @param onSuccess callback called when the file successfully loads
  30910. * @param onProgress callback called while file is loading (if the server supports this mode)
  30911. * @param offlineProvider defines the offline provider for caching
  30912. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30913. * @param onError callback called when the file fails to load
  30914. * @returns a file request object
  30915. */
  30916. 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;
  30917. /**
  30918. * Load a script (identified by an url). When the url returns, the
  30919. * content of this file is added into a new script element, attached to the DOM (body element)
  30920. * @param scriptUrl defines the url of the script to laod
  30921. * @param onSuccess defines the callback called when the script is loaded
  30922. * @param onError defines the callback to call if an error occurs
  30923. */
  30924. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30925. /**
  30926. * Loads a file from a blob
  30927. * @param fileToLoad defines the blob to use
  30928. * @param callback defines the callback to call when data is loaded
  30929. * @param progressCallback defines the callback to call during loading process
  30930. * @returns a file request object
  30931. */
  30932. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30933. /**
  30934. * Loads a file
  30935. * @param fileToLoad defines the file to load
  30936. * @param callback defines the callback to call when data is loaded
  30937. * @param progressCallBack defines the callback to call during loading process
  30938. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30939. * @returns a file request object
  30940. */
  30941. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30942. /**
  30943. * Creates a data url from a given string content
  30944. * @param content defines the content to convert
  30945. * @returns the new data url link
  30946. */
  30947. static FileAsURL(content: string): string;
  30948. /**
  30949. * Format the given number to a specific decimal format
  30950. * @param value defines the number to format
  30951. * @param decimals defines the number of decimals to use
  30952. * @returns the formatted string
  30953. */
  30954. static Format(value: number, decimals?: number): string;
  30955. /**
  30956. * Checks if a given vector is inside a specific range
  30957. * @param v defines the vector to test
  30958. * @param min defines the minimum range
  30959. * @param max defines the maximum range
  30960. */
  30961. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30962. /**
  30963. * Tries to copy an object by duplicating every property
  30964. * @param source defines the source object
  30965. * @param destination defines the target object
  30966. * @param doNotCopyList defines a list of properties to avoid
  30967. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30968. */
  30969. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30970. /**
  30971. * Gets a boolean indicating if the given object has no own property
  30972. * @param obj defines the object to test
  30973. * @returns true if object has no own property
  30974. */
  30975. static IsEmpty(obj: any): boolean;
  30976. /**
  30977. * Function used to register events at window level
  30978. * @param events defines the events to register
  30979. */
  30980. static RegisterTopRootEvents(events: {
  30981. name: string;
  30982. handler: Nullable<(e: FocusEvent) => any>;
  30983. }[]): void;
  30984. /**
  30985. * Function used to unregister events from window level
  30986. * @param events defines the events to unregister
  30987. */
  30988. static UnregisterTopRootEvents(events: {
  30989. name: string;
  30990. handler: Nullable<(e: FocusEvent) => any>;
  30991. }[]): void;
  30992. /**
  30993. * Dumps the current bound framebuffer
  30994. * @param width defines the rendering width
  30995. * @param height defines the rendering height
  30996. * @param engine defines the hosting engine
  30997. * @param successCallback defines the callback triggered once the data are available
  30998. * @param mimeType defines the mime type of the result
  30999. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31000. */
  31001. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31002. /**
  31003. * Converts the canvas data to blob.
  31004. * This acts as a polyfill for browsers not supporting the to blob function.
  31005. * @param canvas Defines the canvas to extract the data from
  31006. * @param successCallback Defines the callback triggered once the data are available
  31007. * @param mimeType Defines the mime type of the result
  31008. */
  31009. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31010. /**
  31011. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31012. * @param successCallback defines the callback triggered once the data are available
  31013. * @param mimeType defines the mime type of the result
  31014. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31015. */
  31016. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31017. /**
  31018. * Downloads a blob in the browser
  31019. * @param blob defines the blob to download
  31020. * @param fileName defines the name of the downloaded file
  31021. */
  31022. static Download(blob: Blob, fileName: string): void;
  31023. /**
  31024. * Captures a screenshot of the current rendering
  31025. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31026. * @param engine defines the rendering engine
  31027. * @param camera defines the source camera
  31028. * @param size This parameter can be set to a single number or to an object with the
  31029. * following (optional) properties: precision, width, height. If a single number is passed,
  31030. * it will be used for both width and height. If an object is passed, the screenshot size
  31031. * will be derived from the parameters. The precision property is a multiplier allowing
  31032. * rendering at a higher or lower resolution
  31033. * @param successCallback defines the callback receives a single parameter which contains the
  31034. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31035. * src parameter of an <img> to display it
  31036. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31037. * Check your browser for supported MIME types
  31038. */
  31039. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31040. /**
  31041. * Generates an image screenshot from the specified camera.
  31042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31043. * @param engine The engine to use for rendering
  31044. * @param camera The camera to use for rendering
  31045. * @param size This parameter can be set to a single number or to an object with the
  31046. * following (optional) properties: precision, width, height. If a single number is passed,
  31047. * it will be used for both width and height. If an object is passed, the screenshot size
  31048. * will be derived from the parameters. The precision property is a multiplier allowing
  31049. * rendering at a higher or lower resolution
  31050. * @param successCallback The callback receives a single parameter which contains the
  31051. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31052. * src parameter of an <img> to display it
  31053. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31054. * Check your browser for supported MIME types
  31055. * @param samples Texture samples (default: 1)
  31056. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31057. * @param fileName A name for for the downloaded file.
  31058. */
  31059. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31060. /**
  31061. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31062. * Be aware Math.random() could cause collisions, but:
  31063. * "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"
  31064. * @returns a pseudo random id
  31065. */
  31066. static RandomId(): string;
  31067. /**
  31068. * Test if the given uri is a base64 string
  31069. * @param uri The uri to test
  31070. * @return True if the uri is a base64 string or false otherwise
  31071. */
  31072. static IsBase64(uri: string): boolean;
  31073. /**
  31074. * Decode the given base64 uri.
  31075. * @param uri The uri to decode
  31076. * @return The decoded base64 data.
  31077. */
  31078. static DecodeBase64(uri: string): ArrayBuffer;
  31079. /**
  31080. * No log
  31081. */
  31082. static readonly NoneLogLevel: number;
  31083. /**
  31084. * Only message logs
  31085. */
  31086. static readonly MessageLogLevel: number;
  31087. /**
  31088. * Only warning logs
  31089. */
  31090. static readonly WarningLogLevel: number;
  31091. /**
  31092. * Only error logs
  31093. */
  31094. static readonly ErrorLogLevel: number;
  31095. /**
  31096. * All logs
  31097. */
  31098. static readonly AllLogLevel: number;
  31099. /**
  31100. * Gets a value indicating the number of loading errors
  31101. * @ignorenaming
  31102. */
  31103. static readonly errorsCount: number;
  31104. /**
  31105. * Callback called when a new log is added
  31106. */
  31107. static OnNewCacheEntry: (entry: string) => void;
  31108. /**
  31109. * Log a message to the console
  31110. * @param message defines the message to log
  31111. */
  31112. static Log(message: string): void;
  31113. /**
  31114. * Write a warning message to the console
  31115. * @param message defines the message to log
  31116. */
  31117. static Warn(message: string): void;
  31118. /**
  31119. * Write an error message to the console
  31120. * @param message defines the message to log
  31121. */
  31122. static Error(message: string): void;
  31123. /**
  31124. * Gets current log cache (list of logs)
  31125. */
  31126. static readonly LogCache: string;
  31127. /**
  31128. * Clears the log cache
  31129. */
  31130. static ClearLogCache(): void;
  31131. /**
  31132. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31133. */
  31134. static LogLevels: number;
  31135. /**
  31136. * Checks if the loaded document was accessed via `file:`-Protocol.
  31137. * @returns boolean
  31138. */
  31139. static IsFileURL(): boolean;
  31140. /**
  31141. * Checks if the window object exists
  31142. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31143. */
  31144. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31145. /**
  31146. * No performance log
  31147. */
  31148. static readonly PerformanceNoneLogLevel: number;
  31149. /**
  31150. * Use user marks to log performance
  31151. */
  31152. static readonly PerformanceUserMarkLogLevel: number;
  31153. /**
  31154. * Log performance to the console
  31155. */
  31156. static readonly PerformanceConsoleLogLevel: number;
  31157. private static _performance;
  31158. /**
  31159. * Sets the current performance log level
  31160. */
  31161. static PerformanceLogLevel: number;
  31162. private static _StartPerformanceCounterDisabled;
  31163. private static _EndPerformanceCounterDisabled;
  31164. private static _StartUserMark;
  31165. private static _EndUserMark;
  31166. private static _StartPerformanceConsole;
  31167. private static _EndPerformanceConsole;
  31168. /**
  31169. * Injects the @see CustomRequestHeaders into the given request
  31170. * @param request the request that should be used for injection
  31171. */
  31172. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31173. /**
  31174. * Starts a performance counter
  31175. */
  31176. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31177. /**
  31178. * Ends a specific performance coutner
  31179. */
  31180. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31181. /**
  31182. * Gets either window.performance.now() if supported or Date.now() else
  31183. */
  31184. static readonly Now: number;
  31185. /**
  31186. * This method will return the name of the class used to create the instance of the given object.
  31187. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31188. * @param object the object to get the class name from
  31189. * @param isType defines if the object is actually a type
  31190. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31191. */
  31192. static GetClassName(object: any, isType?: boolean): string;
  31193. /**
  31194. * Gets the first element of an array satisfying a given predicate
  31195. * @param array defines the array to browse
  31196. * @param predicate defines the predicate to use
  31197. * @returns null if not found or the element
  31198. */
  31199. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31200. /**
  31201. * This method will return the name of the full name of the class, including its owning module (if any).
  31202. * 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).
  31203. * @param object the object to get the class name from
  31204. * @param isType defines if the object is actually a type
  31205. * @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.
  31206. * @ignorenaming
  31207. */
  31208. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31209. /**
  31210. * Returns a promise that resolves after the given amount of time.
  31211. * @param delay Number of milliseconds to delay
  31212. * @returns Promise that resolves after the given amount of time
  31213. */
  31214. static DelayAsync(delay: number): Promise<void>;
  31215. /**
  31216. * Gets the current gradient from an array of IValueGradient
  31217. * @param ratio defines the current ratio to get
  31218. * @param gradients defines the array of IValueGradient
  31219. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31220. */
  31221. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31222. }
  31223. /**
  31224. * This class is used to track a performance counter which is number based.
  31225. * The user has access to many properties which give statistics of different nature.
  31226. *
  31227. * The implementer can track two kinds of Performance Counter: time and count.
  31228. * 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.
  31229. * 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.
  31230. */
  31231. export class PerfCounter {
  31232. /**
  31233. * Gets or sets a global boolean to turn on and off all the counters
  31234. */
  31235. static Enabled: boolean;
  31236. /**
  31237. * Returns the smallest value ever
  31238. */
  31239. readonly min: number;
  31240. /**
  31241. * Returns the biggest value ever
  31242. */
  31243. readonly max: number;
  31244. /**
  31245. * Returns the average value since the performance counter is running
  31246. */
  31247. readonly average: number;
  31248. /**
  31249. * Returns the average value of the last second the counter was monitored
  31250. */
  31251. readonly lastSecAverage: number;
  31252. /**
  31253. * Returns the current value
  31254. */
  31255. readonly current: number;
  31256. /**
  31257. * Gets the accumulated total
  31258. */
  31259. readonly total: number;
  31260. /**
  31261. * Gets the total value count
  31262. */
  31263. readonly count: number;
  31264. /**
  31265. * Creates a new counter
  31266. */
  31267. constructor();
  31268. /**
  31269. * Call this method to start monitoring a new frame.
  31270. * 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.
  31271. */
  31272. fetchNewFrame(): void;
  31273. /**
  31274. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31275. * @param newCount the count value to add to the monitored count
  31276. * @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.
  31277. */
  31278. addCount(newCount: number, fetchResult: boolean): void;
  31279. /**
  31280. * Start monitoring this performance counter
  31281. */
  31282. beginMonitoring(): void;
  31283. /**
  31284. * Compute the time lapsed since the previous beginMonitoring() call.
  31285. * @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
  31286. */
  31287. endMonitoring(newFrame?: boolean): void;
  31288. private _fetchResult;
  31289. private _startMonitoringTime;
  31290. private _min;
  31291. private _max;
  31292. private _average;
  31293. private _current;
  31294. private _totalValueCount;
  31295. private _totalAccumulated;
  31296. private _lastSecAverage;
  31297. private _lastSecAccumulated;
  31298. private _lastSecTime;
  31299. private _lastSecValueCount;
  31300. }
  31301. /**
  31302. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31303. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31304. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31305. * @param name The name of the class, case should be preserved
  31306. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31307. */
  31308. export function className(name: string, module?: string): (target: Object) => void;
  31309. /**
  31310. * An implementation of a loop for asynchronous functions.
  31311. */
  31312. export class AsyncLoop {
  31313. /**
  31314. * Defines the number of iterations for the loop
  31315. */
  31316. iterations: number;
  31317. /**
  31318. * Defines the current index of the loop.
  31319. */
  31320. index: number;
  31321. private _done;
  31322. private _fn;
  31323. private _successCallback;
  31324. /**
  31325. * Constructor.
  31326. * @param iterations the number of iterations.
  31327. * @param func the function to run each iteration
  31328. * @param successCallback the callback that will be called upon succesful execution
  31329. * @param offset starting offset.
  31330. */
  31331. constructor(
  31332. /**
  31333. * Defines the number of iterations for the loop
  31334. */
  31335. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31336. /**
  31337. * Execute the next iteration. Must be called after the last iteration was finished.
  31338. */
  31339. executeNext(): void;
  31340. /**
  31341. * Break the loop and run the success callback.
  31342. */
  31343. breakLoop(): void;
  31344. /**
  31345. * Create and run an async loop.
  31346. * @param iterations the number of iterations.
  31347. * @param fn the function to run each iteration
  31348. * @param successCallback the callback that will be called upon succesful execution
  31349. * @param offset starting offset.
  31350. * @returns the created async loop object
  31351. */
  31352. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31353. /**
  31354. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31355. * @param iterations total number of iterations
  31356. * @param syncedIterations number of synchronous iterations in each async iteration.
  31357. * @param fn the function to call each iteration.
  31358. * @param callback a success call back that will be called when iterating stops.
  31359. * @param breakFunction a break condition (optional)
  31360. * @param timeout timeout settings for the setTimeout function. default - 0.
  31361. * @returns the created async loop object
  31362. */
  31363. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31364. }
  31365. }
  31366. declare module "babylonjs/Collisions/collisionCoordinator" {
  31367. import { Nullable } from "babylonjs/types";
  31368. import { Scene } from "babylonjs/scene";
  31369. import { Vector3 } from "babylonjs/Maths/math";
  31370. import { Collider } from "babylonjs/Collisions/collider";
  31371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31372. /** @hidden */
  31373. export interface ICollisionCoordinator {
  31374. createCollider(): Collider;
  31375. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31376. init(scene: Scene): void;
  31377. }
  31378. /** @hidden */
  31379. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31380. private _scene;
  31381. private _scaledPosition;
  31382. private _scaledVelocity;
  31383. private _finalPosition;
  31384. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31385. createCollider(): Collider;
  31386. init(scene: Scene): void;
  31387. private _collideWithWorld;
  31388. }
  31389. }
  31390. declare module "babylonjs/Animations/animationGroup" {
  31391. import { Animatable } from "babylonjs/Animations/animatable";
  31392. import { Animation } from "babylonjs/Animations/animation";
  31393. import { Scene, IDisposable } from "babylonjs/scene";
  31394. import { Observable } from "babylonjs/Misc/observable";
  31395. import { Nullable } from "babylonjs/types";
  31396. /**
  31397. * This class defines the direct association between an animation and a target
  31398. */
  31399. export class TargetedAnimation {
  31400. /**
  31401. * Animation to perform
  31402. */
  31403. animation: Animation;
  31404. /**
  31405. * Target to animate
  31406. */
  31407. target: any;
  31408. }
  31409. /**
  31410. * Use this class to create coordinated animations on multiple targets
  31411. */
  31412. export class AnimationGroup implements IDisposable {
  31413. /** The name of the animation group */
  31414. name: string;
  31415. private _scene;
  31416. private _targetedAnimations;
  31417. private _animatables;
  31418. private _from;
  31419. private _to;
  31420. private _isStarted;
  31421. private _isPaused;
  31422. private _speedRatio;
  31423. /**
  31424. * Gets or sets the unique id of the node
  31425. */
  31426. uniqueId: number;
  31427. /**
  31428. * This observable will notify when one animation have ended
  31429. */
  31430. onAnimationEndObservable: Observable<TargetedAnimation>;
  31431. /**
  31432. * Observer raised when one animation loops
  31433. */
  31434. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31435. /**
  31436. * This observable will notify when all animations have ended.
  31437. */
  31438. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31439. /**
  31440. * This observable will notify when all animations have paused.
  31441. */
  31442. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31443. /**
  31444. * This observable will notify when all animations are playing.
  31445. */
  31446. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31447. /**
  31448. * Gets the first frame
  31449. */
  31450. readonly from: number;
  31451. /**
  31452. * Gets the last frame
  31453. */
  31454. readonly to: number;
  31455. /**
  31456. * Define if the animations are started
  31457. */
  31458. readonly isStarted: boolean;
  31459. /**
  31460. * Gets a value indicating that the current group is playing
  31461. */
  31462. readonly isPlaying: boolean;
  31463. /**
  31464. * Gets or sets the speed ratio to use for all animations
  31465. */
  31466. /**
  31467. * Gets or sets the speed ratio to use for all animations
  31468. */
  31469. speedRatio: number;
  31470. /**
  31471. * Gets the targeted animations for this animation group
  31472. */
  31473. readonly targetedAnimations: Array<TargetedAnimation>;
  31474. /**
  31475. * returning the list of animatables controlled by this animation group.
  31476. */
  31477. readonly animatables: Array<Animatable>;
  31478. /**
  31479. * Instantiates a new Animation Group.
  31480. * This helps managing several animations at once.
  31481. * @see http://doc.babylonjs.com/how_to/group
  31482. * @param name Defines the name of the group
  31483. * @param scene Defines the scene the group belongs to
  31484. */
  31485. constructor(
  31486. /** The name of the animation group */
  31487. name: string, scene?: Nullable<Scene>);
  31488. /**
  31489. * Add an animation (with its target) in the group
  31490. * @param animation defines the animation we want to add
  31491. * @param target defines the target of the animation
  31492. * @returns the TargetedAnimation object
  31493. */
  31494. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31495. /**
  31496. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31497. * It can add constant keys at begin or end
  31498. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31499. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31500. * @returns the animation group
  31501. */
  31502. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31503. /**
  31504. * Start all animations on given targets
  31505. * @param loop defines if animations must loop
  31506. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31507. * @param from defines the from key (optional)
  31508. * @param to defines the to key (optional)
  31509. * @returns the current animation group
  31510. */
  31511. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31512. /**
  31513. * Pause all animations
  31514. * @returns the animation group
  31515. */
  31516. pause(): AnimationGroup;
  31517. /**
  31518. * Play all animations to initial state
  31519. * This function will start() the animations if they were not started or will restart() them if they were paused
  31520. * @param loop defines if animations must loop
  31521. * @returns the animation group
  31522. */
  31523. play(loop?: boolean): AnimationGroup;
  31524. /**
  31525. * Reset all animations to initial state
  31526. * @returns the animation group
  31527. */
  31528. reset(): AnimationGroup;
  31529. /**
  31530. * Restart animations from key 0
  31531. * @returns the animation group
  31532. */
  31533. restart(): AnimationGroup;
  31534. /**
  31535. * Stop all animations
  31536. * @returns the animation group
  31537. */
  31538. stop(): AnimationGroup;
  31539. /**
  31540. * Set animation weight for all animatables
  31541. * @param weight defines the weight to use
  31542. * @return the animationGroup
  31543. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31544. */
  31545. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31546. /**
  31547. * Synchronize and normalize all animatables with a source animatable
  31548. * @param root defines the root animatable to synchronize with
  31549. * @return the animationGroup
  31550. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31551. */
  31552. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31553. /**
  31554. * Goes to a specific frame in this animation group
  31555. * @param frame the frame number to go to
  31556. * @return the animationGroup
  31557. */
  31558. goToFrame(frame: number): AnimationGroup;
  31559. /**
  31560. * Dispose all associated resources
  31561. */
  31562. dispose(): void;
  31563. private _checkAnimationGroupEnded;
  31564. /**
  31565. * Clone the current animation group and returns a copy
  31566. * @param newName defines the name of the new group
  31567. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31568. * @returns the new aniamtion group
  31569. */
  31570. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31571. /**
  31572. * Returns a new AnimationGroup object parsed from the source provided.
  31573. * @param parsedAnimationGroup defines the source
  31574. * @param scene defines the scene that will receive the animationGroup
  31575. * @returns a new AnimationGroup
  31576. */
  31577. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31578. /**
  31579. * Returns the string "AnimationGroup"
  31580. * @returns "AnimationGroup"
  31581. */
  31582. getClassName(): string;
  31583. /**
  31584. * Creates a detailled string about the object
  31585. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31586. * @returns a string representing the object
  31587. */
  31588. toString(fullDetails?: boolean): string;
  31589. }
  31590. }
  31591. declare module "babylonjs/scene" {
  31592. import { Nullable } from "babylonjs/types";
  31593. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31594. import { Observable } from "babylonjs/Misc/observable";
  31595. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31596. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31597. import { Geometry } from "babylonjs/Meshes/geometry";
  31598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31601. import { Mesh } from "babylonjs/Meshes/mesh";
  31602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31603. import { Bone } from "babylonjs/Bones/bone";
  31604. import { Skeleton } from "babylonjs/Bones/skeleton";
  31605. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31606. import { Camera } from "babylonjs/Cameras/camera";
  31607. import { AbstractScene } from "babylonjs/abstractScene";
  31608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31610. import { Material } from "babylonjs/Materials/material";
  31611. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31612. import { Effect } from "babylonjs/Materials/effect";
  31613. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31614. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31615. import { Light } from "babylonjs/Lights/light";
  31616. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31617. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31618. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31619. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31620. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31621. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31622. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31623. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31624. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31625. import { Engine } from "babylonjs/Engines/engine";
  31626. import { Node } from "babylonjs/node";
  31627. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31628. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31629. import { Ray } from "babylonjs/Culling/ray";
  31630. import { Animation } from "babylonjs/Animations/animation";
  31631. import { Animatable } from "babylonjs/Animations/animatable";
  31632. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31633. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31634. import { Collider } from "babylonjs/Collisions/collider";
  31635. /**
  31636. * Define an interface for all classes that will hold resources
  31637. */
  31638. export interface IDisposable {
  31639. /**
  31640. * Releases all held resources
  31641. */
  31642. dispose(): void;
  31643. }
  31644. /** Interface defining initialization parameters for Scene class */
  31645. export interface SceneOptions {
  31646. /**
  31647. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31648. * It will improve performance when the number of geometries becomes important.
  31649. */
  31650. useGeometryUniqueIdsMap?: boolean;
  31651. /**
  31652. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31653. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31654. */
  31655. useMaterialMeshMap?: boolean;
  31656. /**
  31657. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31658. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31659. */
  31660. useClonedMeshhMap?: boolean;
  31661. }
  31662. /**
  31663. * Represents a scene to be rendered by the engine.
  31664. * @see http://doc.babylonjs.com/features/scene
  31665. */
  31666. export class Scene extends AbstractScene implements IAnimatable {
  31667. private static _uniqueIdCounter;
  31668. /** The fog is deactivated */
  31669. static readonly FOGMODE_NONE: number;
  31670. /** The fog density is following an exponential function */
  31671. static readonly FOGMODE_EXP: number;
  31672. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31673. static readonly FOGMODE_EXP2: number;
  31674. /** The fog density is following a linear function. */
  31675. static readonly FOGMODE_LINEAR: number;
  31676. /**
  31677. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31679. */
  31680. static MinDeltaTime: number;
  31681. /**
  31682. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31683. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31684. */
  31685. static MaxDeltaTime: number;
  31686. /**
  31687. * Factory used to create the default material.
  31688. * @param name The name of the material to create
  31689. * @param scene The scene to create the material for
  31690. * @returns The default material
  31691. */
  31692. static DefaultMaterialFactory(scene: Scene): Material;
  31693. /**
  31694. * Factory used to create the a collision coordinator.
  31695. * @returns The collision coordinator
  31696. */
  31697. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31698. /** @hidden */
  31699. readonly _isScene: boolean;
  31700. /**
  31701. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31702. */
  31703. autoClear: boolean;
  31704. /**
  31705. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31706. */
  31707. autoClearDepthAndStencil: boolean;
  31708. /**
  31709. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31710. */
  31711. clearColor: Color4;
  31712. /**
  31713. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31714. */
  31715. ambientColor: Color3;
  31716. /** @hidden */
  31717. _environmentBRDFTexture: BaseTexture;
  31718. /** @hidden */
  31719. protected _environmentTexture: Nullable<BaseTexture>;
  31720. /**
  31721. * Texture used in all pbr material as the reflection texture.
  31722. * As in the majority of the scene they are the same (exception for multi room and so on),
  31723. * this is easier to reference from here than from all the materials.
  31724. */
  31725. /**
  31726. * Texture used in all pbr material as the reflection texture.
  31727. * As in the majority of the scene they are the same (exception for multi room and so on),
  31728. * this is easier to set here than in all the materials.
  31729. */
  31730. environmentTexture: Nullable<BaseTexture>;
  31731. /** @hidden */
  31732. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31733. /**
  31734. * Default image processing configuration used either in the rendering
  31735. * Forward main pass or through the imageProcessingPostProcess if present.
  31736. * As in the majority of the scene they are the same (exception for multi camera),
  31737. * this is easier to reference from here than from all the materials and post process.
  31738. *
  31739. * No setter as we it is a shared configuration, you can set the values instead.
  31740. */
  31741. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31742. private _forceWireframe;
  31743. /**
  31744. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31745. */
  31746. forceWireframe: boolean;
  31747. private _forcePointsCloud;
  31748. /**
  31749. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31750. */
  31751. forcePointsCloud: boolean;
  31752. /**
  31753. * Gets or sets the active clipplane 1
  31754. */
  31755. clipPlane: Nullable<Plane>;
  31756. /**
  31757. * Gets or sets the active clipplane 2
  31758. */
  31759. clipPlane2: Nullable<Plane>;
  31760. /**
  31761. * Gets or sets the active clipplane 3
  31762. */
  31763. clipPlane3: Nullable<Plane>;
  31764. /**
  31765. * Gets or sets the active clipplane 4
  31766. */
  31767. clipPlane4: Nullable<Plane>;
  31768. /**
  31769. * Gets or sets a boolean indicating if animations are enabled
  31770. */
  31771. animationsEnabled: boolean;
  31772. private _animationPropertiesOverride;
  31773. /**
  31774. * Gets or sets the animation properties override
  31775. */
  31776. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31777. /**
  31778. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31779. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31780. */
  31781. useConstantAnimationDeltaTime: boolean;
  31782. /**
  31783. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31784. * Please note that it requires to run a ray cast through the scene on every frame
  31785. */
  31786. constantlyUpdateMeshUnderPointer: boolean;
  31787. /**
  31788. * Defines the HTML cursor to use when hovering over interactive elements
  31789. */
  31790. hoverCursor: string;
  31791. /**
  31792. * Defines the HTML default cursor to use (empty by default)
  31793. */
  31794. defaultCursor: string;
  31795. /**
  31796. * This is used to call preventDefault() on pointer down
  31797. * in order to block unwanted artifacts like system double clicks
  31798. */
  31799. preventDefaultOnPointerDown: boolean;
  31800. /**
  31801. * This is used to call preventDefault() on pointer up
  31802. * in order to block unwanted artifacts like system double clicks
  31803. */
  31804. preventDefaultOnPointerUp: boolean;
  31805. /**
  31806. * Gets or sets user defined metadata
  31807. */
  31808. metadata: any;
  31809. /**
  31810. * For internal use only. Please do not use.
  31811. */
  31812. reservedDataStore: any;
  31813. /**
  31814. * Gets the name of the plugin used to load this scene (null by default)
  31815. */
  31816. loadingPluginName: string;
  31817. /**
  31818. * Use this array to add regular expressions used to disable offline support for specific urls
  31819. */
  31820. disableOfflineSupportExceptionRules: RegExp[];
  31821. /**
  31822. * An event triggered when the scene is disposed.
  31823. */
  31824. onDisposeObservable: Observable<Scene>;
  31825. private _onDisposeObserver;
  31826. /** Sets a function to be executed when this scene is disposed. */
  31827. onDispose: () => void;
  31828. /**
  31829. * An event triggered before rendering the scene (right after animations and physics)
  31830. */
  31831. onBeforeRenderObservable: Observable<Scene>;
  31832. private _onBeforeRenderObserver;
  31833. /** Sets a function to be executed before rendering this scene */
  31834. beforeRender: Nullable<() => void>;
  31835. /**
  31836. * An event triggered after rendering the scene
  31837. */
  31838. onAfterRenderObservable: Observable<Scene>;
  31839. private _onAfterRenderObserver;
  31840. /** Sets a function to be executed after rendering this scene */
  31841. afterRender: Nullable<() => void>;
  31842. /**
  31843. * An event triggered before animating the scene
  31844. */
  31845. onBeforeAnimationsObservable: Observable<Scene>;
  31846. /**
  31847. * An event triggered after animations processing
  31848. */
  31849. onAfterAnimationsObservable: Observable<Scene>;
  31850. /**
  31851. * An event triggered before draw calls are ready to be sent
  31852. */
  31853. onBeforeDrawPhaseObservable: Observable<Scene>;
  31854. /**
  31855. * An event triggered after draw calls have been sent
  31856. */
  31857. onAfterDrawPhaseObservable: Observable<Scene>;
  31858. /**
  31859. * An event triggered when the scene is ready
  31860. */
  31861. onReadyObservable: Observable<Scene>;
  31862. /**
  31863. * An event triggered before rendering a camera
  31864. */
  31865. onBeforeCameraRenderObservable: Observable<Camera>;
  31866. private _onBeforeCameraRenderObserver;
  31867. /** Sets a function to be executed before rendering a camera*/
  31868. beforeCameraRender: () => void;
  31869. /**
  31870. * An event triggered after rendering a camera
  31871. */
  31872. onAfterCameraRenderObservable: Observable<Camera>;
  31873. private _onAfterCameraRenderObserver;
  31874. /** Sets a function to be executed after rendering a camera*/
  31875. afterCameraRender: () => void;
  31876. /**
  31877. * An event triggered when active meshes evaluation is about to start
  31878. */
  31879. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31880. /**
  31881. * An event triggered when active meshes evaluation is done
  31882. */
  31883. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31884. /**
  31885. * An event triggered when particles rendering is about to start
  31886. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31887. */
  31888. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31889. /**
  31890. * An event triggered when particles rendering is done
  31891. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31892. */
  31893. onAfterParticlesRenderingObservable: Observable<Scene>;
  31894. /**
  31895. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31896. */
  31897. onDataLoadedObservable: Observable<Scene>;
  31898. /**
  31899. * An event triggered when a camera is created
  31900. */
  31901. onNewCameraAddedObservable: Observable<Camera>;
  31902. /**
  31903. * An event triggered when a camera is removed
  31904. */
  31905. onCameraRemovedObservable: Observable<Camera>;
  31906. /**
  31907. * An event triggered when a light is created
  31908. */
  31909. onNewLightAddedObservable: Observable<Light>;
  31910. /**
  31911. * An event triggered when a light is removed
  31912. */
  31913. onLightRemovedObservable: Observable<Light>;
  31914. /**
  31915. * An event triggered when a geometry is created
  31916. */
  31917. onNewGeometryAddedObservable: Observable<Geometry>;
  31918. /**
  31919. * An event triggered when a geometry is removed
  31920. */
  31921. onGeometryRemovedObservable: Observable<Geometry>;
  31922. /**
  31923. * An event triggered when a transform node is created
  31924. */
  31925. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31926. /**
  31927. * An event triggered when a transform node is removed
  31928. */
  31929. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31930. /**
  31931. * An event triggered when a mesh is created
  31932. */
  31933. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31934. /**
  31935. * An event triggered when a mesh is removed
  31936. */
  31937. onMeshRemovedObservable: Observable<AbstractMesh>;
  31938. /**
  31939. * An event triggered when a material is created
  31940. */
  31941. onNewMaterialAddedObservable: Observable<Material>;
  31942. /**
  31943. * An event triggered when a material is removed
  31944. */
  31945. onMaterialRemovedObservable: Observable<Material>;
  31946. /**
  31947. * An event triggered when a texture is created
  31948. */
  31949. onNewTextureAddedObservable: Observable<BaseTexture>;
  31950. /**
  31951. * An event triggered when a texture is removed
  31952. */
  31953. onTextureRemovedObservable: Observable<BaseTexture>;
  31954. /**
  31955. * An event triggered when render targets are about to be rendered
  31956. * Can happen multiple times per frame.
  31957. */
  31958. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31959. /**
  31960. * An event triggered when render targets were rendered.
  31961. * Can happen multiple times per frame.
  31962. */
  31963. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31964. /**
  31965. * An event triggered before calculating deterministic simulation step
  31966. */
  31967. onBeforeStepObservable: Observable<Scene>;
  31968. /**
  31969. * An event triggered after calculating deterministic simulation step
  31970. */
  31971. onAfterStepObservable: Observable<Scene>;
  31972. /**
  31973. * An event triggered when the activeCamera property is updated
  31974. */
  31975. onActiveCameraChanged: Observable<Scene>;
  31976. /**
  31977. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31979. * 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)
  31980. */
  31981. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31982. /**
  31983. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31984. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31985. * 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)
  31986. */
  31987. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31988. /**
  31989. * This Observable will when a mesh has been imported into the scene.
  31990. */
  31991. onMeshImportedObservable: Observable<AbstractMesh>;
  31992. /** @hidden */
  31993. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31994. /**
  31995. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31996. */
  31997. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31998. /**
  31999. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32000. */
  32001. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32002. /**
  32003. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32004. */
  32005. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32006. private _onPointerMove;
  32007. private _onPointerDown;
  32008. private _onPointerUp;
  32009. /** Callback called when a pointer move is detected */
  32010. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32011. /** Callback called when a pointer down is detected */
  32012. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32013. /** Callback called when a pointer up is detected */
  32014. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32015. /** Callback called when a pointer pick is detected */
  32016. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32017. /**
  32018. * 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).
  32019. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32020. */
  32021. onPrePointerObservable: Observable<PointerInfoPre>;
  32022. /**
  32023. * Observable event triggered each time an input event is received from the rendering canvas
  32024. */
  32025. onPointerObservable: Observable<PointerInfo>;
  32026. /**
  32027. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32028. */
  32029. readonly unTranslatedPointer: Vector2;
  32030. /** The distance in pixel that you have to move to prevent some events */
  32031. static DragMovementThreshold: number;
  32032. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32033. static LongPressDelay: number;
  32034. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32035. static DoubleClickDelay: number;
  32036. /** If you need to check double click without raising a single click at first click, enable this flag */
  32037. static ExclusiveDoubleClickMode: boolean;
  32038. private _initClickEvent;
  32039. private _initActionManager;
  32040. private _delayedSimpleClick;
  32041. private _delayedSimpleClickTimeout;
  32042. private _previousDelayedSimpleClickTimeout;
  32043. private _meshPickProceed;
  32044. private _previousButtonPressed;
  32045. private _currentPickResult;
  32046. private _previousPickResult;
  32047. private _totalPointersPressed;
  32048. private _doubleClickOccured;
  32049. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32050. cameraToUseForPointers: Nullable<Camera>;
  32051. private _pointerX;
  32052. private _pointerY;
  32053. private _unTranslatedPointerX;
  32054. private _unTranslatedPointerY;
  32055. private _startingPointerPosition;
  32056. private _previousStartingPointerPosition;
  32057. private _startingPointerTime;
  32058. private _previousStartingPointerTime;
  32059. private _pointerCaptures;
  32060. private _timeAccumulator;
  32061. private _currentStepId;
  32062. private _currentInternalStep;
  32063. /** @hidden */
  32064. _mirroredCameraPosition: Nullable<Vector3>;
  32065. /**
  32066. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32067. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32068. */
  32069. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32070. /**
  32071. * Observable event triggered each time an keyboard event is received from the hosting window
  32072. */
  32073. onKeyboardObservable: Observable<KeyboardInfo>;
  32074. private _onKeyDown;
  32075. private _onKeyUp;
  32076. private _onCanvasFocusObserver;
  32077. private _onCanvasBlurObserver;
  32078. private _useRightHandedSystem;
  32079. /**
  32080. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32081. */
  32082. useRightHandedSystem: boolean;
  32083. /**
  32084. * Sets the step Id used by deterministic lock step
  32085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32086. * @param newStepId defines the step Id
  32087. */
  32088. setStepId(newStepId: number): void;
  32089. /**
  32090. * Gets the step Id used by deterministic lock step
  32091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32092. * @returns the step Id
  32093. */
  32094. getStepId(): number;
  32095. /**
  32096. * Gets the internal step used by deterministic lock step
  32097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32098. * @returns the internal step
  32099. */
  32100. getInternalStep(): number;
  32101. private _fogEnabled;
  32102. /**
  32103. * Gets or sets a boolean indicating if fog is enabled on this scene
  32104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32105. * (Default is true)
  32106. */
  32107. fogEnabled: boolean;
  32108. private _fogMode;
  32109. /**
  32110. * Gets or sets the fog mode to use
  32111. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32112. * | mode | value |
  32113. * | --- | --- |
  32114. * | FOGMODE_NONE | 0 |
  32115. * | FOGMODE_EXP | 1 |
  32116. * | FOGMODE_EXP2 | 2 |
  32117. * | FOGMODE_LINEAR | 3 |
  32118. */
  32119. fogMode: number;
  32120. /**
  32121. * Gets or sets the fog color to use
  32122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32123. * (Default is Color3(0.2, 0.2, 0.3))
  32124. */
  32125. fogColor: Color3;
  32126. /**
  32127. * Gets or sets the fog density to use
  32128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32129. * (Default is 0.1)
  32130. */
  32131. fogDensity: number;
  32132. /**
  32133. * Gets or sets the fog start distance to use
  32134. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32135. * (Default is 0)
  32136. */
  32137. fogStart: number;
  32138. /**
  32139. * Gets or sets the fog end distance to use
  32140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32141. * (Default is 1000)
  32142. */
  32143. fogEnd: number;
  32144. private _shadowsEnabled;
  32145. /**
  32146. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32147. */
  32148. shadowsEnabled: boolean;
  32149. private _lightsEnabled;
  32150. /**
  32151. * Gets or sets a boolean indicating if lights are enabled on this scene
  32152. */
  32153. lightsEnabled: boolean;
  32154. /** All of the active cameras added to this scene. */
  32155. activeCameras: Camera[];
  32156. private _activeCamera;
  32157. /** Gets or sets the current active camera */
  32158. activeCamera: Nullable<Camera>;
  32159. private _defaultMaterial;
  32160. /** The default material used on meshes when no material is affected */
  32161. /** The default material used on meshes when no material is affected */
  32162. defaultMaterial: Material;
  32163. private _texturesEnabled;
  32164. /**
  32165. * Gets or sets a boolean indicating if textures are enabled on this scene
  32166. */
  32167. texturesEnabled: boolean;
  32168. /**
  32169. * Gets or sets a boolean indicating if particles are enabled on this scene
  32170. */
  32171. particlesEnabled: boolean;
  32172. /**
  32173. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32174. */
  32175. spritesEnabled: boolean;
  32176. private _skeletonsEnabled;
  32177. /**
  32178. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32179. */
  32180. skeletonsEnabled: boolean;
  32181. /**
  32182. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32183. */
  32184. lensFlaresEnabled: boolean;
  32185. /**
  32186. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32188. */
  32189. collisionsEnabled: boolean;
  32190. private _collisionCoordinator;
  32191. /** @hidden */
  32192. readonly collisionCoordinator: ICollisionCoordinator;
  32193. /**
  32194. * Defines the gravity applied to this scene (used only for collisions)
  32195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32196. */
  32197. gravity: Vector3;
  32198. /**
  32199. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32200. */
  32201. postProcessesEnabled: boolean;
  32202. /**
  32203. * The list of postprocesses added to the scene
  32204. */
  32205. postProcesses: PostProcess[];
  32206. /**
  32207. * Gets the current postprocess manager
  32208. */
  32209. postProcessManager: PostProcessManager;
  32210. /**
  32211. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32212. */
  32213. renderTargetsEnabled: boolean;
  32214. /**
  32215. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32216. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32217. */
  32218. dumpNextRenderTargets: boolean;
  32219. /**
  32220. * The list of user defined render targets added to the scene
  32221. */
  32222. customRenderTargets: RenderTargetTexture[];
  32223. /**
  32224. * Defines if texture loading must be delayed
  32225. * If true, textures will only be loaded when they need to be rendered
  32226. */
  32227. useDelayedTextureLoading: boolean;
  32228. /**
  32229. * Gets the list of meshes imported to the scene through SceneLoader
  32230. */
  32231. importedMeshesFiles: String[];
  32232. /**
  32233. * Gets or sets a boolean indicating if probes are enabled on this scene
  32234. */
  32235. probesEnabled: boolean;
  32236. /**
  32237. * Gets or sets the current offline provider to use to store scene data
  32238. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32239. */
  32240. offlineProvider: IOfflineProvider;
  32241. /**
  32242. * Gets or sets the action manager associated with the scene
  32243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32244. */
  32245. actionManager: AbstractActionManager;
  32246. private _meshesForIntersections;
  32247. /**
  32248. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32249. */
  32250. proceduralTexturesEnabled: boolean;
  32251. private _engine;
  32252. private _totalVertices;
  32253. /** @hidden */
  32254. _activeIndices: PerfCounter;
  32255. /** @hidden */
  32256. _activeParticles: PerfCounter;
  32257. /** @hidden */
  32258. _activeBones: PerfCounter;
  32259. private _animationRatio;
  32260. /** @hidden */
  32261. _animationTimeLast: number;
  32262. /** @hidden */
  32263. _animationTime: number;
  32264. /**
  32265. * Gets or sets a general scale for animation speed
  32266. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32267. */
  32268. animationTimeScale: number;
  32269. /** @hidden */
  32270. _cachedMaterial: Nullable<Material>;
  32271. /** @hidden */
  32272. _cachedEffect: Nullable<Effect>;
  32273. /** @hidden */
  32274. _cachedVisibility: Nullable<number>;
  32275. private _renderId;
  32276. private _frameId;
  32277. private _executeWhenReadyTimeoutId;
  32278. private _intermediateRendering;
  32279. private _viewUpdateFlag;
  32280. private _projectionUpdateFlag;
  32281. private _alternateViewUpdateFlag;
  32282. private _alternateProjectionUpdateFlag;
  32283. /** @hidden */
  32284. _toBeDisposed: Nullable<IDisposable>[];
  32285. private _activeRequests;
  32286. /** @hidden */
  32287. _pendingData: any[];
  32288. private _isDisposed;
  32289. /**
  32290. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32291. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32292. */
  32293. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32294. private _activeMeshes;
  32295. private _processedMaterials;
  32296. private _renderTargets;
  32297. /** @hidden */
  32298. _activeParticleSystems: SmartArray<IParticleSystem>;
  32299. private _activeSkeletons;
  32300. private _softwareSkinnedMeshes;
  32301. private _renderingManager;
  32302. /** @hidden */
  32303. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32304. private _transformMatrix;
  32305. private _sceneUbo;
  32306. private _alternateSceneUbo;
  32307. private _viewMatrix;
  32308. private _projectionMatrix;
  32309. private _alternateViewMatrix;
  32310. private _alternateProjectionMatrix;
  32311. private _alternateTransformMatrix;
  32312. private _useAlternateCameraConfiguration;
  32313. private _alternateRendering;
  32314. private _wheelEventName;
  32315. /** @hidden */
  32316. _forcedViewPosition: Nullable<Vector3>;
  32317. /** @hidden */
  32318. readonly _isAlternateRenderingEnabled: boolean;
  32319. private _frustumPlanes;
  32320. /**
  32321. * Gets the list of frustum planes (built from the active camera)
  32322. */
  32323. readonly frustumPlanes: Plane[];
  32324. /**
  32325. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32326. * This is useful if there are more lights that the maximum simulteanous authorized
  32327. */
  32328. requireLightSorting: boolean;
  32329. /** @hidden */
  32330. readonly useMaterialMeshMap: boolean;
  32331. /** @hidden */
  32332. readonly useClonedMeshhMap: boolean;
  32333. private _pointerOverMesh;
  32334. private _pickedDownMesh;
  32335. private _pickedUpMesh;
  32336. private _externalData;
  32337. private _uid;
  32338. /**
  32339. * @hidden
  32340. * Backing store of defined scene components.
  32341. */
  32342. _components: ISceneComponent[];
  32343. /**
  32344. * @hidden
  32345. * Backing store of defined scene components.
  32346. */
  32347. _serializableComponents: ISceneSerializableComponent[];
  32348. /**
  32349. * List of components to register on the next registration step.
  32350. */
  32351. private _transientComponents;
  32352. /**
  32353. * Registers the transient components if needed.
  32354. */
  32355. private _registerTransientComponents;
  32356. /**
  32357. * @hidden
  32358. * Add a component to the scene.
  32359. * Note that the ccomponent could be registered on th next frame if this is called after
  32360. * the register component stage.
  32361. * @param component Defines the component to add to the scene
  32362. */
  32363. _addComponent(component: ISceneComponent): void;
  32364. /**
  32365. * @hidden
  32366. * Gets a component from the scene.
  32367. * @param name defines the name of the component to retrieve
  32368. * @returns the component or null if not present
  32369. */
  32370. _getComponent(name: string): Nullable<ISceneComponent>;
  32371. /**
  32372. * @hidden
  32373. * Defines the actions happening before camera updates.
  32374. */
  32375. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening before clear the canvas.
  32379. */
  32380. _beforeClearStage: Stage<SimpleStageAction>;
  32381. /**
  32382. * @hidden
  32383. * Defines the actions when collecting render targets for the frame.
  32384. */
  32385. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32386. /**
  32387. * @hidden
  32388. * Defines the actions happening for one camera in the frame.
  32389. */
  32390. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32391. /**
  32392. * @hidden
  32393. * Defines the actions happening during the per mesh ready checks.
  32394. */
  32395. _isReadyForMeshStage: Stage<MeshStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening before evaluate active mesh checks.
  32399. */
  32400. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32401. /**
  32402. * @hidden
  32403. * Defines the actions happening during the evaluate sub mesh checks.
  32404. */
  32405. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32406. /**
  32407. * @hidden
  32408. * Defines the actions happening during the active mesh stage.
  32409. */
  32410. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32411. /**
  32412. * @hidden
  32413. * Defines the actions happening during the per camera render target step.
  32414. */
  32415. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32416. /**
  32417. * @hidden
  32418. * Defines the actions happening just before the active camera is drawing.
  32419. */
  32420. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32421. /**
  32422. * @hidden
  32423. * Defines the actions happening just before a render target is drawing.
  32424. */
  32425. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32426. /**
  32427. * @hidden
  32428. * Defines the actions happening just before a rendering group is drawing.
  32429. */
  32430. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32431. /**
  32432. * @hidden
  32433. * Defines the actions happening just before a mesh is drawing.
  32434. */
  32435. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32436. /**
  32437. * @hidden
  32438. * Defines the actions happening just after a mesh has been drawn.
  32439. */
  32440. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32441. /**
  32442. * @hidden
  32443. * Defines the actions happening just after a rendering group has been drawn.
  32444. */
  32445. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32446. /**
  32447. * @hidden
  32448. * Defines the actions happening just after the active camera has been drawn.
  32449. */
  32450. _afterCameraDrawStage: Stage<CameraStageAction>;
  32451. /**
  32452. * @hidden
  32453. * Defines the actions happening just after a render target has been drawn.
  32454. */
  32455. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32456. /**
  32457. * @hidden
  32458. * Defines the actions happening just after rendering all cameras and computing intersections.
  32459. */
  32460. _afterRenderStage: Stage<SimpleStageAction>;
  32461. /**
  32462. * @hidden
  32463. * Defines the actions happening when a pointer move event happens.
  32464. */
  32465. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32466. /**
  32467. * @hidden
  32468. * Defines the actions happening when a pointer down event happens.
  32469. */
  32470. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32471. /**
  32472. * @hidden
  32473. * Defines the actions happening when a pointer up event happens.
  32474. */
  32475. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32476. /**
  32477. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32478. */
  32479. private geometriesByUniqueId;
  32480. /**
  32481. * Creates a new Scene
  32482. * @param engine defines the engine to use to render this scene
  32483. * @param options defines the scene options
  32484. */
  32485. constructor(engine: Engine, options?: SceneOptions);
  32486. private _defaultMeshCandidates;
  32487. /**
  32488. * @hidden
  32489. */
  32490. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32491. private _defaultSubMeshCandidates;
  32492. /**
  32493. * @hidden
  32494. */
  32495. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32496. /**
  32497. * Sets the default candidate providers for the scene.
  32498. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32499. * and getCollidingSubMeshCandidates to their default function
  32500. */
  32501. setDefaultCandidateProviders(): void;
  32502. /**
  32503. * Gets the mesh that is currently under the pointer
  32504. */
  32505. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32506. /**
  32507. * Gets or sets the current on-screen X position of the pointer
  32508. */
  32509. pointerX: number;
  32510. /**
  32511. * Gets or sets the current on-screen Y position of the pointer
  32512. */
  32513. pointerY: number;
  32514. /**
  32515. * Gets the cached material (ie. the latest rendered one)
  32516. * @returns the cached material
  32517. */
  32518. getCachedMaterial(): Nullable<Material>;
  32519. /**
  32520. * Gets the cached effect (ie. the latest rendered one)
  32521. * @returns the cached effect
  32522. */
  32523. getCachedEffect(): Nullable<Effect>;
  32524. /**
  32525. * Gets the cached visibility state (ie. the latest rendered one)
  32526. * @returns the cached visibility state
  32527. */
  32528. getCachedVisibility(): Nullable<number>;
  32529. /**
  32530. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32531. * @param material defines the current material
  32532. * @param effect defines the current effect
  32533. * @param visibility defines the current visibility state
  32534. * @returns true if one parameter is not cached
  32535. */
  32536. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32537. /**
  32538. * Gets the engine associated with the scene
  32539. * @returns an Engine
  32540. */
  32541. getEngine(): Engine;
  32542. /**
  32543. * Gets the total number of vertices rendered per frame
  32544. * @returns the total number of vertices rendered per frame
  32545. */
  32546. getTotalVertices(): number;
  32547. /**
  32548. * Gets the performance counter for total vertices
  32549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32550. */
  32551. readonly totalVerticesPerfCounter: PerfCounter;
  32552. /**
  32553. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32554. * @returns the total number of active indices rendered per frame
  32555. */
  32556. getActiveIndices(): number;
  32557. /**
  32558. * Gets the performance counter for active indices
  32559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32560. */
  32561. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32562. /**
  32563. * Gets the total number of active particles rendered per frame
  32564. * @returns the total number of active particles rendered per frame
  32565. */
  32566. getActiveParticles(): number;
  32567. /**
  32568. * Gets the performance counter for active particles
  32569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32570. */
  32571. readonly activeParticlesPerfCounter: PerfCounter;
  32572. /**
  32573. * Gets the total number of active bones rendered per frame
  32574. * @returns the total number of active bones rendered per frame
  32575. */
  32576. getActiveBones(): number;
  32577. /**
  32578. * Gets the performance counter for active bones
  32579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32580. */
  32581. readonly activeBonesPerfCounter: PerfCounter;
  32582. /**
  32583. * Gets the array of active meshes
  32584. * @returns an array of AbstractMesh
  32585. */
  32586. getActiveMeshes(): SmartArray<AbstractMesh>;
  32587. /**
  32588. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32589. * @returns a number
  32590. */
  32591. getAnimationRatio(): number;
  32592. /**
  32593. * Gets an unique Id for the current render phase
  32594. * @returns a number
  32595. */
  32596. getRenderId(): number;
  32597. /**
  32598. * Gets an unique Id for the current frame
  32599. * @returns a number
  32600. */
  32601. getFrameId(): number;
  32602. /** Call this function if you want to manually increment the render Id*/
  32603. incrementRenderId(): void;
  32604. private _updatePointerPosition;
  32605. private _createUbo;
  32606. private _createAlternateUbo;
  32607. private _setRayOnPointerInfo;
  32608. /**
  32609. * Use this method to simulate a pointer move on a mesh
  32610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32613. * @returns the current scene
  32614. */
  32615. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32616. private _processPointerMove;
  32617. private _checkPrePointerObservable;
  32618. /**
  32619. * Use this method to simulate a pointer down on a mesh
  32620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32623. * @returns the current scene
  32624. */
  32625. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32626. private _processPointerDown;
  32627. /**
  32628. * Use this method to simulate a pointer up on a mesh
  32629. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32630. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32631. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32632. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32633. * @returns the current scene
  32634. */
  32635. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32636. private _processPointerUp;
  32637. /**
  32638. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32639. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32640. * @returns true if the pointer was captured
  32641. */
  32642. isPointerCaptured(pointerId?: number): boolean;
  32643. /** @hidden */
  32644. _isPointerSwiping(): boolean;
  32645. /**
  32646. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32647. * @param attachUp defines if you want to attach events to pointerup
  32648. * @param attachDown defines if you want to attach events to pointerdown
  32649. * @param attachMove defines if you want to attach events to pointermove
  32650. */
  32651. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32652. /** Detaches all event handlers*/
  32653. detachControl(): void;
  32654. /**
  32655. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32656. * Delay loaded resources are not taking in account
  32657. * @return true if all required resources are ready
  32658. */
  32659. isReady(): boolean;
  32660. /** Resets all cached information relative to material (including effect and visibility) */
  32661. resetCachedMaterial(): void;
  32662. /**
  32663. * Registers a function to be called before every frame render
  32664. * @param func defines the function to register
  32665. */
  32666. registerBeforeRender(func: () => void): void;
  32667. /**
  32668. * Unregisters a function called before every frame render
  32669. * @param func defines the function to unregister
  32670. */
  32671. unregisterBeforeRender(func: () => void): void;
  32672. /**
  32673. * Registers a function to be called after every frame render
  32674. * @param func defines the function to register
  32675. */
  32676. registerAfterRender(func: () => void): void;
  32677. /**
  32678. * Unregisters a function called after every frame render
  32679. * @param func defines the function to unregister
  32680. */
  32681. unregisterAfterRender(func: () => void): void;
  32682. private _executeOnceBeforeRender;
  32683. /**
  32684. * The provided function will run before render once and will be disposed afterwards.
  32685. * A timeout delay can be provided so that the function will be executed in N ms.
  32686. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32687. * @param func The function to be executed.
  32688. * @param timeout optional delay in ms
  32689. */
  32690. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32691. /** @hidden */
  32692. _addPendingData(data: any): void;
  32693. /** @hidden */
  32694. _removePendingData(data: any): void;
  32695. /**
  32696. * Returns the number of items waiting to be loaded
  32697. * @returns the number of items waiting to be loaded
  32698. */
  32699. getWaitingItemsCount(): number;
  32700. /**
  32701. * Returns a boolean indicating if the scene is still loading data
  32702. */
  32703. readonly isLoading: boolean;
  32704. /**
  32705. * Registers a function to be executed when the scene is ready
  32706. * @param {Function} func - the function to be executed
  32707. */
  32708. executeWhenReady(func: () => void): void;
  32709. /**
  32710. * Returns a promise that resolves when the scene is ready
  32711. * @returns A promise that resolves when the scene is ready
  32712. */
  32713. whenReadyAsync(): Promise<void>;
  32714. /** @hidden */
  32715. _checkIsReady(): void;
  32716. /**
  32717. * Gets all animatable attached to the scene
  32718. */
  32719. readonly animatables: Animatable[];
  32720. /**
  32721. * Resets the last animation time frame.
  32722. * Useful to override when animations start running when loading a scene for the first time.
  32723. */
  32724. resetLastAnimationTimeFrame(): void;
  32725. /** @hidden */
  32726. _switchToAlternateCameraConfiguration(active: boolean): void;
  32727. /**
  32728. * Gets the current view matrix
  32729. * @returns a Matrix
  32730. */
  32731. getViewMatrix(): Matrix;
  32732. /**
  32733. * Gets the current projection matrix
  32734. * @returns a Matrix
  32735. */
  32736. getProjectionMatrix(): Matrix;
  32737. /**
  32738. * Gets the current transform matrix
  32739. * @returns a Matrix made of View * Projection
  32740. */
  32741. getTransformMatrix(): Matrix;
  32742. /**
  32743. * Sets the current transform matrix
  32744. * @param view defines the View matrix to use
  32745. * @param projection defines the Projection matrix to use
  32746. */
  32747. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32748. /** @hidden */
  32749. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32750. /**
  32751. * Gets the uniform buffer used to store scene data
  32752. * @returns a UniformBuffer
  32753. */
  32754. getSceneUniformBuffer(): UniformBuffer;
  32755. /**
  32756. * Gets an unique (relatively to the current scene) Id
  32757. * @returns an unique number for the scene
  32758. */
  32759. getUniqueId(): number;
  32760. /**
  32761. * Add a mesh to the list of scene's meshes
  32762. * @param newMesh defines the mesh to add
  32763. * @param recursive if all child meshes should also be added to the scene
  32764. */
  32765. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32766. /**
  32767. * Remove a mesh for the list of scene's meshes
  32768. * @param toRemove defines the mesh to remove
  32769. * @param recursive if all child meshes should also be removed from the scene
  32770. * @returns the index where the mesh was in the mesh list
  32771. */
  32772. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32773. /**
  32774. * Add a transform node to the list of scene's transform nodes
  32775. * @param newTransformNode defines the transform node to add
  32776. */
  32777. addTransformNode(newTransformNode: TransformNode): void;
  32778. /**
  32779. * Remove a transform node for the list of scene's transform nodes
  32780. * @param toRemove defines the transform node to remove
  32781. * @returns the index where the transform node was in the transform node list
  32782. */
  32783. removeTransformNode(toRemove: TransformNode): number;
  32784. /**
  32785. * Remove a skeleton for the list of scene's skeletons
  32786. * @param toRemove defines the skeleton to remove
  32787. * @returns the index where the skeleton was in the skeleton list
  32788. */
  32789. removeSkeleton(toRemove: Skeleton): number;
  32790. /**
  32791. * Remove a morph target for the list of scene's morph targets
  32792. * @param toRemove defines the morph target to remove
  32793. * @returns the index where the morph target was in the morph target list
  32794. */
  32795. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32796. /**
  32797. * Remove a light for the list of scene's lights
  32798. * @param toRemove defines the light to remove
  32799. * @returns the index where the light was in the light list
  32800. */
  32801. removeLight(toRemove: Light): number;
  32802. /**
  32803. * Remove a camera for the list of scene's cameras
  32804. * @param toRemove defines the camera to remove
  32805. * @returns the index where the camera was in the camera list
  32806. */
  32807. removeCamera(toRemove: Camera): number;
  32808. /**
  32809. * Remove a particle system for the list of scene's particle systems
  32810. * @param toRemove defines the particle system to remove
  32811. * @returns the index where the particle system was in the particle system list
  32812. */
  32813. removeParticleSystem(toRemove: IParticleSystem): number;
  32814. /**
  32815. * Remove a animation for the list of scene's animations
  32816. * @param toRemove defines the animation to remove
  32817. * @returns the index where the animation was in the animation list
  32818. */
  32819. removeAnimation(toRemove: Animation): number;
  32820. /**
  32821. * Removes the given animation group from this scene.
  32822. * @param toRemove The animation group to remove
  32823. * @returns The index of the removed animation group
  32824. */
  32825. removeAnimationGroup(toRemove: AnimationGroup): number;
  32826. /**
  32827. * Removes the given multi-material from this scene.
  32828. * @param toRemove The multi-material to remove
  32829. * @returns The index of the removed multi-material
  32830. */
  32831. removeMultiMaterial(toRemove: MultiMaterial): number;
  32832. /**
  32833. * Removes the given material from this scene.
  32834. * @param toRemove The material to remove
  32835. * @returns The index of the removed material
  32836. */
  32837. removeMaterial(toRemove: Material): number;
  32838. /**
  32839. * Removes the given action manager from this scene.
  32840. * @param toRemove The action manager to remove
  32841. * @returns The index of the removed action manager
  32842. */
  32843. removeActionManager(toRemove: AbstractActionManager): number;
  32844. /**
  32845. * Removes the given texture from this scene.
  32846. * @param toRemove The texture to remove
  32847. * @returns The index of the removed texture
  32848. */
  32849. removeTexture(toRemove: BaseTexture): number;
  32850. /**
  32851. * Adds the given light to this scene
  32852. * @param newLight The light to add
  32853. */
  32854. addLight(newLight: Light): void;
  32855. /**
  32856. * Sorts the list list based on light priorities
  32857. */
  32858. sortLightsByPriority(): void;
  32859. /**
  32860. * Adds the given camera to this scene
  32861. * @param newCamera The camera to add
  32862. */
  32863. addCamera(newCamera: Camera): void;
  32864. /**
  32865. * Adds the given skeleton to this scene
  32866. * @param newSkeleton The skeleton to add
  32867. */
  32868. addSkeleton(newSkeleton: Skeleton): void;
  32869. /**
  32870. * Adds the given particle system to this scene
  32871. * @param newParticleSystem The particle system to add
  32872. */
  32873. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32874. /**
  32875. * Adds the given animation to this scene
  32876. * @param newAnimation The animation to add
  32877. */
  32878. addAnimation(newAnimation: Animation): void;
  32879. /**
  32880. * Adds the given animation group to this scene.
  32881. * @param newAnimationGroup The animation group to add
  32882. */
  32883. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32884. /**
  32885. * Adds the given multi-material to this scene
  32886. * @param newMultiMaterial The multi-material to add
  32887. */
  32888. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32889. /**
  32890. * Adds the given material to this scene
  32891. * @param newMaterial The material to add
  32892. */
  32893. addMaterial(newMaterial: Material): void;
  32894. /**
  32895. * Adds the given morph target to this scene
  32896. * @param newMorphTargetManager The morph target to add
  32897. */
  32898. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32899. /**
  32900. * Adds the given geometry to this scene
  32901. * @param newGeometry The geometry to add
  32902. */
  32903. addGeometry(newGeometry: Geometry): void;
  32904. /**
  32905. * Adds the given action manager to this scene
  32906. * @param newActionManager The action manager to add
  32907. */
  32908. addActionManager(newActionManager: AbstractActionManager): void;
  32909. /**
  32910. * Adds the given texture to this scene.
  32911. * @param newTexture The texture to add
  32912. */
  32913. addTexture(newTexture: BaseTexture): void;
  32914. /**
  32915. * Switch active camera
  32916. * @param newCamera defines the new active camera
  32917. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32918. */
  32919. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32920. /**
  32921. * sets the active camera of the scene using its ID
  32922. * @param id defines the camera's ID
  32923. * @return the new active camera or null if none found.
  32924. */
  32925. setActiveCameraByID(id: string): Nullable<Camera>;
  32926. /**
  32927. * sets the active camera of the scene using its name
  32928. * @param name defines the camera's name
  32929. * @returns the new active camera or null if none found.
  32930. */
  32931. setActiveCameraByName(name: string): Nullable<Camera>;
  32932. /**
  32933. * get an animation group using its name
  32934. * @param name defines the material's name
  32935. * @return the animation group or null if none found.
  32936. */
  32937. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32938. /**
  32939. * get a material using its id
  32940. * @param id defines the material's ID
  32941. * @return the material or null if none found.
  32942. */
  32943. getMaterialByID(id: string): Nullable<Material>;
  32944. /**
  32945. * Gets a material using its name
  32946. * @param name defines the material's name
  32947. * @return the material or null if none found.
  32948. */
  32949. getMaterialByName(name: string): Nullable<Material>;
  32950. /**
  32951. * Gets a camera using its id
  32952. * @param id defines the id to look for
  32953. * @returns the camera or null if not found
  32954. */
  32955. getCameraByID(id: string): Nullable<Camera>;
  32956. /**
  32957. * Gets a camera using its unique id
  32958. * @param uniqueId defines the unique id to look for
  32959. * @returns the camera or null if not found
  32960. */
  32961. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32962. /**
  32963. * Gets a camera using its name
  32964. * @param name defines the camera's name
  32965. * @return the camera or null if none found.
  32966. */
  32967. getCameraByName(name: string): Nullable<Camera>;
  32968. /**
  32969. * Gets a bone using its id
  32970. * @param id defines the bone's id
  32971. * @return the bone or null if not found
  32972. */
  32973. getBoneByID(id: string): Nullable<Bone>;
  32974. /**
  32975. * Gets a bone using its id
  32976. * @param name defines the bone's name
  32977. * @return the bone or null if not found
  32978. */
  32979. getBoneByName(name: string): Nullable<Bone>;
  32980. /**
  32981. * Gets a light node using its name
  32982. * @param name defines the the light's name
  32983. * @return the light or null if none found.
  32984. */
  32985. getLightByName(name: string): Nullable<Light>;
  32986. /**
  32987. * Gets a light node using its id
  32988. * @param id defines the light's id
  32989. * @return the light or null if none found.
  32990. */
  32991. getLightByID(id: string): Nullable<Light>;
  32992. /**
  32993. * Gets a light node using its scene-generated unique ID
  32994. * @param uniqueId defines the light's unique id
  32995. * @return the light or null if none found.
  32996. */
  32997. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32998. /**
  32999. * Gets a particle system by id
  33000. * @param id defines the particle system id
  33001. * @return the corresponding system or null if none found
  33002. */
  33003. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33004. /**
  33005. * Gets a geometry using its ID
  33006. * @param id defines the geometry's id
  33007. * @return the geometry or null if none found.
  33008. */
  33009. getGeometryByID(id: string): Nullable<Geometry>;
  33010. private _getGeometryByUniqueID;
  33011. /**
  33012. * Add a new geometry to this scene
  33013. * @param geometry defines the geometry to be added to the scene.
  33014. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33015. * @return a boolean defining if the geometry was added or not
  33016. */
  33017. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33018. /**
  33019. * Removes an existing geometry
  33020. * @param geometry defines the geometry to be removed from the scene
  33021. * @return a boolean defining if the geometry was removed or not
  33022. */
  33023. removeGeometry(geometry: Geometry): boolean;
  33024. /**
  33025. * Gets the list of geometries attached to the scene
  33026. * @returns an array of Geometry
  33027. */
  33028. getGeometries(): Geometry[];
  33029. /**
  33030. * Gets the first added mesh found of a given ID
  33031. * @param id defines the id to search for
  33032. * @return the mesh found or null if not found at all
  33033. */
  33034. getMeshByID(id: string): Nullable<AbstractMesh>;
  33035. /**
  33036. * Gets a list of meshes using their id
  33037. * @param id defines the id to search for
  33038. * @returns a list of meshes
  33039. */
  33040. getMeshesByID(id: string): Array<AbstractMesh>;
  33041. /**
  33042. * Gets the first added transform node found of a given ID
  33043. * @param id defines the id to search for
  33044. * @return the found transform node or null if not found at all.
  33045. */
  33046. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33047. /**
  33048. * Gets a list of transform nodes using their id
  33049. * @param id defines the id to search for
  33050. * @returns a list of transform nodes
  33051. */
  33052. getTransformNodesByID(id: string): Array<TransformNode>;
  33053. /**
  33054. * Gets a mesh with its auto-generated unique id
  33055. * @param uniqueId defines the unique id to search for
  33056. * @return the found mesh or null if not found at all.
  33057. */
  33058. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33059. /**
  33060. * Gets a the last added mesh using a given id
  33061. * @param id defines the id to search for
  33062. * @return the found mesh or null if not found at all.
  33063. */
  33064. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33065. /**
  33066. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33067. * @param id defines the id to search for
  33068. * @return the found node or null if not found at all
  33069. */
  33070. getLastEntryByID(id: string): Nullable<Node>;
  33071. /**
  33072. * Gets a node (Mesh, Camera, Light) using a given id
  33073. * @param id defines the id to search for
  33074. * @return the found node or null if not found at all
  33075. */
  33076. getNodeByID(id: string): Nullable<Node>;
  33077. /**
  33078. * Gets a node (Mesh, Camera, Light) using a given name
  33079. * @param name defines the name to search for
  33080. * @return the found node or null if not found at all.
  33081. */
  33082. getNodeByName(name: string): Nullable<Node>;
  33083. /**
  33084. * Gets a mesh using a given name
  33085. * @param name defines the name to search for
  33086. * @return the found mesh or null if not found at all.
  33087. */
  33088. getMeshByName(name: string): Nullable<AbstractMesh>;
  33089. /**
  33090. * Gets a transform node using a given name
  33091. * @param name defines the name to search for
  33092. * @return the found transform node or null if not found at all.
  33093. */
  33094. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33095. /**
  33096. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33097. * @param id defines the id to search for
  33098. * @return the found skeleton or null if not found at all.
  33099. */
  33100. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33101. /**
  33102. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33103. * @param id defines the id to search for
  33104. * @return the found skeleton or null if not found at all.
  33105. */
  33106. getSkeletonById(id: string): Nullable<Skeleton>;
  33107. /**
  33108. * Gets a skeleton using a given name
  33109. * @param name defines the name to search for
  33110. * @return the found skeleton or null if not found at all.
  33111. */
  33112. getSkeletonByName(name: string): Nullable<Skeleton>;
  33113. /**
  33114. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33115. * @param id defines the id to search for
  33116. * @return the found morph target manager or null if not found at all.
  33117. */
  33118. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33119. /**
  33120. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33121. * @param id defines the id to search for
  33122. * @return the found morph target or null if not found at all.
  33123. */
  33124. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33125. /**
  33126. * Gets a boolean indicating if the given mesh is active
  33127. * @param mesh defines the mesh to look for
  33128. * @returns true if the mesh is in the active list
  33129. */
  33130. isActiveMesh(mesh: AbstractMesh): boolean;
  33131. /**
  33132. * Return a unique id as a string which can serve as an identifier for the scene
  33133. */
  33134. readonly uid: string;
  33135. /**
  33136. * Add an externaly attached data from its key.
  33137. * This method call will fail and return false, if such key already exists.
  33138. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33139. * @param key the unique key that identifies the data
  33140. * @param data the data object to associate to the key for this Engine instance
  33141. * @return true if no such key were already present and the data was added successfully, false otherwise
  33142. */
  33143. addExternalData<T>(key: string, data: T): boolean;
  33144. /**
  33145. * Get an externaly attached data from its key
  33146. * @param key the unique key that identifies the data
  33147. * @return the associated data, if present (can be null), or undefined if not present
  33148. */
  33149. getExternalData<T>(key: string): Nullable<T>;
  33150. /**
  33151. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33152. * @param key the unique key that identifies the data
  33153. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33154. * @return the associated data, can be null if the factory returned null.
  33155. */
  33156. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33157. /**
  33158. * Remove an externaly attached data from the Engine instance
  33159. * @param key the unique key that identifies the data
  33160. * @return true if the data was successfully removed, false if it doesn't exist
  33161. */
  33162. removeExternalData(key: string): boolean;
  33163. private _evaluateSubMesh;
  33164. /**
  33165. * Clear the processed materials smart array preventing retention point in material dispose.
  33166. */
  33167. freeProcessedMaterials(): void;
  33168. private _preventFreeActiveMeshesAndRenderingGroups;
  33169. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33170. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33171. * when disposing several meshes in a row or a hierarchy of meshes.
  33172. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33173. */
  33174. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33175. /**
  33176. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33177. */
  33178. freeActiveMeshes(): void;
  33179. /**
  33180. * Clear the info related to rendering groups preventing retention points during dispose.
  33181. */
  33182. freeRenderingGroups(): void;
  33183. /** @hidden */
  33184. _isInIntermediateRendering(): boolean;
  33185. /**
  33186. * Lambda returning the list of potentially active meshes.
  33187. */
  33188. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33189. /**
  33190. * Lambda returning the list of potentially active sub meshes.
  33191. */
  33192. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33193. /**
  33194. * Lambda returning the list of potentially intersecting sub meshes.
  33195. */
  33196. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33197. /**
  33198. * Lambda returning the list of potentially colliding sub meshes.
  33199. */
  33200. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33201. private _activeMeshesFrozen;
  33202. /**
  33203. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33204. * @returns the current scene
  33205. */
  33206. freezeActiveMeshes(): Scene;
  33207. /**
  33208. * Use this function to restart evaluating active meshes on every frame
  33209. * @returns the current scene
  33210. */
  33211. unfreezeActiveMeshes(): Scene;
  33212. private _evaluateActiveMeshes;
  33213. private _activeMesh;
  33214. /**
  33215. * Update the transform matrix to update from the current active camera
  33216. * @param force defines a boolean used to force the update even if cache is up to date
  33217. */
  33218. updateTransformMatrix(force?: boolean): void;
  33219. /**
  33220. * 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)
  33221. * @param alternateCamera defines the camera to use
  33222. */
  33223. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33224. /** @hidden */
  33225. _allowPostProcessClearColor: boolean;
  33226. private _renderForCamera;
  33227. private _processSubCameras;
  33228. private _checkIntersections;
  33229. /** @hidden */
  33230. _advancePhysicsEngineStep(step: number): void;
  33231. /**
  33232. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33233. */
  33234. getDeterministicFrameTime: () => number;
  33235. /** @hidden */
  33236. _animate(): void;
  33237. /**
  33238. * Render the scene
  33239. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33240. */
  33241. render(updateCameras?: boolean): void;
  33242. /**
  33243. * Freeze all materials
  33244. * A frozen material will not be updatable but should be faster to render
  33245. */
  33246. freezeMaterials(): void;
  33247. /**
  33248. * Unfreeze all materials
  33249. * A frozen material will not be updatable but should be faster to render
  33250. */
  33251. unfreezeMaterials(): void;
  33252. /**
  33253. * Releases all held ressources
  33254. */
  33255. dispose(): void;
  33256. /**
  33257. * Gets if the scene is already disposed
  33258. */
  33259. readonly isDisposed: boolean;
  33260. /**
  33261. * Call this function to reduce memory footprint of the scene.
  33262. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33263. */
  33264. clearCachedVertexData(): void;
  33265. /**
  33266. * This function will remove the local cached buffer data from texture.
  33267. * It will save memory but will prevent the texture from being rebuilt
  33268. */
  33269. cleanCachedTextureBuffer(): void;
  33270. /**
  33271. * Get the world extend vectors with an optional filter
  33272. *
  33273. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33274. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33275. */
  33276. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33277. min: Vector3;
  33278. max: Vector3;
  33279. };
  33280. /**
  33281. * Creates a ray that can be used to pick in the scene
  33282. * @param x defines the x coordinate of the origin (on-screen)
  33283. * @param y defines the y coordinate of the origin (on-screen)
  33284. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33285. * @param camera defines the camera to use for the picking
  33286. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33287. * @returns a Ray
  33288. */
  33289. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33290. /**
  33291. * Creates a ray that can be used to pick in the scene
  33292. * @param x defines the x coordinate of the origin (on-screen)
  33293. * @param y defines the y coordinate of the origin (on-screen)
  33294. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33295. * @param result defines the ray where to store the picking ray
  33296. * @param camera defines the camera to use for the picking
  33297. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33298. * @returns the current scene
  33299. */
  33300. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33301. /**
  33302. * Creates a ray that can be used to pick in the scene
  33303. * @param x defines the x coordinate of the origin (on-screen)
  33304. * @param y defines the y coordinate of the origin (on-screen)
  33305. * @param camera defines the camera to use for the picking
  33306. * @returns a Ray
  33307. */
  33308. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33309. /**
  33310. * Creates a ray that can be used to pick in the scene
  33311. * @param x defines the x coordinate of the origin (on-screen)
  33312. * @param y defines the y coordinate of the origin (on-screen)
  33313. * @param result defines the ray where to store the picking ray
  33314. * @param camera defines the camera to use for the picking
  33315. * @returns the current scene
  33316. */
  33317. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33318. /** Launch a ray to try to pick a mesh in the scene
  33319. * @param x position on screen
  33320. * @param y position on screen
  33321. * @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
  33322. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33323. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33324. * @returns a PickingInfo
  33325. */
  33326. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33327. /** Use the given ray to pick a mesh in the scene
  33328. * @param ray The ray to use to pick meshes
  33329. * @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
  33330. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33331. * @returns a PickingInfo
  33332. */
  33333. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33334. /**
  33335. * Launch a ray to try to pick a mesh in the scene
  33336. * @param x X position on screen
  33337. * @param y Y position on screen
  33338. * @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
  33339. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33340. * @returns an array of PickingInfo
  33341. */
  33342. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33343. /**
  33344. * Launch a ray to try to pick a mesh in the scene
  33345. * @param ray Ray to use
  33346. * @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
  33347. * @returns an array of PickingInfo
  33348. */
  33349. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33350. /**
  33351. * Force the value of meshUnderPointer
  33352. * @param mesh defines the mesh to use
  33353. */
  33354. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33355. /**
  33356. * Gets the mesh under the pointer
  33357. * @returns a Mesh or null if no mesh is under the pointer
  33358. */
  33359. getPointerOverMesh(): Nullable<AbstractMesh>;
  33360. /** @hidden */
  33361. _rebuildGeometries(): void;
  33362. /** @hidden */
  33363. _rebuildTextures(): void;
  33364. private _getByTags;
  33365. /**
  33366. * Get a list of meshes by tags
  33367. * @param tagsQuery defines the tags query to use
  33368. * @param forEach defines a predicate used to filter results
  33369. * @returns an array of Mesh
  33370. */
  33371. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33372. /**
  33373. * Get a list of cameras by tags
  33374. * @param tagsQuery defines the tags query to use
  33375. * @param forEach defines a predicate used to filter results
  33376. * @returns an array of Camera
  33377. */
  33378. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33379. /**
  33380. * Get a list of lights by tags
  33381. * @param tagsQuery defines the tags query to use
  33382. * @param forEach defines a predicate used to filter results
  33383. * @returns an array of Light
  33384. */
  33385. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33386. /**
  33387. * Get a list of materials by tags
  33388. * @param tagsQuery defines the tags query to use
  33389. * @param forEach defines a predicate used to filter results
  33390. * @returns an array of Material
  33391. */
  33392. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33393. /**
  33394. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33395. * This allowed control for front to back rendering or reversly depending of the special needs.
  33396. *
  33397. * @param renderingGroupId The rendering group id corresponding to its index
  33398. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33399. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33400. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33401. */
  33402. 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;
  33403. /**
  33404. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33405. *
  33406. * @param renderingGroupId The rendering group id corresponding to its index
  33407. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33408. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33409. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33410. */
  33411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33412. /**
  33413. * Gets the current auto clear configuration for one rendering group of the rendering
  33414. * manager.
  33415. * @param index the rendering group index to get the information for
  33416. * @returns The auto clear setup for the requested rendering group
  33417. */
  33418. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33419. private _blockMaterialDirtyMechanism;
  33420. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33421. blockMaterialDirtyMechanism: boolean;
  33422. /**
  33423. * Will flag all materials as dirty to trigger new shader compilation
  33424. * @param flag defines the flag used to specify which material part must be marked as dirty
  33425. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33426. */
  33427. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33428. /** @hidden */
  33429. _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;
  33430. /** @hidden */
  33431. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33432. }
  33433. }
  33434. declare module "babylonjs/assetContainer" {
  33435. import { AbstractScene } from "babylonjs/abstractScene";
  33436. import { Scene } from "babylonjs/scene";
  33437. import { Mesh } from "babylonjs/Meshes/mesh";
  33438. /**
  33439. * Set of assets to keep when moving a scene into an asset container.
  33440. */
  33441. export class KeepAssets extends AbstractScene {
  33442. }
  33443. /**
  33444. * Container with a set of assets that can be added or removed from a scene.
  33445. */
  33446. export class AssetContainer extends AbstractScene {
  33447. /**
  33448. * The scene the AssetContainer belongs to.
  33449. */
  33450. scene: Scene;
  33451. /**
  33452. * Instantiates an AssetContainer.
  33453. * @param scene The scene the AssetContainer belongs to.
  33454. */
  33455. constructor(scene: Scene);
  33456. /**
  33457. * Adds all the assets from the container to the scene.
  33458. */
  33459. addAllToScene(): void;
  33460. /**
  33461. * Removes all the assets in the container from the scene
  33462. */
  33463. removeAllFromScene(): void;
  33464. /**
  33465. * Disposes all the assets in the container
  33466. */
  33467. dispose(): void;
  33468. private _moveAssets;
  33469. /**
  33470. * Removes all the assets contained in the scene and adds them to the container.
  33471. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33472. */
  33473. moveAllFromScene(keepAssets?: KeepAssets): void;
  33474. /**
  33475. * 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.
  33476. * @returns the root mesh
  33477. */
  33478. createRootMesh(): Mesh;
  33479. }
  33480. }
  33481. declare module "babylonjs/abstractScene" {
  33482. import { Scene } from "babylonjs/scene";
  33483. import { Nullable } from "babylonjs/types";
  33484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33486. import { Geometry } from "babylonjs/Meshes/geometry";
  33487. import { Skeleton } from "babylonjs/Bones/skeleton";
  33488. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33489. import { AssetContainer } from "babylonjs/assetContainer";
  33490. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33491. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33493. import { Material } from "babylonjs/Materials/material";
  33494. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33495. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33496. import { Camera } from "babylonjs/Cameras/camera";
  33497. import { Light } from "babylonjs/Lights/light";
  33498. import { Node } from "babylonjs/node";
  33499. import { Animation } from "babylonjs/Animations/animation";
  33500. /**
  33501. * Defines how the parser contract is defined.
  33502. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33503. */
  33504. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33505. /**
  33506. * Defines how the individual parser contract is defined.
  33507. * These parser can parse an individual asset
  33508. */
  33509. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33510. /**
  33511. * Base class of the scene acting as a container for the different elements composing a scene.
  33512. * This class is dynamically extended by the different components of the scene increasing
  33513. * flexibility and reducing coupling
  33514. */
  33515. export abstract class AbstractScene {
  33516. /**
  33517. * Stores the list of available parsers in the application.
  33518. */
  33519. private static _BabylonFileParsers;
  33520. /**
  33521. * Stores the list of available individual parsers in the application.
  33522. */
  33523. private static _IndividualBabylonFileParsers;
  33524. /**
  33525. * Adds a parser in the list of available ones
  33526. * @param name Defines the name of the parser
  33527. * @param parser Defines the parser to add
  33528. */
  33529. static AddParser(name: string, parser: BabylonFileParser): void;
  33530. /**
  33531. * Gets a general parser from the list of avaialble ones
  33532. * @param name Defines the name of the parser
  33533. * @returns the requested parser or null
  33534. */
  33535. static GetParser(name: string): Nullable<BabylonFileParser>;
  33536. /**
  33537. * Adds n individual parser in the list of available ones
  33538. * @param name Defines the name of the parser
  33539. * @param parser Defines the parser to add
  33540. */
  33541. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33542. /**
  33543. * Gets an individual parser from the list of avaialble ones
  33544. * @param name Defines the name of the parser
  33545. * @returns the requested parser or null
  33546. */
  33547. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33548. /**
  33549. * Parser json data and populate both a scene and its associated container object
  33550. * @param jsonData Defines the data to parse
  33551. * @param scene Defines the scene to parse the data for
  33552. * @param container Defines the container attached to the parsing sequence
  33553. * @param rootUrl Defines the root url of the data
  33554. */
  33555. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33556. /**
  33557. * Gets the list of root nodes (ie. nodes with no parent)
  33558. */
  33559. rootNodes: Node[];
  33560. /** All of the cameras added to this scene
  33561. * @see http://doc.babylonjs.com/babylon101/cameras
  33562. */
  33563. cameras: Camera[];
  33564. /**
  33565. * All of the lights added to this scene
  33566. * @see http://doc.babylonjs.com/babylon101/lights
  33567. */
  33568. lights: Light[];
  33569. /**
  33570. * All of the (abstract) meshes added to this scene
  33571. */
  33572. meshes: AbstractMesh[];
  33573. /**
  33574. * The list of skeletons added to the scene
  33575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33576. */
  33577. skeletons: Skeleton[];
  33578. /**
  33579. * All of the particle systems added to this scene
  33580. * @see http://doc.babylonjs.com/babylon101/particles
  33581. */
  33582. particleSystems: IParticleSystem[];
  33583. /**
  33584. * Gets a list of Animations associated with the scene
  33585. */
  33586. animations: Animation[];
  33587. /**
  33588. * All of the animation groups added to this scene
  33589. * @see http://doc.babylonjs.com/how_to/group
  33590. */
  33591. animationGroups: AnimationGroup[];
  33592. /**
  33593. * All of the multi-materials added to this scene
  33594. * @see http://doc.babylonjs.com/how_to/multi_materials
  33595. */
  33596. multiMaterials: MultiMaterial[];
  33597. /**
  33598. * All of the materials added to this scene
  33599. * In the context of a Scene, it is not supposed to be modified manually.
  33600. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33601. * Note also that the order of the Material wihin the array is not significant and might change.
  33602. * @see http://doc.babylonjs.com/babylon101/materials
  33603. */
  33604. materials: Material[];
  33605. /**
  33606. * The list of morph target managers added to the scene
  33607. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33608. */
  33609. morphTargetManagers: MorphTargetManager[];
  33610. /**
  33611. * The list of geometries used in the scene.
  33612. */
  33613. geometries: Geometry[];
  33614. /**
  33615. * All of the tranform nodes added to this scene
  33616. * In the context of a Scene, it is not supposed to be modified manually.
  33617. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33618. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33619. * @see http://doc.babylonjs.com/how_to/transformnode
  33620. */
  33621. transformNodes: TransformNode[];
  33622. /**
  33623. * ActionManagers available on the scene.
  33624. */
  33625. actionManagers: AbstractActionManager[];
  33626. /**
  33627. * Textures to keep.
  33628. */
  33629. textures: BaseTexture[];
  33630. }
  33631. }
  33632. declare module "babylonjs/Audio/sound" {
  33633. import { Observable } from "babylonjs/Misc/observable";
  33634. import { Vector3 } from "babylonjs/Maths/math";
  33635. import { Nullable } from "babylonjs/types";
  33636. import { Scene } from "babylonjs/scene";
  33637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33638. /**
  33639. * Defines a sound that can be played in the application.
  33640. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33642. */
  33643. export class Sound {
  33644. /**
  33645. * The name of the sound in the scene.
  33646. */
  33647. name: string;
  33648. /**
  33649. * Does the sound autoplay once loaded.
  33650. */
  33651. autoplay: boolean;
  33652. /**
  33653. * Does the sound loop after it finishes playing once.
  33654. */
  33655. loop: boolean;
  33656. /**
  33657. * Does the sound use a custom attenuation curve to simulate the falloff
  33658. * happening when the source gets further away from the camera.
  33659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33660. */
  33661. useCustomAttenuation: boolean;
  33662. /**
  33663. * The sound track id this sound belongs to.
  33664. */
  33665. soundTrackId: number;
  33666. /**
  33667. * Is this sound currently played.
  33668. */
  33669. isPlaying: boolean;
  33670. /**
  33671. * Is this sound currently paused.
  33672. */
  33673. isPaused: boolean;
  33674. /**
  33675. * Does this sound enables spatial sound.
  33676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33677. */
  33678. spatialSound: boolean;
  33679. /**
  33680. * Define the reference distance the sound should be heard perfectly.
  33681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33682. */
  33683. refDistance: number;
  33684. /**
  33685. * Define the roll off factor of spatial sounds.
  33686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33687. */
  33688. rolloffFactor: number;
  33689. /**
  33690. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33692. */
  33693. maxDistance: number;
  33694. /**
  33695. * Define the distance attenuation model the sound will follow.
  33696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33697. */
  33698. distanceModel: string;
  33699. /**
  33700. * @hidden
  33701. * Back Compat
  33702. **/
  33703. onended: () => any;
  33704. /**
  33705. * Observable event when the current playing sound finishes.
  33706. */
  33707. onEndedObservable: Observable<Sound>;
  33708. private _panningModel;
  33709. private _playbackRate;
  33710. private _streaming;
  33711. private _startTime;
  33712. private _startOffset;
  33713. private _position;
  33714. /** @hidden */
  33715. _positionInEmitterSpace: boolean;
  33716. private _localDirection;
  33717. private _volume;
  33718. private _isReadyToPlay;
  33719. private _isDirectional;
  33720. private _readyToPlayCallback;
  33721. private _audioBuffer;
  33722. private _soundSource;
  33723. private _streamingSource;
  33724. private _soundPanner;
  33725. private _soundGain;
  33726. private _inputAudioNode;
  33727. private _outputAudioNode;
  33728. private _coneInnerAngle;
  33729. private _coneOuterAngle;
  33730. private _coneOuterGain;
  33731. private _scene;
  33732. private _connectedTransformNode;
  33733. private _customAttenuationFunction;
  33734. private _registerFunc;
  33735. private _isOutputConnected;
  33736. private _htmlAudioElement;
  33737. private _urlType;
  33738. /** @hidden */
  33739. static _SceneComponentInitialization: (scene: Scene) => void;
  33740. /**
  33741. * Create a sound and attach it to a scene
  33742. * @param name Name of your sound
  33743. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33744. * @param scene defines the scene the sound belongs to
  33745. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33746. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33747. */
  33748. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33749. /**
  33750. * Release the sound and its associated resources
  33751. */
  33752. dispose(): void;
  33753. /**
  33754. * Gets if the sounds is ready to be played or not.
  33755. * @returns true if ready, otherwise false
  33756. */
  33757. isReady(): boolean;
  33758. private _soundLoaded;
  33759. /**
  33760. * Sets the data of the sound from an audiobuffer
  33761. * @param audioBuffer The audioBuffer containing the data
  33762. */
  33763. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33764. /**
  33765. * Updates the current sounds options such as maxdistance, loop...
  33766. * @param options A JSON object containing values named as the object properties
  33767. */
  33768. updateOptions(options: any): void;
  33769. private _createSpatialParameters;
  33770. private _updateSpatialParameters;
  33771. /**
  33772. * Switch the panning model to HRTF:
  33773. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33775. */
  33776. switchPanningModelToHRTF(): void;
  33777. /**
  33778. * Switch the panning model to Equal Power:
  33779. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33781. */
  33782. switchPanningModelToEqualPower(): void;
  33783. private _switchPanningModel;
  33784. /**
  33785. * Connect this sound to a sound track audio node like gain...
  33786. * @param soundTrackAudioNode the sound track audio node to connect to
  33787. */
  33788. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33789. /**
  33790. * Transform this sound into a directional source
  33791. * @param coneInnerAngle Size of the inner cone in degree
  33792. * @param coneOuterAngle Size of the outer cone in degree
  33793. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33794. */
  33795. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33796. /**
  33797. * Gets or sets the inner angle for the directional cone.
  33798. */
  33799. /**
  33800. * Gets or sets the inner angle for the directional cone.
  33801. */
  33802. directionalConeInnerAngle: number;
  33803. /**
  33804. * Gets or sets the outer angle for the directional cone.
  33805. */
  33806. /**
  33807. * Gets or sets the outer angle for the directional cone.
  33808. */
  33809. directionalConeOuterAngle: number;
  33810. /**
  33811. * Sets the position of the emitter if spatial sound is enabled
  33812. * @param newPosition Defines the new posisiton
  33813. */
  33814. setPosition(newPosition: Vector3): void;
  33815. /**
  33816. * Sets the local direction of the emitter if spatial sound is enabled
  33817. * @param newLocalDirection Defines the new local direction
  33818. */
  33819. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33820. private _updateDirection;
  33821. /** @hidden */
  33822. updateDistanceFromListener(): void;
  33823. /**
  33824. * Sets a new custom attenuation function for the sound.
  33825. * @param callback Defines the function used for the attenuation
  33826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33827. */
  33828. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33829. /**
  33830. * Play the sound
  33831. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33832. * @param offset (optional) Start the sound setting it at a specific time
  33833. */
  33834. play(time?: number, offset?: number): void;
  33835. private _onended;
  33836. /**
  33837. * Stop the sound
  33838. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33839. */
  33840. stop(time?: number): void;
  33841. /**
  33842. * Put the sound in pause
  33843. */
  33844. pause(): void;
  33845. /**
  33846. * Sets a dedicated volume for this sounds
  33847. * @param newVolume Define the new volume of the sound
  33848. * @param time Define in how long the sound should be at this value
  33849. */
  33850. setVolume(newVolume: number, time?: number): void;
  33851. /**
  33852. * Set the sound play back rate
  33853. * @param newPlaybackRate Define the playback rate the sound should be played at
  33854. */
  33855. setPlaybackRate(newPlaybackRate: number): void;
  33856. /**
  33857. * Gets the volume of the sound.
  33858. * @returns the volume of the sound
  33859. */
  33860. getVolume(): number;
  33861. /**
  33862. * Attach the sound to a dedicated mesh
  33863. * @param transformNode The transform node to connect the sound with
  33864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33865. */
  33866. attachToMesh(transformNode: TransformNode): void;
  33867. /**
  33868. * Detach the sound from the previously attached mesh
  33869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33870. */
  33871. detachFromMesh(): void;
  33872. private _onRegisterAfterWorldMatrixUpdate;
  33873. /**
  33874. * Clone the current sound in the scene.
  33875. * @returns the new sound clone
  33876. */
  33877. clone(): Nullable<Sound>;
  33878. /**
  33879. * Gets the current underlying audio buffer containing the data
  33880. * @returns the audio buffer
  33881. */
  33882. getAudioBuffer(): Nullable<AudioBuffer>;
  33883. /**
  33884. * Serializes the Sound in a JSON representation
  33885. * @returns the JSON representation of the sound
  33886. */
  33887. serialize(): any;
  33888. /**
  33889. * Parse a JSON representation of a sound to innstantiate in a given scene
  33890. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33891. * @param scene Define the scene the new parsed sound should be created in
  33892. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33893. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33894. * @returns the newly parsed sound
  33895. */
  33896. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33897. }
  33898. }
  33899. declare module "babylonjs/Actions/directAudioActions" {
  33900. import { Action } from "babylonjs/Actions/action";
  33901. import { Condition } from "babylonjs/Actions/condition";
  33902. import { Sound } from "babylonjs/Audio/sound";
  33903. /**
  33904. * This defines an action helpful to play a defined sound on a triggered action.
  33905. */
  33906. export class PlaySoundAction extends Action {
  33907. private _sound;
  33908. /**
  33909. * Instantiate the action
  33910. * @param triggerOptions defines the trigger options
  33911. * @param sound defines the sound to play
  33912. * @param condition defines the trigger related conditions
  33913. */
  33914. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33915. /** @hidden */
  33916. _prepare(): void;
  33917. /**
  33918. * Execute the action and play the sound.
  33919. */
  33920. execute(): void;
  33921. /**
  33922. * Serializes the actions and its related information.
  33923. * @param parent defines the object to serialize in
  33924. * @returns the serialized object
  33925. */
  33926. serialize(parent: any): any;
  33927. }
  33928. /**
  33929. * This defines an action helpful to stop a defined sound on a triggered action.
  33930. */
  33931. export class StopSoundAction extends Action {
  33932. private _sound;
  33933. /**
  33934. * Instantiate the action
  33935. * @param triggerOptions defines the trigger options
  33936. * @param sound defines the sound to stop
  33937. * @param condition defines the trigger related conditions
  33938. */
  33939. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33940. /** @hidden */
  33941. _prepare(): void;
  33942. /**
  33943. * Execute the action and stop the sound.
  33944. */
  33945. execute(): void;
  33946. /**
  33947. * Serializes the actions and its related information.
  33948. * @param parent defines the object to serialize in
  33949. * @returns the serialized object
  33950. */
  33951. serialize(parent: any): any;
  33952. }
  33953. }
  33954. declare module "babylonjs/Actions/interpolateValueAction" {
  33955. import { Action } from "babylonjs/Actions/action";
  33956. import { Condition } from "babylonjs/Actions/condition";
  33957. import { Observable } from "babylonjs/Misc/observable";
  33958. /**
  33959. * This defines an action responsible to change the value of a property
  33960. * by interpolating between its current value and the newly set one once triggered.
  33961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33962. */
  33963. export class InterpolateValueAction extends Action {
  33964. /**
  33965. * Defines the path of the property where the value should be interpolated
  33966. */
  33967. propertyPath: string;
  33968. /**
  33969. * Defines the target value at the end of the interpolation.
  33970. */
  33971. value: any;
  33972. /**
  33973. * Defines the time it will take for the property to interpolate to the value.
  33974. */
  33975. duration: number;
  33976. /**
  33977. * Defines if the other scene animations should be stopped when the action has been triggered
  33978. */
  33979. stopOtherAnimations?: boolean;
  33980. /**
  33981. * Defines a callback raised once the interpolation animation has been done.
  33982. */
  33983. onInterpolationDone?: () => void;
  33984. /**
  33985. * Observable triggered once the interpolation animation has been done.
  33986. */
  33987. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33988. private _target;
  33989. private _effectiveTarget;
  33990. private _property;
  33991. /**
  33992. * Instantiate the action
  33993. * @param triggerOptions defines the trigger options
  33994. * @param target defines the object containing the value to interpolate
  33995. * @param propertyPath defines the path to the property in the target object
  33996. * @param value defines the target value at the end of the interpolation
  33997. * @param duration deines the time it will take for the property to interpolate to the value.
  33998. * @param condition defines the trigger related conditions
  33999. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34000. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34001. */
  34002. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34003. /** @hidden */
  34004. _prepare(): void;
  34005. /**
  34006. * Execute the action starts the value interpolation.
  34007. */
  34008. execute(): void;
  34009. /**
  34010. * Serializes the actions and its related information.
  34011. * @param parent defines the object to serialize in
  34012. * @returns the serialized object
  34013. */
  34014. serialize(parent: any): any;
  34015. }
  34016. }
  34017. declare module "babylonjs/Actions/index" {
  34018. export * from "babylonjs/Actions/action";
  34019. export * from "babylonjs/Actions/actionEvent";
  34020. export * from "babylonjs/Actions/actionManager";
  34021. export * from "babylonjs/Actions/condition";
  34022. export * from "babylonjs/Actions/directActions";
  34023. export * from "babylonjs/Actions/directAudioActions";
  34024. export * from "babylonjs/Actions/interpolateValueAction";
  34025. }
  34026. declare module "babylonjs/Animations/index" {
  34027. export * from "babylonjs/Animations/animatable";
  34028. export * from "babylonjs/Animations/animation";
  34029. export * from "babylonjs/Animations/animationGroup";
  34030. export * from "babylonjs/Animations/animationPropertiesOverride";
  34031. export * from "babylonjs/Animations/easing";
  34032. export * from "babylonjs/Animations/runtimeAnimation";
  34033. export * from "babylonjs/Animations/animationEvent";
  34034. export * from "babylonjs/Animations/animationGroup";
  34035. export * from "babylonjs/Animations/animationKey";
  34036. export * from "babylonjs/Animations/animationRange";
  34037. }
  34038. declare module "babylonjs/Audio/soundTrack" {
  34039. import { Sound } from "babylonjs/Audio/sound";
  34040. import { Analyser } from "babylonjs/Audio/analyser";
  34041. import { Scene } from "babylonjs/scene";
  34042. /**
  34043. * Options allowed during the creation of a sound track.
  34044. */
  34045. export interface ISoundTrackOptions {
  34046. /**
  34047. * The volume the sound track should take during creation
  34048. */
  34049. volume?: number;
  34050. /**
  34051. * Define if the sound track is the main sound track of the scene
  34052. */
  34053. mainTrack?: boolean;
  34054. }
  34055. /**
  34056. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34057. * It will be also used in a future release to apply effects on a specific track.
  34058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34059. */
  34060. export class SoundTrack {
  34061. /**
  34062. * The unique identifier of the sound track in the scene.
  34063. */
  34064. id: number;
  34065. /**
  34066. * The list of sounds included in the sound track.
  34067. */
  34068. soundCollection: Array<Sound>;
  34069. private _outputAudioNode;
  34070. private _scene;
  34071. private _isMainTrack;
  34072. private _connectedAnalyser;
  34073. private _options;
  34074. private _isInitialized;
  34075. /**
  34076. * Creates a new sound track.
  34077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34078. * @param scene Define the scene the sound track belongs to
  34079. * @param options
  34080. */
  34081. constructor(scene: Scene, options?: ISoundTrackOptions);
  34082. private _initializeSoundTrackAudioGraph;
  34083. /**
  34084. * Release the sound track and its associated resources
  34085. */
  34086. dispose(): void;
  34087. /**
  34088. * Adds a sound to this sound track
  34089. * @param sound define the cound to add
  34090. * @ignoreNaming
  34091. */
  34092. AddSound(sound: Sound): void;
  34093. /**
  34094. * Removes a sound to this sound track
  34095. * @param sound define the cound to remove
  34096. * @ignoreNaming
  34097. */
  34098. RemoveSound(sound: Sound): void;
  34099. /**
  34100. * Set a global volume for the full sound track.
  34101. * @param newVolume Define the new volume of the sound track
  34102. */
  34103. setVolume(newVolume: number): void;
  34104. /**
  34105. * Switch the panning model to HRTF:
  34106. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34108. */
  34109. switchPanningModelToHRTF(): void;
  34110. /**
  34111. * Switch the panning model to Equal Power:
  34112. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34114. */
  34115. switchPanningModelToEqualPower(): void;
  34116. /**
  34117. * Connect the sound track to an audio analyser allowing some amazing
  34118. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34120. * @param analyser The analyser to connect to the engine
  34121. */
  34122. connectToAnalyser(analyser: Analyser): void;
  34123. }
  34124. }
  34125. declare module "babylonjs/Audio/audioSceneComponent" {
  34126. import { Sound } from "babylonjs/Audio/sound";
  34127. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34128. import { Nullable } from "babylonjs/types";
  34129. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34130. import { Scene } from "babylonjs/scene";
  34131. import { AbstractScene } from "babylonjs/abstractScene";
  34132. module "babylonjs/abstractScene" {
  34133. interface AbstractScene {
  34134. /**
  34135. * The list of sounds used in the scene.
  34136. */
  34137. sounds: Nullable<Array<Sound>>;
  34138. }
  34139. }
  34140. module "babylonjs/scene" {
  34141. interface Scene {
  34142. /**
  34143. * @hidden
  34144. * Backing field
  34145. */
  34146. _mainSoundTrack: SoundTrack;
  34147. /**
  34148. * The main sound track played by the scene.
  34149. * It cotains your primary collection of sounds.
  34150. */
  34151. mainSoundTrack: SoundTrack;
  34152. /**
  34153. * The list of sound tracks added to the scene
  34154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34155. */
  34156. soundTracks: Nullable<Array<SoundTrack>>;
  34157. /**
  34158. * Gets a sound using a given name
  34159. * @param name defines the name to search for
  34160. * @return the found sound or null if not found at all.
  34161. */
  34162. getSoundByName(name: string): Nullable<Sound>;
  34163. /**
  34164. * Gets or sets if audio support is enabled
  34165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34166. */
  34167. audioEnabled: boolean;
  34168. /**
  34169. * Gets or sets if audio will be output to headphones
  34170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34171. */
  34172. headphone: boolean;
  34173. }
  34174. }
  34175. /**
  34176. * Defines the sound scene component responsible to manage any sounds
  34177. * in a given scene.
  34178. */
  34179. export class AudioSceneComponent implements ISceneSerializableComponent {
  34180. /**
  34181. * The component name helpfull to identify the component in the list of scene components.
  34182. */
  34183. readonly name: string;
  34184. /**
  34185. * The scene the component belongs to.
  34186. */
  34187. scene: Scene;
  34188. private _audioEnabled;
  34189. /**
  34190. * Gets whether audio is enabled or not.
  34191. * Please use related enable/disable method to switch state.
  34192. */
  34193. readonly audioEnabled: boolean;
  34194. private _headphone;
  34195. /**
  34196. * Gets whether audio is outputing to headphone or not.
  34197. * Please use the according Switch methods to change output.
  34198. */
  34199. readonly headphone: boolean;
  34200. /**
  34201. * Creates a new instance of the component for the given scene
  34202. * @param scene Defines the scene to register the component in
  34203. */
  34204. constructor(scene: Scene);
  34205. /**
  34206. * Registers the component in a given scene
  34207. */
  34208. register(): void;
  34209. /**
  34210. * Rebuilds the elements related to this component in case of
  34211. * context lost for instance.
  34212. */
  34213. rebuild(): void;
  34214. /**
  34215. * Serializes the component data to the specified json object
  34216. * @param serializationObject The object to serialize to
  34217. */
  34218. serialize(serializationObject: any): void;
  34219. /**
  34220. * Adds all the element from the container to the scene
  34221. * @param container the container holding the elements
  34222. */
  34223. addFromContainer(container: AbstractScene): void;
  34224. /**
  34225. * Removes all the elements in the container from the scene
  34226. * @param container contains the elements to remove
  34227. */
  34228. removeFromContainer(container: AbstractScene): void;
  34229. /**
  34230. * Disposes the component and the associated ressources.
  34231. */
  34232. dispose(): void;
  34233. /**
  34234. * Disables audio in the associated scene.
  34235. */
  34236. disableAudio(): void;
  34237. /**
  34238. * Enables audio in the associated scene.
  34239. */
  34240. enableAudio(): void;
  34241. /**
  34242. * Switch audio to headphone output.
  34243. */
  34244. switchAudioModeForHeadphones(): void;
  34245. /**
  34246. * Switch audio to normal speakers.
  34247. */
  34248. switchAudioModeForNormalSpeakers(): void;
  34249. private _afterRender;
  34250. }
  34251. }
  34252. declare module "babylonjs/Audio/weightedsound" {
  34253. import { Sound } from "babylonjs/Audio/sound";
  34254. /**
  34255. * Wraps one or more Sound objects and selects one with random weight for playback.
  34256. */
  34257. export class WeightedSound {
  34258. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34259. loop: boolean;
  34260. private _coneInnerAngle;
  34261. private _coneOuterAngle;
  34262. private _volume;
  34263. /** A Sound is currently playing. */
  34264. isPlaying: boolean;
  34265. /** A Sound is currently paused. */
  34266. isPaused: boolean;
  34267. private _sounds;
  34268. private _weights;
  34269. private _currentIndex?;
  34270. /**
  34271. * Creates a new WeightedSound from the list of sounds given.
  34272. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34273. * @param sounds Array of Sounds that will be selected from.
  34274. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34275. */
  34276. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34277. /**
  34278. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34279. */
  34280. /**
  34281. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34282. */
  34283. directionalConeInnerAngle: number;
  34284. /**
  34285. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34286. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34287. */
  34288. /**
  34289. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34290. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34291. */
  34292. directionalConeOuterAngle: number;
  34293. /**
  34294. * Playback volume.
  34295. */
  34296. /**
  34297. * Playback volume.
  34298. */
  34299. volume: number;
  34300. private _onended;
  34301. /**
  34302. * Suspend playback
  34303. */
  34304. pause(): void;
  34305. /**
  34306. * Stop playback
  34307. */
  34308. stop(): void;
  34309. /**
  34310. * Start playback.
  34311. * @param startOffset Position the clip head at a specific time in seconds.
  34312. */
  34313. play(startOffset?: number): void;
  34314. }
  34315. }
  34316. declare module "babylonjs/Audio/index" {
  34317. export * from "babylonjs/Audio/analyser";
  34318. export * from "babylonjs/Audio/audioEngine";
  34319. export * from "babylonjs/Audio/audioSceneComponent";
  34320. export * from "babylonjs/Audio/sound";
  34321. export * from "babylonjs/Audio/soundTrack";
  34322. export * from "babylonjs/Audio/weightedsound";
  34323. }
  34324. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34325. import { Behavior } from "babylonjs/Behaviors/behavior";
  34326. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34327. import { BackEase } from "babylonjs/Animations/easing";
  34328. /**
  34329. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34331. */
  34332. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34333. /**
  34334. * Gets the name of the behavior.
  34335. */
  34336. readonly name: string;
  34337. /**
  34338. * The easing function used by animations
  34339. */
  34340. static EasingFunction: BackEase;
  34341. /**
  34342. * The easing mode used by animations
  34343. */
  34344. static EasingMode: number;
  34345. /**
  34346. * The duration of the animation, in milliseconds
  34347. */
  34348. transitionDuration: number;
  34349. /**
  34350. * Length of the distance animated by the transition when lower radius is reached
  34351. */
  34352. lowerRadiusTransitionRange: number;
  34353. /**
  34354. * Length of the distance animated by the transition when upper radius is reached
  34355. */
  34356. upperRadiusTransitionRange: number;
  34357. private _autoTransitionRange;
  34358. /**
  34359. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34360. */
  34361. /**
  34362. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34363. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34364. */
  34365. autoTransitionRange: boolean;
  34366. private _attachedCamera;
  34367. private _onAfterCheckInputsObserver;
  34368. private _onMeshTargetChangedObserver;
  34369. /**
  34370. * Initializes the behavior.
  34371. */
  34372. init(): void;
  34373. /**
  34374. * Attaches the behavior to its arc rotate camera.
  34375. * @param camera Defines the camera to attach the behavior to
  34376. */
  34377. attach(camera: ArcRotateCamera): void;
  34378. /**
  34379. * Detaches the behavior from its current arc rotate camera.
  34380. */
  34381. detach(): void;
  34382. private _radiusIsAnimating;
  34383. private _radiusBounceTransition;
  34384. private _animatables;
  34385. private _cachedWheelPrecision;
  34386. /**
  34387. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34388. * @param radiusLimit The limit to check against.
  34389. * @return Bool to indicate if at limit.
  34390. */
  34391. private _isRadiusAtLimit;
  34392. /**
  34393. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34394. * @param radiusDelta The delta by which to animate to. Can be negative.
  34395. */
  34396. private _applyBoundRadiusAnimation;
  34397. /**
  34398. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34399. */
  34400. protected _clearAnimationLocks(): void;
  34401. /**
  34402. * Stops and removes all animations that have been applied to the camera
  34403. */
  34404. stopAllAnimations(): void;
  34405. }
  34406. }
  34407. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34408. import { Behavior } from "babylonjs/Behaviors/behavior";
  34409. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34410. import { ExponentialEase } from "babylonjs/Animations/easing";
  34411. import { Nullable } from "babylonjs/types";
  34412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34413. import { Vector3 } from "babylonjs/Maths/math";
  34414. /**
  34415. * 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.
  34416. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34417. */
  34418. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34419. /**
  34420. * Gets the name of the behavior.
  34421. */
  34422. readonly name: string;
  34423. private _mode;
  34424. private _radiusScale;
  34425. private _positionScale;
  34426. private _defaultElevation;
  34427. private _elevationReturnTime;
  34428. private _elevationReturnWaitTime;
  34429. private _zoomStopsAnimation;
  34430. private _framingTime;
  34431. /**
  34432. * The easing function used by animations
  34433. */
  34434. static EasingFunction: ExponentialEase;
  34435. /**
  34436. * The easing mode used by animations
  34437. */
  34438. static EasingMode: number;
  34439. /**
  34440. * Sets the current mode used by the behavior
  34441. */
  34442. /**
  34443. * Gets current mode used by the behavior.
  34444. */
  34445. mode: number;
  34446. /**
  34447. * Sets the scale applied to the radius (1 by default)
  34448. */
  34449. /**
  34450. * Gets the scale applied to the radius
  34451. */
  34452. radiusScale: number;
  34453. /**
  34454. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34455. */
  34456. /**
  34457. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34458. */
  34459. positionScale: number;
  34460. /**
  34461. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34462. * behaviour is triggered, in radians.
  34463. */
  34464. /**
  34465. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34466. * behaviour is triggered, in radians.
  34467. */
  34468. defaultElevation: number;
  34469. /**
  34470. * Sets the time (in milliseconds) taken to return to the default beta position.
  34471. * Negative value indicates camera should not return to default.
  34472. */
  34473. /**
  34474. * Gets the time (in milliseconds) taken to return to the default beta position.
  34475. * Negative value indicates camera should not return to default.
  34476. */
  34477. elevationReturnTime: number;
  34478. /**
  34479. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34480. */
  34481. /**
  34482. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34483. */
  34484. elevationReturnWaitTime: number;
  34485. /**
  34486. * Sets the flag that indicates if user zooming should stop animation.
  34487. */
  34488. /**
  34489. * Gets the flag that indicates if user zooming should stop animation.
  34490. */
  34491. zoomStopsAnimation: boolean;
  34492. /**
  34493. * Sets the transition time when framing the mesh, in milliseconds
  34494. */
  34495. /**
  34496. * Gets the transition time when framing the mesh, in milliseconds
  34497. */
  34498. framingTime: number;
  34499. /**
  34500. * Define if the behavior should automatically change the configured
  34501. * camera limits and sensibilities.
  34502. */
  34503. autoCorrectCameraLimitsAndSensibility: boolean;
  34504. private _onPrePointerObservableObserver;
  34505. private _onAfterCheckInputsObserver;
  34506. private _onMeshTargetChangedObserver;
  34507. private _attachedCamera;
  34508. private _isPointerDown;
  34509. private _lastInteractionTime;
  34510. /**
  34511. * Initializes the behavior.
  34512. */
  34513. init(): void;
  34514. /**
  34515. * Attaches the behavior to its arc rotate camera.
  34516. * @param camera Defines the camera to attach the behavior to
  34517. */
  34518. attach(camera: ArcRotateCamera): void;
  34519. /**
  34520. * Detaches the behavior from its current arc rotate camera.
  34521. */
  34522. detach(): void;
  34523. private _animatables;
  34524. private _betaIsAnimating;
  34525. private _betaTransition;
  34526. private _radiusTransition;
  34527. private _vectorTransition;
  34528. /**
  34529. * Targets the given mesh and updates zoom level accordingly.
  34530. * @param mesh The mesh to target.
  34531. * @param radius Optional. If a cached radius position already exists, overrides default.
  34532. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34535. */
  34536. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34537. /**
  34538. * Targets the given mesh with its children and updates zoom level accordingly.
  34539. * @param mesh The mesh to target.
  34540. * @param radius Optional. If a cached radius position already exists, overrides default.
  34541. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34542. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34543. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34544. */
  34545. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34546. /**
  34547. * Targets the given meshes with their children and updates zoom level accordingly.
  34548. * @param meshes The mesh to target.
  34549. * @param radius Optional. If a cached radius position already exists, overrides default.
  34550. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34553. */
  34554. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34555. /**
  34556. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34557. * @param minimumWorld Determines the smaller position of the bounding box extend
  34558. * @param maximumWorld Determines the bigger position of the bounding box extend
  34559. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34560. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34561. */
  34562. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34563. /**
  34564. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34565. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34566. * frustum width.
  34567. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34568. * to fully enclose the mesh in the viewing frustum.
  34569. */
  34570. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34571. /**
  34572. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34573. * is automatically returned to its default position (expected to be above ground plane).
  34574. */
  34575. private _maintainCameraAboveGround;
  34576. /**
  34577. * Returns the frustum slope based on the canvas ratio and camera FOV
  34578. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34579. */
  34580. private _getFrustumSlope;
  34581. /**
  34582. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34583. */
  34584. private _clearAnimationLocks;
  34585. /**
  34586. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34587. */
  34588. private _applyUserInteraction;
  34589. /**
  34590. * Stops and removes all animations that have been applied to the camera
  34591. */
  34592. stopAllAnimations(): void;
  34593. /**
  34594. * Gets a value indicating if the user is moving the camera
  34595. */
  34596. readonly isUserIsMoving: boolean;
  34597. /**
  34598. * The camera can move all the way towards the mesh.
  34599. */
  34600. static IgnoreBoundsSizeMode: number;
  34601. /**
  34602. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34603. */
  34604. static FitFrustumSidesMode: number;
  34605. }
  34606. }
  34607. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34608. import { Nullable } from "babylonjs/types";
  34609. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34610. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34611. /**
  34612. * Manage the pointers inputs to control an arc rotate camera.
  34613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34614. */
  34615. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34616. /**
  34617. * Defines the camera the input is attached to.
  34618. */
  34619. camera: ArcRotateCamera;
  34620. /**
  34621. * Defines the buttons associated with the input to handle camera move.
  34622. */
  34623. buttons: number[];
  34624. /**
  34625. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34626. */
  34627. angularSensibilityX: number;
  34628. /**
  34629. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34630. */
  34631. angularSensibilityY: number;
  34632. /**
  34633. * Defines the pointer pinch precision or how fast is the camera zooming.
  34634. */
  34635. pinchPrecision: number;
  34636. /**
  34637. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34638. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34639. */
  34640. pinchDeltaPercentage: number;
  34641. /**
  34642. * Defines the pointer panning sensibility or how fast is the camera moving.
  34643. */
  34644. panningSensibility: number;
  34645. /**
  34646. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34647. */
  34648. multiTouchPanning: boolean;
  34649. /**
  34650. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34651. */
  34652. multiTouchPanAndZoom: boolean;
  34653. /**
  34654. * Revers pinch action direction.
  34655. */
  34656. pinchInwards: boolean;
  34657. private _isPanClick;
  34658. private _pointerInput;
  34659. private _observer;
  34660. private _onMouseMove;
  34661. private _onGestureStart;
  34662. private _onGesture;
  34663. private _MSGestureHandler;
  34664. private _onLostFocus;
  34665. private _onContextMenu;
  34666. /**
  34667. * Attach the input controls to a specific dom element to get the input from.
  34668. * @param element Defines the element the controls should be listened from
  34669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34670. */
  34671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34672. /**
  34673. * Detach the current controls from the specified dom element.
  34674. * @param element Defines the element to stop listening the inputs from
  34675. */
  34676. detachControl(element: Nullable<HTMLElement>): void;
  34677. /**
  34678. * Gets the class name of the current intput.
  34679. * @returns the class name
  34680. */
  34681. getClassName(): string;
  34682. /**
  34683. * Get the friendly name associated with the input class.
  34684. * @returns the input friendly name
  34685. */
  34686. getSimpleName(): string;
  34687. }
  34688. }
  34689. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34690. import { Nullable } from "babylonjs/types";
  34691. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34692. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34693. /**
  34694. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34696. */
  34697. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34698. /**
  34699. * Defines the camera the input is attached to.
  34700. */
  34701. camera: ArcRotateCamera;
  34702. /**
  34703. * Defines the list of key codes associated with the up action (increase alpha)
  34704. */
  34705. keysUp: number[];
  34706. /**
  34707. * Defines the list of key codes associated with the down action (decrease alpha)
  34708. */
  34709. keysDown: number[];
  34710. /**
  34711. * Defines the list of key codes associated with the left action (increase beta)
  34712. */
  34713. keysLeft: number[];
  34714. /**
  34715. * Defines the list of key codes associated with the right action (decrease beta)
  34716. */
  34717. keysRight: number[];
  34718. /**
  34719. * Defines the list of key codes associated with the reset action.
  34720. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34721. */
  34722. keysReset: number[];
  34723. /**
  34724. * Defines the panning sensibility of the inputs.
  34725. * (How fast is the camera paning)
  34726. */
  34727. panningSensibility: number;
  34728. /**
  34729. * Defines the zooming sensibility of the inputs.
  34730. * (How fast is the camera zooming)
  34731. */
  34732. zoomingSensibility: number;
  34733. /**
  34734. * Defines wether maintaining the alt key down switch the movement mode from
  34735. * orientation to zoom.
  34736. */
  34737. useAltToZoom: boolean;
  34738. /**
  34739. * Rotation speed of the camera
  34740. */
  34741. angularSpeed: number;
  34742. private _keys;
  34743. private _ctrlPressed;
  34744. private _altPressed;
  34745. private _onCanvasBlurObserver;
  34746. private _onKeyboardObserver;
  34747. private _engine;
  34748. private _scene;
  34749. /**
  34750. * Attach the input controls to a specific dom element to get the input from.
  34751. * @param element Defines the element the controls should be listened from
  34752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34753. */
  34754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34755. /**
  34756. * Detach the current controls from the specified dom element.
  34757. * @param element Defines the element to stop listening the inputs from
  34758. */
  34759. detachControl(element: Nullable<HTMLElement>): void;
  34760. /**
  34761. * Update the current camera state depending on the inputs that have been used this frame.
  34762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34763. */
  34764. checkInputs(): void;
  34765. /**
  34766. * Gets the class name of the current intput.
  34767. * @returns the class name
  34768. */
  34769. getClassName(): string;
  34770. /**
  34771. * Get the friendly name associated with the input class.
  34772. * @returns the input friendly name
  34773. */
  34774. getSimpleName(): string;
  34775. }
  34776. }
  34777. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34778. import { Nullable } from "babylonjs/types";
  34779. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34780. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34781. /**
  34782. * Manage the mouse wheel inputs to control an arc rotate camera.
  34783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34784. */
  34785. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34786. /**
  34787. * Defines the camera the input is attached to.
  34788. */
  34789. camera: ArcRotateCamera;
  34790. /**
  34791. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34792. */
  34793. wheelPrecision: number;
  34794. /**
  34795. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34796. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34797. */
  34798. wheelDeltaPercentage: number;
  34799. private _wheel;
  34800. private _observer;
  34801. /**
  34802. * Attach the input controls to a specific dom element to get the input from.
  34803. * @param element Defines the element the controls should be listened from
  34804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34805. */
  34806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34807. /**
  34808. * Detach the current controls from the specified dom element.
  34809. * @param element Defines the element to stop listening the inputs from
  34810. */
  34811. detachControl(element: Nullable<HTMLElement>): void;
  34812. /**
  34813. * Gets the class name of the current intput.
  34814. * @returns the class name
  34815. */
  34816. getClassName(): string;
  34817. /**
  34818. * Get the friendly name associated with the input class.
  34819. * @returns the input friendly name
  34820. */
  34821. getSimpleName(): string;
  34822. }
  34823. }
  34824. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34825. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34826. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34827. /**
  34828. * Default Inputs manager for the ArcRotateCamera.
  34829. * It groups all the default supported inputs for ease of use.
  34830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34831. */
  34832. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34833. /**
  34834. * Instantiates a new ArcRotateCameraInputsManager.
  34835. * @param camera Defines the camera the inputs belong to
  34836. */
  34837. constructor(camera: ArcRotateCamera);
  34838. /**
  34839. * Add mouse wheel input support to the input manager.
  34840. * @returns the current input manager
  34841. */
  34842. addMouseWheel(): ArcRotateCameraInputsManager;
  34843. /**
  34844. * Add pointers input support to the input manager.
  34845. * @returns the current input manager
  34846. */
  34847. addPointers(): ArcRotateCameraInputsManager;
  34848. /**
  34849. * Add keyboard input support to the input manager.
  34850. * @returns the current input manager
  34851. */
  34852. addKeyboard(): ArcRotateCameraInputsManager;
  34853. }
  34854. }
  34855. declare module "babylonjs/Cameras/arcRotateCamera" {
  34856. import { Observable } from "babylonjs/Misc/observable";
  34857. import { Nullable } from "babylonjs/types";
  34858. import { Scene } from "babylonjs/scene";
  34859. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34861. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34862. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34863. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34864. import { Camera } from "babylonjs/Cameras/camera";
  34865. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34866. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34867. import { Collider } from "babylonjs/Collisions/collider";
  34868. /**
  34869. * This represents an orbital type of camera.
  34870. *
  34871. * 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.
  34872. * 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.
  34873. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34874. */
  34875. export class ArcRotateCamera extends TargetCamera {
  34876. /**
  34877. * Defines the rotation angle of the camera along the longitudinal axis.
  34878. */
  34879. alpha: number;
  34880. /**
  34881. * Defines the rotation angle of the camera along the latitudinal axis.
  34882. */
  34883. beta: number;
  34884. /**
  34885. * Defines the radius of the camera from it s target point.
  34886. */
  34887. radius: number;
  34888. protected _target: Vector3;
  34889. protected _targetHost: Nullable<AbstractMesh>;
  34890. /**
  34891. * Defines the target point of the camera.
  34892. * The camera looks towards it form the radius distance.
  34893. */
  34894. target: Vector3;
  34895. /**
  34896. * Define the current local position of the camera in the scene
  34897. */
  34898. position: Vector3;
  34899. /**
  34900. * Current inertia value on the longitudinal axis.
  34901. * The bigger this number the longer it will take for the camera to stop.
  34902. */
  34903. inertialAlphaOffset: number;
  34904. /**
  34905. * Current inertia value on the latitudinal axis.
  34906. * The bigger this number the longer it will take for the camera to stop.
  34907. */
  34908. inertialBetaOffset: number;
  34909. /**
  34910. * Current inertia value on the radius axis.
  34911. * The bigger this number the longer it will take for the camera to stop.
  34912. */
  34913. inertialRadiusOffset: number;
  34914. /**
  34915. * Minimum allowed angle on the longitudinal axis.
  34916. * This can help limiting how the Camera is able to move in the scene.
  34917. */
  34918. lowerAlphaLimit: Nullable<number>;
  34919. /**
  34920. * Maximum allowed angle on the longitudinal axis.
  34921. * This can help limiting how the Camera is able to move in the scene.
  34922. */
  34923. upperAlphaLimit: Nullable<number>;
  34924. /**
  34925. * Minimum allowed angle on the latitudinal axis.
  34926. * This can help limiting how the Camera is able to move in the scene.
  34927. */
  34928. lowerBetaLimit: number;
  34929. /**
  34930. * Maximum allowed angle on the latitudinal axis.
  34931. * This can help limiting how the Camera is able to move in the scene.
  34932. */
  34933. upperBetaLimit: number;
  34934. /**
  34935. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34936. * This can help limiting how the Camera is able to move in the scene.
  34937. */
  34938. lowerRadiusLimit: Nullable<number>;
  34939. /**
  34940. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34941. * This can help limiting how the Camera is able to move in the scene.
  34942. */
  34943. upperRadiusLimit: Nullable<number>;
  34944. /**
  34945. * Defines the current inertia value used during panning of the camera along the X axis.
  34946. */
  34947. inertialPanningX: number;
  34948. /**
  34949. * Defines the current inertia value used during panning of the camera along the Y axis.
  34950. */
  34951. inertialPanningY: number;
  34952. /**
  34953. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34954. * Basically if your fingers moves away from more than this distance you will be considered
  34955. * in pinch mode.
  34956. */
  34957. pinchToPanMaxDistance: number;
  34958. /**
  34959. * Defines the maximum distance the camera can pan.
  34960. * This could help keeping the cammera always in your scene.
  34961. */
  34962. panningDistanceLimit: Nullable<number>;
  34963. /**
  34964. * Defines the target of the camera before paning.
  34965. */
  34966. panningOriginTarget: Vector3;
  34967. /**
  34968. * Defines the value of the inertia used during panning.
  34969. * 0 would mean stop inertia and one would mean no decelleration at all.
  34970. */
  34971. panningInertia: number;
  34972. /**
  34973. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34974. */
  34975. angularSensibilityX: number;
  34976. /**
  34977. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34978. */
  34979. angularSensibilityY: number;
  34980. /**
  34981. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34982. */
  34983. pinchPrecision: number;
  34984. /**
  34985. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34986. * It will be used instead of pinchDeltaPrecision if different from 0.
  34987. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34988. */
  34989. pinchDeltaPercentage: number;
  34990. /**
  34991. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34992. */
  34993. panningSensibility: number;
  34994. /**
  34995. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34996. */
  34997. keysUp: number[];
  34998. /**
  34999. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35000. */
  35001. keysDown: number[];
  35002. /**
  35003. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35004. */
  35005. keysLeft: number[];
  35006. /**
  35007. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35008. */
  35009. keysRight: number[];
  35010. /**
  35011. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35012. */
  35013. wheelPrecision: number;
  35014. /**
  35015. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35016. * It will be used instead of pinchDeltaPrecision if different from 0.
  35017. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35018. */
  35019. wheelDeltaPercentage: number;
  35020. /**
  35021. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35022. */
  35023. zoomOnFactor: number;
  35024. /**
  35025. * Defines a screen offset for the camera position.
  35026. */
  35027. targetScreenOffset: Vector2;
  35028. /**
  35029. * Allows the camera to be completely reversed.
  35030. * If false the camera can not arrive upside down.
  35031. */
  35032. allowUpsideDown: boolean;
  35033. /**
  35034. * Define if double tap/click is used to restore the previously saved state of the camera.
  35035. */
  35036. useInputToRestoreState: boolean;
  35037. /** @hidden */
  35038. _viewMatrix: Matrix;
  35039. /** @hidden */
  35040. _useCtrlForPanning: boolean;
  35041. /** @hidden */
  35042. _panningMouseButton: number;
  35043. /**
  35044. * Defines the input associated to the camera.
  35045. */
  35046. inputs: ArcRotateCameraInputsManager;
  35047. /** @hidden */
  35048. _reset: () => void;
  35049. /**
  35050. * Defines the allowed panning axis.
  35051. */
  35052. panningAxis: Vector3;
  35053. protected _localDirection: Vector3;
  35054. protected _transformedDirection: Vector3;
  35055. private _bouncingBehavior;
  35056. /**
  35057. * Gets the bouncing behavior of the camera if it has been enabled.
  35058. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35059. */
  35060. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35061. /**
  35062. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35064. */
  35065. useBouncingBehavior: boolean;
  35066. private _framingBehavior;
  35067. /**
  35068. * Gets the framing behavior of the camera if it has been enabled.
  35069. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35070. */
  35071. readonly framingBehavior: Nullable<FramingBehavior>;
  35072. /**
  35073. * Defines if the framing behavior of the camera is enabled on the camera.
  35074. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35075. */
  35076. useFramingBehavior: boolean;
  35077. private _autoRotationBehavior;
  35078. /**
  35079. * Gets the auto rotation behavior of the camera if it has been enabled.
  35080. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35081. */
  35082. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35083. /**
  35084. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35086. */
  35087. useAutoRotationBehavior: boolean;
  35088. /**
  35089. * Observable triggered when the mesh target has been changed on the camera.
  35090. */
  35091. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35092. /**
  35093. * Event raised when the camera is colliding with a mesh.
  35094. */
  35095. onCollide: (collidedMesh: AbstractMesh) => void;
  35096. /**
  35097. * Defines whether the camera should check collision with the objects oh the scene.
  35098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35099. */
  35100. checkCollisions: boolean;
  35101. /**
  35102. * Defines the collision radius of the camera.
  35103. * This simulates a sphere around the camera.
  35104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35105. */
  35106. collisionRadius: Vector3;
  35107. protected _collider: Collider;
  35108. protected _previousPosition: Vector3;
  35109. protected _collisionVelocity: Vector3;
  35110. protected _newPosition: Vector3;
  35111. protected _previousAlpha: number;
  35112. protected _previousBeta: number;
  35113. protected _previousRadius: number;
  35114. protected _collisionTriggered: boolean;
  35115. protected _targetBoundingCenter: Nullable<Vector3>;
  35116. private _computationVector;
  35117. private _tempAxisVector;
  35118. private _tempAxisRotationMatrix;
  35119. /**
  35120. * Instantiates a new ArcRotateCamera in a given scene
  35121. * @param name Defines the name of the camera
  35122. * @param alpha Defines the camera rotation along the logitudinal axis
  35123. * @param beta Defines the camera rotation along the latitudinal axis
  35124. * @param radius Defines the camera distance from its target
  35125. * @param target Defines the camera target
  35126. * @param scene Defines the scene the camera belongs to
  35127. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35128. */
  35129. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35130. /** @hidden */
  35131. _initCache(): void;
  35132. /** @hidden */
  35133. _updateCache(ignoreParentClass?: boolean): void;
  35134. protected _getTargetPosition(): Vector3;
  35135. private _storedAlpha;
  35136. private _storedBeta;
  35137. private _storedRadius;
  35138. private _storedTarget;
  35139. /**
  35140. * Stores the current state of the camera (alpha, beta, radius and target)
  35141. * @returns the camera itself
  35142. */
  35143. storeState(): Camera;
  35144. /**
  35145. * @hidden
  35146. * Restored camera state. You must call storeState() first
  35147. */
  35148. _restoreStateValues(): boolean;
  35149. /** @hidden */
  35150. _isSynchronizedViewMatrix(): boolean;
  35151. /**
  35152. * Attached controls to the current camera.
  35153. * @param element Defines the element the controls should be listened from
  35154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35155. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35156. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35157. */
  35158. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35159. /**
  35160. * Detach the current controls from the camera.
  35161. * The camera will stop reacting to inputs.
  35162. * @param element Defines the element to stop listening the inputs from
  35163. */
  35164. detachControl(element: HTMLElement): void;
  35165. /** @hidden */
  35166. _checkInputs(): void;
  35167. protected _checkLimits(): void;
  35168. /**
  35169. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35170. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35171. */
  35172. rebuildAnglesAndRadius(updateView?: boolean): void;
  35173. /**
  35174. * Use a position to define the current camera related information like aplha, beta and radius
  35175. * @param position Defines the position to set the camera at
  35176. */
  35177. setPosition(position: Vector3): void;
  35178. /**
  35179. * Defines the target the camera should look at.
  35180. * This will automatically adapt alpha beta and radius to fit within the new target.
  35181. * @param target Defines the new target as a Vector or a mesh
  35182. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35183. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35184. */
  35185. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35186. /** @hidden */
  35187. _getViewMatrix(): Matrix;
  35188. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35189. /**
  35190. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35191. * @param meshes Defines the mesh to zoom on
  35192. * @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)
  35193. */
  35194. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35195. /**
  35196. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35197. * The target will be changed but the radius
  35198. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35199. * @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)
  35200. */
  35201. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35202. min: Vector3;
  35203. max: Vector3;
  35204. distance: number;
  35205. }, doNotUpdateMaxZ?: boolean): void;
  35206. /**
  35207. * @override
  35208. * Override Camera.createRigCamera
  35209. */
  35210. createRigCamera(name: string, cameraIndex: number): Camera;
  35211. /**
  35212. * @hidden
  35213. * @override
  35214. * Override Camera._updateRigCameras
  35215. */
  35216. _updateRigCameras(): void;
  35217. /**
  35218. * Destroy the camera and release the current resources hold by it.
  35219. */
  35220. dispose(): void;
  35221. /**
  35222. * Gets the current object class name.
  35223. * @return the class name
  35224. */
  35225. getClassName(): string;
  35226. }
  35227. }
  35228. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35229. import { Behavior } from "babylonjs/Behaviors/behavior";
  35230. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35231. /**
  35232. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35233. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35234. */
  35235. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35236. /**
  35237. * Gets the name of the behavior.
  35238. */
  35239. readonly name: string;
  35240. private _zoomStopsAnimation;
  35241. private _idleRotationSpeed;
  35242. private _idleRotationWaitTime;
  35243. private _idleRotationSpinupTime;
  35244. /**
  35245. * Sets the flag that indicates if user zooming should stop animation.
  35246. */
  35247. /**
  35248. * Gets the flag that indicates if user zooming should stop animation.
  35249. */
  35250. zoomStopsAnimation: boolean;
  35251. /**
  35252. * Sets the default speed at which the camera rotates around the model.
  35253. */
  35254. /**
  35255. * Gets the default speed at which the camera rotates around the model.
  35256. */
  35257. idleRotationSpeed: number;
  35258. /**
  35259. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35260. */
  35261. /**
  35262. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35263. */
  35264. idleRotationWaitTime: number;
  35265. /**
  35266. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35267. */
  35268. /**
  35269. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35270. */
  35271. idleRotationSpinupTime: number;
  35272. /**
  35273. * Gets a value indicating if the camera is currently rotating because of this behavior
  35274. */
  35275. readonly rotationInProgress: boolean;
  35276. private _onPrePointerObservableObserver;
  35277. private _onAfterCheckInputsObserver;
  35278. private _attachedCamera;
  35279. private _isPointerDown;
  35280. private _lastFrameTime;
  35281. private _lastInteractionTime;
  35282. private _cameraRotationSpeed;
  35283. /**
  35284. * Initializes the behavior.
  35285. */
  35286. init(): void;
  35287. /**
  35288. * Attaches the behavior to its arc rotate camera.
  35289. * @param camera Defines the camera to attach the behavior to
  35290. */
  35291. attach(camera: ArcRotateCamera): void;
  35292. /**
  35293. * Detaches the behavior from its current arc rotate camera.
  35294. */
  35295. detach(): void;
  35296. /**
  35297. * Returns true if user is scrolling.
  35298. * @return true if user is scrolling.
  35299. */
  35300. private _userIsZooming;
  35301. private _lastFrameRadius;
  35302. private _shouldAnimationStopForInteraction;
  35303. /**
  35304. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35305. */
  35306. private _applyUserInteraction;
  35307. private _userIsMoving;
  35308. }
  35309. }
  35310. declare module "babylonjs/Behaviors/Cameras/index" {
  35311. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35312. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35313. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35314. }
  35315. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35316. import { Mesh } from "babylonjs/Meshes/mesh";
  35317. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35318. import { Behavior } from "babylonjs/Behaviors/behavior";
  35319. /**
  35320. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35321. */
  35322. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35323. private ui;
  35324. /**
  35325. * The name of the behavior
  35326. */
  35327. name: string;
  35328. /**
  35329. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35330. */
  35331. distanceAwayFromFace: number;
  35332. /**
  35333. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35334. */
  35335. distanceAwayFromBottomOfFace: number;
  35336. private _faceVectors;
  35337. private _target;
  35338. private _scene;
  35339. private _onRenderObserver;
  35340. private _tmpMatrix;
  35341. private _tmpVector;
  35342. /**
  35343. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35344. * @param ui The transform node that should be attched to the mesh
  35345. */
  35346. constructor(ui: TransformNode);
  35347. /**
  35348. * Initializes the behavior
  35349. */
  35350. init(): void;
  35351. private _closestFace;
  35352. private _zeroVector;
  35353. private _lookAtTmpMatrix;
  35354. private _lookAtToRef;
  35355. /**
  35356. * Attaches the AttachToBoxBehavior to the passed in mesh
  35357. * @param target The mesh that the specified node will be attached to
  35358. */
  35359. attach(target: Mesh): void;
  35360. /**
  35361. * Detaches the behavior from the mesh
  35362. */
  35363. detach(): void;
  35364. }
  35365. }
  35366. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35367. import { Behavior } from "babylonjs/Behaviors/behavior";
  35368. import { Mesh } from "babylonjs/Meshes/mesh";
  35369. /**
  35370. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35371. */
  35372. export class FadeInOutBehavior implements Behavior<Mesh> {
  35373. /**
  35374. * Time in milliseconds to delay before fading in (Default: 0)
  35375. */
  35376. delay: number;
  35377. /**
  35378. * Time in milliseconds for the mesh to fade in (Default: 300)
  35379. */
  35380. fadeInTime: number;
  35381. private _millisecondsPerFrame;
  35382. private _hovered;
  35383. private _hoverValue;
  35384. private _ownerNode;
  35385. /**
  35386. * Instatiates the FadeInOutBehavior
  35387. */
  35388. constructor();
  35389. /**
  35390. * The name of the behavior
  35391. */
  35392. readonly name: string;
  35393. /**
  35394. * Initializes the behavior
  35395. */
  35396. init(): void;
  35397. /**
  35398. * Attaches the fade behavior on the passed in mesh
  35399. * @param ownerNode The mesh that will be faded in/out once attached
  35400. */
  35401. attach(ownerNode: Mesh): void;
  35402. /**
  35403. * Detaches the behavior from the mesh
  35404. */
  35405. detach(): void;
  35406. /**
  35407. * Triggers the mesh to begin fading in or out
  35408. * @param value if the object should fade in or out (true to fade in)
  35409. */
  35410. fadeIn(value: boolean): void;
  35411. private _update;
  35412. private _setAllVisibility;
  35413. }
  35414. }
  35415. declare module "babylonjs/Misc/pivotTools" {
  35416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35417. /**
  35418. * Class containing a set of static utilities functions for managing Pivots
  35419. * @hidden
  35420. */
  35421. export class PivotTools {
  35422. private static _PivotCached;
  35423. private static _OldPivotPoint;
  35424. private static _PivotTranslation;
  35425. private static _PivotTmpVector;
  35426. /** @hidden */
  35427. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35428. /** @hidden */
  35429. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35430. }
  35431. }
  35432. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35433. import { Scene } from "babylonjs/scene";
  35434. import { Vector4, Plane } from "babylonjs/Maths/math";
  35435. import { Mesh } from "babylonjs/Meshes/mesh";
  35436. /**
  35437. * Class containing static functions to help procedurally build meshes
  35438. */
  35439. export class PlaneBuilder {
  35440. /**
  35441. * Creates a plane mesh
  35442. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35443. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35444. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35448. * @param name defines the name of the mesh
  35449. * @param options defines the options used to create the mesh
  35450. * @param scene defines the hosting scene
  35451. * @returns the plane mesh
  35452. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35453. */
  35454. static CreatePlane(name: string, options: {
  35455. size?: number;
  35456. width?: number;
  35457. height?: number;
  35458. sideOrientation?: number;
  35459. frontUVs?: Vector4;
  35460. backUVs?: Vector4;
  35461. updatable?: boolean;
  35462. sourcePlane?: Plane;
  35463. }, scene: Scene): Mesh;
  35464. }
  35465. }
  35466. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35467. import { Behavior } from "babylonjs/Behaviors/behavior";
  35468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35469. import { Observable } from "babylonjs/Misc/observable";
  35470. import { Vector3 } from "babylonjs/Maths/math";
  35471. import { Ray } from "babylonjs/Culling/ray";
  35472. import "babylonjs/Meshes/Builders/planeBuilder";
  35473. /**
  35474. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35475. */
  35476. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35477. private static _AnyMouseID;
  35478. private _attachedNode;
  35479. private _dragPlane;
  35480. private _scene;
  35481. private _pointerObserver;
  35482. private _beforeRenderObserver;
  35483. private static _planeScene;
  35484. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35485. /**
  35486. * 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)
  35487. */
  35488. maxDragAngle: number;
  35489. /**
  35490. * @hidden
  35491. */
  35492. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35493. /**
  35494. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35495. */
  35496. currentDraggingPointerID: number;
  35497. /**
  35498. * The last position where the pointer hit the drag plane in world space
  35499. */
  35500. lastDragPosition: Vector3;
  35501. /**
  35502. * If the behavior is currently in a dragging state
  35503. */
  35504. dragging: boolean;
  35505. /**
  35506. * 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)
  35507. */
  35508. dragDeltaRatio: number;
  35509. /**
  35510. * If the drag plane orientation should be updated during the dragging (Default: true)
  35511. */
  35512. updateDragPlane: boolean;
  35513. private _debugMode;
  35514. private _moving;
  35515. /**
  35516. * Fires each time the attached mesh is dragged with the pointer
  35517. * * delta between last drag position and current drag position in world space
  35518. * * dragDistance along the drag axis
  35519. * * dragPlaneNormal normal of the current drag plane used during the drag
  35520. * * dragPlanePoint in world space where the drag intersects the drag plane
  35521. */
  35522. onDragObservable: Observable<{
  35523. delta: Vector3;
  35524. dragPlanePoint: Vector3;
  35525. dragPlaneNormal: Vector3;
  35526. dragDistance: number;
  35527. pointerId: number;
  35528. }>;
  35529. /**
  35530. * Fires each time a drag begins (eg. mouse down on mesh)
  35531. */
  35532. onDragStartObservable: Observable<{
  35533. dragPlanePoint: Vector3;
  35534. pointerId: number;
  35535. }>;
  35536. /**
  35537. * Fires each time a drag ends (eg. mouse release after drag)
  35538. */
  35539. onDragEndObservable: Observable<{
  35540. dragPlanePoint: Vector3;
  35541. pointerId: number;
  35542. }>;
  35543. /**
  35544. * If the attached mesh should be moved when dragged
  35545. */
  35546. moveAttached: boolean;
  35547. /**
  35548. * If the drag behavior will react to drag events (Default: true)
  35549. */
  35550. enabled: boolean;
  35551. /**
  35552. * If camera controls should be detached during the drag
  35553. */
  35554. detachCameraControls: boolean;
  35555. /**
  35556. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35557. */
  35558. useObjectOrienationForDragging: boolean;
  35559. private _options;
  35560. /**
  35561. * Creates a pointer drag behavior that can be attached to a mesh
  35562. * @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)
  35563. */
  35564. constructor(options?: {
  35565. dragAxis?: Vector3;
  35566. dragPlaneNormal?: Vector3;
  35567. });
  35568. /**
  35569. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35570. */
  35571. validateDrag: (targetPosition: Vector3) => boolean;
  35572. /**
  35573. * The name of the behavior
  35574. */
  35575. readonly name: string;
  35576. /**
  35577. * Initializes the behavior
  35578. */
  35579. init(): void;
  35580. private _tmpVector;
  35581. private _alternatePickedPoint;
  35582. private _worldDragAxis;
  35583. private _targetPosition;
  35584. private _attachedElement;
  35585. /**
  35586. * Attaches the drag behavior the passed in mesh
  35587. * @param ownerNode The mesh that will be dragged around once attached
  35588. */
  35589. attach(ownerNode: AbstractMesh): void;
  35590. /**
  35591. * Force relase the drag action by code.
  35592. */
  35593. releaseDrag(): void;
  35594. private _startDragRay;
  35595. private _lastPointerRay;
  35596. /**
  35597. * Simulates the start of a pointer drag event on the behavior
  35598. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35599. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35600. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35601. */
  35602. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35603. private _startDrag;
  35604. private _dragDelta;
  35605. private _moveDrag;
  35606. private _pickWithRayOnDragPlane;
  35607. private _pointA;
  35608. private _pointB;
  35609. private _pointC;
  35610. private _lineA;
  35611. private _lineB;
  35612. private _localAxis;
  35613. private _lookAt;
  35614. private _updateDragPlanePosition;
  35615. /**
  35616. * Detaches the behavior from the mesh
  35617. */
  35618. detach(): void;
  35619. }
  35620. }
  35621. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35622. import { Mesh } from "babylonjs/Meshes/mesh";
  35623. import { Behavior } from "babylonjs/Behaviors/behavior";
  35624. /**
  35625. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35626. */
  35627. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35628. private _dragBehaviorA;
  35629. private _dragBehaviorB;
  35630. private _startDistance;
  35631. private _initialScale;
  35632. private _targetScale;
  35633. private _ownerNode;
  35634. private _sceneRenderObserver;
  35635. /**
  35636. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35637. */
  35638. constructor();
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. readonly name: string;
  35643. /**
  35644. * Initializes the behavior
  35645. */
  35646. init(): void;
  35647. private _getCurrentDistance;
  35648. /**
  35649. * Attaches the scale behavior the passed in mesh
  35650. * @param ownerNode The mesh that will be scaled around once attached
  35651. */
  35652. attach(ownerNode: Mesh): void;
  35653. /**
  35654. * Detaches the behavior from the mesh
  35655. */
  35656. detach(): void;
  35657. }
  35658. }
  35659. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35660. import { Behavior } from "babylonjs/Behaviors/behavior";
  35661. import { Mesh } from "babylonjs/Meshes/mesh";
  35662. import { Observable } from "babylonjs/Misc/observable";
  35663. /**
  35664. * 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
  35665. */
  35666. export class SixDofDragBehavior implements Behavior<Mesh> {
  35667. private static _virtualScene;
  35668. private _ownerNode;
  35669. private _sceneRenderObserver;
  35670. private _scene;
  35671. private _targetPosition;
  35672. private _virtualOriginMesh;
  35673. private _virtualDragMesh;
  35674. private _pointerObserver;
  35675. private _moving;
  35676. private _startingOrientation;
  35677. /**
  35678. * 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)
  35679. */
  35680. private zDragFactor;
  35681. /**
  35682. * If the object should rotate to face the drag origin
  35683. */
  35684. rotateDraggedObject: boolean;
  35685. /**
  35686. * If the behavior is currently in a dragging state
  35687. */
  35688. dragging: boolean;
  35689. /**
  35690. * 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)
  35691. */
  35692. dragDeltaRatio: number;
  35693. /**
  35694. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35695. */
  35696. currentDraggingPointerID: number;
  35697. /**
  35698. * If camera controls should be detached during the drag
  35699. */
  35700. detachCameraControls: boolean;
  35701. /**
  35702. * Fires each time a drag starts
  35703. */
  35704. onDragStartObservable: Observable<{}>;
  35705. /**
  35706. * Fires each time a drag ends (eg. mouse release after drag)
  35707. */
  35708. onDragEndObservable: Observable<{}>;
  35709. /**
  35710. * 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
  35711. */
  35712. constructor();
  35713. /**
  35714. * The name of the behavior
  35715. */
  35716. readonly name: string;
  35717. /**
  35718. * Initializes the behavior
  35719. */
  35720. init(): void;
  35721. /**
  35722. * Attaches the scale behavior the passed in mesh
  35723. * @param ownerNode The mesh that will be scaled around once attached
  35724. */
  35725. attach(ownerNode: Mesh): void;
  35726. /**
  35727. * Detaches the behavior from the mesh
  35728. */
  35729. detach(): void;
  35730. }
  35731. }
  35732. declare module "babylonjs/Behaviors/Meshes/index" {
  35733. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35734. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35735. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35736. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35737. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35738. }
  35739. declare module "babylonjs/Behaviors/index" {
  35740. export * from "babylonjs/Behaviors/behavior";
  35741. export * from "babylonjs/Behaviors/Cameras/index";
  35742. export * from "babylonjs/Behaviors/Meshes/index";
  35743. }
  35744. declare module "babylonjs/Bones/boneIKController" {
  35745. import { Bone } from "babylonjs/Bones/bone";
  35746. import { Vector3 } from "babylonjs/Maths/math";
  35747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35748. import { Nullable } from "babylonjs/types";
  35749. /**
  35750. * Class used to apply inverse kinematics to bones
  35751. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35752. */
  35753. export class BoneIKController {
  35754. private static _tmpVecs;
  35755. private static _tmpQuat;
  35756. private static _tmpMats;
  35757. /**
  35758. * Gets or sets the target mesh
  35759. */
  35760. targetMesh: AbstractMesh;
  35761. /** Gets or sets the mesh used as pole */
  35762. poleTargetMesh: AbstractMesh;
  35763. /**
  35764. * Gets or sets the bone used as pole
  35765. */
  35766. poleTargetBone: Nullable<Bone>;
  35767. /**
  35768. * Gets or sets the target position
  35769. */
  35770. targetPosition: Vector3;
  35771. /**
  35772. * Gets or sets the pole target position
  35773. */
  35774. poleTargetPosition: Vector3;
  35775. /**
  35776. * Gets or sets the pole target local offset
  35777. */
  35778. poleTargetLocalOffset: Vector3;
  35779. /**
  35780. * Gets or sets the pole angle
  35781. */
  35782. poleAngle: number;
  35783. /**
  35784. * Gets or sets the mesh associated with the controller
  35785. */
  35786. mesh: AbstractMesh;
  35787. /**
  35788. * 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)
  35789. */
  35790. slerpAmount: number;
  35791. private _bone1Quat;
  35792. private _bone1Mat;
  35793. private _bone2Ang;
  35794. private _bone1;
  35795. private _bone2;
  35796. private _bone1Length;
  35797. private _bone2Length;
  35798. private _maxAngle;
  35799. private _maxReach;
  35800. private _rightHandedSystem;
  35801. private _bendAxis;
  35802. private _slerping;
  35803. private _adjustRoll;
  35804. /**
  35805. * Gets or sets maximum allowed angle
  35806. */
  35807. maxAngle: number;
  35808. /**
  35809. * Creates a new BoneIKController
  35810. * @param mesh defines the mesh to control
  35811. * @param bone defines the bone to control
  35812. * @param options defines options to set up the controller
  35813. */
  35814. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35815. targetMesh?: AbstractMesh;
  35816. poleTargetMesh?: AbstractMesh;
  35817. poleTargetBone?: Bone;
  35818. poleTargetLocalOffset?: Vector3;
  35819. poleAngle?: number;
  35820. bendAxis?: Vector3;
  35821. maxAngle?: number;
  35822. slerpAmount?: number;
  35823. });
  35824. private _setMaxAngle;
  35825. /**
  35826. * Force the controller to update the bones
  35827. */
  35828. update(): void;
  35829. }
  35830. }
  35831. declare module "babylonjs/Bones/boneLookController" {
  35832. import { Vector3, Space } from "babylonjs/Maths/math";
  35833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35834. import { Bone } from "babylonjs/Bones/bone";
  35835. /**
  35836. * Class used to make a bone look toward a point in space
  35837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35838. */
  35839. export class BoneLookController {
  35840. private static _tmpVecs;
  35841. private static _tmpQuat;
  35842. private static _tmpMats;
  35843. /**
  35844. * The target Vector3 that the bone will look at
  35845. */
  35846. target: Vector3;
  35847. /**
  35848. * The mesh that the bone is attached to
  35849. */
  35850. mesh: AbstractMesh;
  35851. /**
  35852. * The bone that will be looking to the target
  35853. */
  35854. bone: Bone;
  35855. /**
  35856. * The up axis of the coordinate system that is used when the bone is rotated
  35857. */
  35858. upAxis: Vector3;
  35859. /**
  35860. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35861. */
  35862. upAxisSpace: Space;
  35863. /**
  35864. * Used to make an adjustment to the yaw of the bone
  35865. */
  35866. adjustYaw: number;
  35867. /**
  35868. * Used to make an adjustment to the pitch of the bone
  35869. */
  35870. adjustPitch: number;
  35871. /**
  35872. * Used to make an adjustment to the roll of the bone
  35873. */
  35874. adjustRoll: number;
  35875. /**
  35876. * 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)
  35877. */
  35878. slerpAmount: number;
  35879. private _minYaw;
  35880. private _maxYaw;
  35881. private _minPitch;
  35882. private _maxPitch;
  35883. private _minYawSin;
  35884. private _minYawCos;
  35885. private _maxYawSin;
  35886. private _maxYawCos;
  35887. private _midYawConstraint;
  35888. private _minPitchTan;
  35889. private _maxPitchTan;
  35890. private _boneQuat;
  35891. private _slerping;
  35892. private _transformYawPitch;
  35893. private _transformYawPitchInv;
  35894. private _firstFrameSkipped;
  35895. private _yawRange;
  35896. private _fowardAxis;
  35897. /**
  35898. * Gets or sets the minimum yaw angle that the bone can look to
  35899. */
  35900. minYaw: number;
  35901. /**
  35902. * Gets or sets the maximum yaw angle that the bone can look to
  35903. */
  35904. maxYaw: number;
  35905. /**
  35906. * Gets or sets the minimum pitch angle that the bone can look to
  35907. */
  35908. minPitch: number;
  35909. /**
  35910. * Gets or sets the maximum pitch angle that the bone can look to
  35911. */
  35912. maxPitch: number;
  35913. /**
  35914. * Create a BoneLookController
  35915. * @param mesh the mesh that the bone belongs to
  35916. * @param bone the bone that will be looking to the target
  35917. * @param target the target Vector3 to look at
  35918. * @param options optional settings:
  35919. * * maxYaw: the maximum angle the bone will yaw to
  35920. * * minYaw: the minimum angle the bone will yaw to
  35921. * * maxPitch: the maximum angle the bone will pitch to
  35922. * * minPitch: the minimum angle the bone will yaw to
  35923. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35924. * * upAxis: the up axis of the coordinate system
  35925. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35926. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35927. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35928. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35929. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35930. * * adjustRoll: used to make an adjustment to the roll of the bone
  35931. **/
  35932. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35933. maxYaw?: number;
  35934. minYaw?: number;
  35935. maxPitch?: number;
  35936. minPitch?: number;
  35937. slerpAmount?: number;
  35938. upAxis?: Vector3;
  35939. upAxisSpace?: Space;
  35940. yawAxis?: Vector3;
  35941. pitchAxis?: Vector3;
  35942. adjustYaw?: number;
  35943. adjustPitch?: number;
  35944. adjustRoll?: number;
  35945. });
  35946. /**
  35947. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35948. */
  35949. update(): void;
  35950. private _getAngleDiff;
  35951. private _getAngleBetween;
  35952. private _isAngleBetween;
  35953. }
  35954. }
  35955. declare module "babylonjs/Bones/index" {
  35956. export * from "babylonjs/Bones/bone";
  35957. export * from "babylonjs/Bones/boneIKController";
  35958. export * from "babylonjs/Bones/boneLookController";
  35959. export * from "babylonjs/Bones/skeleton";
  35960. }
  35961. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35962. import { Nullable } from "babylonjs/types";
  35963. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35964. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35965. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35966. /**
  35967. * Manage the gamepad inputs to control an arc rotate camera.
  35968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35969. */
  35970. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35971. /**
  35972. * Defines the camera the input is attached to.
  35973. */
  35974. camera: ArcRotateCamera;
  35975. /**
  35976. * Defines the gamepad the input is gathering event from.
  35977. */
  35978. gamepad: Nullable<Gamepad>;
  35979. /**
  35980. * Defines the gamepad rotation sensiblity.
  35981. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35982. */
  35983. gamepadRotationSensibility: number;
  35984. /**
  35985. * Defines the gamepad move sensiblity.
  35986. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35987. */
  35988. gamepadMoveSensibility: number;
  35989. private _onGamepadConnectedObserver;
  35990. private _onGamepadDisconnectedObserver;
  35991. /**
  35992. * Attach the input controls to a specific dom element to get the input from.
  35993. * @param element Defines the element the controls should be listened from
  35994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35995. */
  35996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35997. /**
  35998. * Detach the current controls from the specified dom element.
  35999. * @param element Defines the element to stop listening the inputs from
  36000. */
  36001. detachControl(element: Nullable<HTMLElement>): void;
  36002. /**
  36003. * Update the current camera state depending on the inputs that have been used this frame.
  36004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36005. */
  36006. checkInputs(): void;
  36007. /**
  36008. * Gets the class name of the current intput.
  36009. * @returns the class name
  36010. */
  36011. getClassName(): string;
  36012. /**
  36013. * Get the friendly name associated with the input class.
  36014. * @returns the input friendly name
  36015. */
  36016. getSimpleName(): string;
  36017. }
  36018. }
  36019. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36020. import { Nullable } from "babylonjs/types";
  36021. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36022. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36023. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36024. interface ArcRotateCameraInputsManager {
  36025. /**
  36026. * Add orientation input support to the input manager.
  36027. * @returns the current input manager
  36028. */
  36029. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36030. }
  36031. }
  36032. /**
  36033. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36035. */
  36036. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36037. /**
  36038. * Defines the camera the input is attached to.
  36039. */
  36040. camera: ArcRotateCamera;
  36041. /**
  36042. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36043. */
  36044. alphaCorrection: number;
  36045. /**
  36046. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36047. */
  36048. gammaCorrection: number;
  36049. private _alpha;
  36050. private _gamma;
  36051. private _dirty;
  36052. private _deviceOrientationHandler;
  36053. /**
  36054. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36055. */
  36056. constructor();
  36057. /**
  36058. * Attach the input controls to a specific dom element to get the input from.
  36059. * @param element Defines the element the controls should be listened from
  36060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36061. */
  36062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36063. /** @hidden */
  36064. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36065. /**
  36066. * Update the current camera state depending on the inputs that have been used this frame.
  36067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36068. */
  36069. checkInputs(): void;
  36070. /**
  36071. * Detach the current controls from the specified dom element.
  36072. * @param element Defines the element to stop listening the inputs from
  36073. */
  36074. detachControl(element: Nullable<HTMLElement>): void;
  36075. /**
  36076. * Gets the class name of the current intput.
  36077. * @returns the class name
  36078. */
  36079. getClassName(): string;
  36080. /**
  36081. * Get the friendly name associated with the input class.
  36082. * @returns the input friendly name
  36083. */
  36084. getSimpleName(): string;
  36085. }
  36086. }
  36087. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36088. import { Nullable } from "babylonjs/types";
  36089. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36090. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36091. /**
  36092. * Listen to mouse events to control the camera.
  36093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36094. */
  36095. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36096. /**
  36097. * Defines the camera the input is attached to.
  36098. */
  36099. camera: FlyCamera;
  36100. /**
  36101. * Defines if touch is enabled. (Default is true.)
  36102. */
  36103. touchEnabled: boolean;
  36104. /**
  36105. * Defines the buttons associated with the input to handle camera rotation.
  36106. */
  36107. buttons: number[];
  36108. /**
  36109. * Assign buttons for Yaw control.
  36110. */
  36111. buttonsYaw: number[];
  36112. /**
  36113. * Assign buttons for Pitch control.
  36114. */
  36115. buttonsPitch: number[];
  36116. /**
  36117. * Assign buttons for Roll control.
  36118. */
  36119. buttonsRoll: number[];
  36120. /**
  36121. * Detect if any button is being pressed while mouse is moved.
  36122. * -1 = Mouse locked.
  36123. * 0 = Left button.
  36124. * 1 = Middle Button.
  36125. * 2 = Right Button.
  36126. */
  36127. activeButton: number;
  36128. /**
  36129. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36130. * Higher values reduce its sensitivity.
  36131. */
  36132. angularSensibility: number;
  36133. private _mousemoveCallback;
  36134. private _observer;
  36135. private _rollObserver;
  36136. private previousPosition;
  36137. private noPreventDefault;
  36138. private element;
  36139. /**
  36140. * Listen to mouse events to control the camera.
  36141. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36143. */
  36144. constructor(touchEnabled?: boolean);
  36145. /**
  36146. * Attach the mouse control to the HTML DOM element.
  36147. * @param element Defines the element that listens to the input events.
  36148. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36149. */
  36150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36151. /**
  36152. * Detach the current controls from the specified dom element.
  36153. * @param element Defines the element to stop listening the inputs from
  36154. */
  36155. detachControl(element: Nullable<HTMLElement>): void;
  36156. /**
  36157. * Gets the class name of the current input.
  36158. * @returns the class name.
  36159. */
  36160. getClassName(): string;
  36161. /**
  36162. * Get the friendly name associated with the input class.
  36163. * @returns the input's friendly name.
  36164. */
  36165. getSimpleName(): string;
  36166. private _pointerInput;
  36167. private _onMouseMove;
  36168. /**
  36169. * Rotate camera by mouse offset.
  36170. */
  36171. private rotateCamera;
  36172. }
  36173. }
  36174. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36175. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36176. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36177. /**
  36178. * Default Inputs manager for the FlyCamera.
  36179. * It groups all the default supported inputs for ease of use.
  36180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36181. */
  36182. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36183. /**
  36184. * Instantiates a new FlyCameraInputsManager.
  36185. * @param camera Defines the camera the inputs belong to.
  36186. */
  36187. constructor(camera: FlyCamera);
  36188. /**
  36189. * Add keyboard input support to the input manager.
  36190. * @returns the new FlyCameraKeyboardMoveInput().
  36191. */
  36192. addKeyboard(): FlyCameraInputsManager;
  36193. /**
  36194. * Add mouse input support to the input manager.
  36195. * @param touchEnabled Enable touch screen support.
  36196. * @returns the new FlyCameraMouseInput().
  36197. */
  36198. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36199. }
  36200. }
  36201. declare module "babylonjs/Cameras/flyCamera" {
  36202. import { Scene } from "babylonjs/scene";
  36203. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36205. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36206. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36207. /**
  36208. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36209. * such as in a 3D Space Shooter or a Flight Simulator.
  36210. */
  36211. export class FlyCamera extends TargetCamera {
  36212. /**
  36213. * Define the collision ellipsoid of the camera.
  36214. * This is helpful for simulating a camera body, like a player's body.
  36215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36216. */
  36217. ellipsoid: Vector3;
  36218. /**
  36219. * Define an offset for the position of the ellipsoid around the camera.
  36220. * This can be helpful if the camera is attached away from the player's body center,
  36221. * such as at its head.
  36222. */
  36223. ellipsoidOffset: Vector3;
  36224. /**
  36225. * Enable or disable collisions of the camera with the rest of the scene objects.
  36226. */
  36227. checkCollisions: boolean;
  36228. /**
  36229. * Enable or disable gravity on the camera.
  36230. */
  36231. applyGravity: boolean;
  36232. /**
  36233. * Define the current direction the camera is moving to.
  36234. */
  36235. cameraDirection: Vector3;
  36236. /**
  36237. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36238. * This overrides and empties cameraRotation.
  36239. */
  36240. rotationQuaternion: Quaternion;
  36241. /**
  36242. * Track Roll to maintain the wanted Rolling when looking around.
  36243. */
  36244. _trackRoll: number;
  36245. /**
  36246. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36247. */
  36248. rollCorrect: number;
  36249. /**
  36250. * Mimic a banked turn, Rolling the camera when Yawing.
  36251. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36252. */
  36253. bankedTurn: boolean;
  36254. /**
  36255. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36256. */
  36257. bankedTurnLimit: number;
  36258. /**
  36259. * Value of 0 disables the banked Roll.
  36260. * Value of 1 is equal to the Yaw angle in radians.
  36261. */
  36262. bankedTurnMultiplier: number;
  36263. /**
  36264. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36265. */
  36266. inputs: FlyCameraInputsManager;
  36267. /**
  36268. * Gets the input sensibility for mouse input.
  36269. * Higher values reduce sensitivity.
  36270. */
  36271. /**
  36272. * Sets the input sensibility for a mouse input.
  36273. * Higher values reduce sensitivity.
  36274. */
  36275. angularSensibility: number;
  36276. /**
  36277. * Get the keys for camera movement forward.
  36278. */
  36279. /**
  36280. * Set the keys for camera movement forward.
  36281. */
  36282. keysForward: number[];
  36283. /**
  36284. * Get the keys for camera movement backward.
  36285. */
  36286. keysBackward: number[];
  36287. /**
  36288. * Get the keys for camera movement up.
  36289. */
  36290. /**
  36291. * Set the keys for camera movement up.
  36292. */
  36293. keysUp: number[];
  36294. /**
  36295. * Get the keys for camera movement down.
  36296. */
  36297. /**
  36298. * Set the keys for camera movement down.
  36299. */
  36300. keysDown: number[];
  36301. /**
  36302. * Get the keys for camera movement left.
  36303. */
  36304. /**
  36305. * Set the keys for camera movement left.
  36306. */
  36307. keysLeft: number[];
  36308. /**
  36309. * Set the keys for camera movement right.
  36310. */
  36311. /**
  36312. * Set the keys for camera movement right.
  36313. */
  36314. keysRight: number[];
  36315. /**
  36316. * Event raised when the camera collides with a mesh in the scene.
  36317. */
  36318. onCollide: (collidedMesh: AbstractMesh) => void;
  36319. private _collider;
  36320. private _needMoveForGravity;
  36321. private _oldPosition;
  36322. private _diffPosition;
  36323. private _newPosition;
  36324. /** @hidden */
  36325. _localDirection: Vector3;
  36326. /** @hidden */
  36327. _transformedDirection: Vector3;
  36328. /**
  36329. * Instantiates a FlyCamera.
  36330. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36331. * such as in a 3D Space Shooter or a Flight Simulator.
  36332. * @param name Define the name of the camera in the scene.
  36333. * @param position Define the starting position of the camera in the scene.
  36334. * @param scene Define the scene the camera belongs to.
  36335. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36336. */
  36337. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36338. /**
  36339. * Attach a control to the HTML DOM element.
  36340. * @param element Defines the element that listens to the input events.
  36341. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36342. */
  36343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36344. /**
  36345. * Detach a control from the HTML DOM element.
  36346. * The camera will stop reacting to that input.
  36347. * @param element Defines the element that listens to the input events.
  36348. */
  36349. detachControl(element: HTMLElement): void;
  36350. private _collisionMask;
  36351. /**
  36352. * Get the mask that the camera ignores in collision events.
  36353. */
  36354. /**
  36355. * Set the mask that the camera ignores in collision events.
  36356. */
  36357. collisionMask: number;
  36358. /** @hidden */
  36359. _collideWithWorld(displacement: Vector3): void;
  36360. /** @hidden */
  36361. private _onCollisionPositionChange;
  36362. /** @hidden */
  36363. _checkInputs(): void;
  36364. /** @hidden */
  36365. _decideIfNeedsToMove(): boolean;
  36366. /** @hidden */
  36367. _updatePosition(): void;
  36368. /**
  36369. * Restore the Roll to its target value at the rate specified.
  36370. * @param rate - Higher means slower restoring.
  36371. * @hidden
  36372. */
  36373. restoreRoll(rate: number): void;
  36374. /**
  36375. * Destroy the camera and release the current resources held by it.
  36376. */
  36377. dispose(): void;
  36378. /**
  36379. * Get the current object class name.
  36380. * @returns the class name.
  36381. */
  36382. getClassName(): string;
  36383. }
  36384. }
  36385. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36386. import { Nullable } from "babylonjs/types";
  36387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36388. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36389. /**
  36390. * Listen to keyboard events to control the camera.
  36391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36392. */
  36393. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36394. /**
  36395. * Defines the camera the input is attached to.
  36396. */
  36397. camera: FlyCamera;
  36398. /**
  36399. * The list of keyboard keys used to control the forward move of the camera.
  36400. */
  36401. keysForward: number[];
  36402. /**
  36403. * The list of keyboard keys used to control the backward move of the camera.
  36404. */
  36405. keysBackward: number[];
  36406. /**
  36407. * The list of keyboard keys used to control the forward move of the camera.
  36408. */
  36409. keysUp: number[];
  36410. /**
  36411. * The list of keyboard keys used to control the backward move of the camera.
  36412. */
  36413. keysDown: number[];
  36414. /**
  36415. * The list of keyboard keys used to control the right strafe move of the camera.
  36416. */
  36417. keysRight: number[];
  36418. /**
  36419. * The list of keyboard keys used to control the left strafe move of the camera.
  36420. */
  36421. keysLeft: number[];
  36422. private _keys;
  36423. private _onCanvasBlurObserver;
  36424. private _onKeyboardObserver;
  36425. private _engine;
  36426. private _scene;
  36427. /**
  36428. * Attach the input controls to a specific dom element to get the input from.
  36429. * @param element Defines the element the controls should be listened from
  36430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36431. */
  36432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36433. /**
  36434. * Detach the current controls from the specified dom element.
  36435. * @param element Defines the element to stop listening the inputs from
  36436. */
  36437. detachControl(element: Nullable<HTMLElement>): void;
  36438. /**
  36439. * Gets the class name of the current intput.
  36440. * @returns the class name
  36441. */
  36442. getClassName(): string;
  36443. /** @hidden */
  36444. _onLostFocus(e: FocusEvent): void;
  36445. /**
  36446. * Get the friendly name associated with the input class.
  36447. * @returns the input friendly name
  36448. */
  36449. getSimpleName(): string;
  36450. /**
  36451. * Update the current camera state depending on the inputs that have been used this frame.
  36452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36453. */
  36454. checkInputs(): void;
  36455. }
  36456. }
  36457. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36458. import { Nullable } from "babylonjs/types";
  36459. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36460. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36461. module "babylonjs/Cameras/freeCameraInputsManager" {
  36462. interface FreeCameraInputsManager {
  36463. /**
  36464. * Add orientation input support to the input manager.
  36465. * @returns the current input manager
  36466. */
  36467. addDeviceOrientation(): FreeCameraInputsManager;
  36468. }
  36469. }
  36470. /**
  36471. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36472. * Screen rotation is taken into account.
  36473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36474. */
  36475. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36476. private _camera;
  36477. private _screenOrientationAngle;
  36478. private _constantTranform;
  36479. private _screenQuaternion;
  36480. private _alpha;
  36481. private _beta;
  36482. private _gamma;
  36483. /**
  36484. * Instantiates a new input
  36485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36486. */
  36487. constructor();
  36488. /**
  36489. * Define the camera controlled by the input.
  36490. */
  36491. camera: FreeCamera;
  36492. /**
  36493. * Attach the input controls to a specific dom element to get the input from.
  36494. * @param element Defines the element the controls should be listened from
  36495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36496. */
  36497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36498. private _orientationChanged;
  36499. private _deviceOrientation;
  36500. /**
  36501. * Detach the current controls from the specified dom element.
  36502. * @param element Defines the element to stop listening the inputs from
  36503. */
  36504. detachControl(element: Nullable<HTMLElement>): void;
  36505. /**
  36506. * Update the current camera state depending on the inputs that have been used this frame.
  36507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36508. */
  36509. checkInputs(): void;
  36510. /**
  36511. * Gets the class name of the current intput.
  36512. * @returns the class name
  36513. */
  36514. getClassName(): string;
  36515. /**
  36516. * Get the friendly name associated with the input class.
  36517. * @returns the input friendly name
  36518. */
  36519. getSimpleName(): string;
  36520. }
  36521. }
  36522. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36523. import { Nullable } from "babylonjs/types";
  36524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36526. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36527. /**
  36528. * Manage the gamepad inputs to control a free camera.
  36529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36530. */
  36531. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36532. /**
  36533. * Define the camera the input is attached to.
  36534. */
  36535. camera: FreeCamera;
  36536. /**
  36537. * Define the Gamepad controlling the input
  36538. */
  36539. gamepad: Nullable<Gamepad>;
  36540. /**
  36541. * Defines the gamepad rotation sensiblity.
  36542. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36543. */
  36544. gamepadAngularSensibility: number;
  36545. /**
  36546. * Defines the gamepad move sensiblity.
  36547. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36548. */
  36549. gamepadMoveSensibility: number;
  36550. private _onGamepadConnectedObserver;
  36551. private _onGamepadDisconnectedObserver;
  36552. private _cameraTransform;
  36553. private _deltaTransform;
  36554. private _vector3;
  36555. private _vector2;
  36556. /**
  36557. * Attach the input controls to a specific dom element to get the input from.
  36558. * @param element Defines the element the controls should be listened from
  36559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36560. */
  36561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36562. /**
  36563. * Detach the current controls from the specified dom element.
  36564. * @param element Defines the element to stop listening the inputs from
  36565. */
  36566. detachControl(element: Nullable<HTMLElement>): void;
  36567. /**
  36568. * Update the current camera state depending on the inputs that have been used this frame.
  36569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36570. */
  36571. checkInputs(): void;
  36572. /**
  36573. * Gets the class name of the current intput.
  36574. * @returns the class name
  36575. */
  36576. getClassName(): string;
  36577. /**
  36578. * Get the friendly name associated with the input class.
  36579. * @returns the input friendly name
  36580. */
  36581. getSimpleName(): string;
  36582. }
  36583. }
  36584. declare module "babylonjs/Misc/virtualJoystick" {
  36585. import { Nullable } from "babylonjs/types";
  36586. import { Vector3 } from "babylonjs/Maths/math";
  36587. /**
  36588. * Defines the potential axis of a Joystick
  36589. */
  36590. export enum JoystickAxis {
  36591. /** X axis */
  36592. X = 0,
  36593. /** Y axis */
  36594. Y = 1,
  36595. /** Z axis */
  36596. Z = 2
  36597. }
  36598. /**
  36599. * Class used to define virtual joystick (used in touch mode)
  36600. */
  36601. export class VirtualJoystick {
  36602. /**
  36603. * Gets or sets a boolean indicating that left and right values must be inverted
  36604. */
  36605. reverseLeftRight: boolean;
  36606. /**
  36607. * Gets or sets a boolean indicating that up and down values must be inverted
  36608. */
  36609. reverseUpDown: boolean;
  36610. /**
  36611. * Gets the offset value for the position (ie. the change of the position value)
  36612. */
  36613. deltaPosition: Vector3;
  36614. /**
  36615. * Gets a boolean indicating if the virtual joystick was pressed
  36616. */
  36617. pressed: boolean;
  36618. /**
  36619. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36620. */
  36621. static Canvas: Nullable<HTMLCanvasElement>;
  36622. private static _globalJoystickIndex;
  36623. private static vjCanvasContext;
  36624. private static vjCanvasWidth;
  36625. private static vjCanvasHeight;
  36626. private static halfWidth;
  36627. private _action;
  36628. private _axisTargetedByLeftAndRight;
  36629. private _axisTargetedByUpAndDown;
  36630. private _joystickSensibility;
  36631. private _inversedSensibility;
  36632. private _joystickPointerID;
  36633. private _joystickColor;
  36634. private _joystickPointerPos;
  36635. private _joystickPreviousPointerPos;
  36636. private _joystickPointerStartPos;
  36637. private _deltaJoystickVector;
  36638. private _leftJoystick;
  36639. private _touches;
  36640. private _onPointerDownHandlerRef;
  36641. private _onPointerMoveHandlerRef;
  36642. private _onPointerUpHandlerRef;
  36643. private _onResize;
  36644. /**
  36645. * Creates a new virtual joystick
  36646. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36647. */
  36648. constructor(leftJoystick?: boolean);
  36649. /**
  36650. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36651. * @param newJoystickSensibility defines the new sensibility
  36652. */
  36653. setJoystickSensibility(newJoystickSensibility: number): void;
  36654. private _onPointerDown;
  36655. private _onPointerMove;
  36656. private _onPointerUp;
  36657. /**
  36658. * Change the color of the virtual joystick
  36659. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36660. */
  36661. setJoystickColor(newColor: string): void;
  36662. /**
  36663. * Defines a callback to call when the joystick is touched
  36664. * @param action defines the callback
  36665. */
  36666. setActionOnTouch(action: () => any): void;
  36667. /**
  36668. * Defines which axis you'd like to control for left & right
  36669. * @param axis defines the axis to use
  36670. */
  36671. setAxisForLeftRight(axis: JoystickAxis): void;
  36672. /**
  36673. * Defines which axis you'd like to control for up & down
  36674. * @param axis defines the axis to use
  36675. */
  36676. setAxisForUpDown(axis: JoystickAxis): void;
  36677. private _drawVirtualJoystick;
  36678. /**
  36679. * Release internal HTML canvas
  36680. */
  36681. releaseCanvas(): void;
  36682. }
  36683. }
  36684. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36685. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36686. import { Nullable } from "babylonjs/types";
  36687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36689. module "babylonjs/Cameras/freeCameraInputsManager" {
  36690. interface FreeCameraInputsManager {
  36691. /**
  36692. * Add virtual joystick input support to the input manager.
  36693. * @returns the current input manager
  36694. */
  36695. addVirtualJoystick(): FreeCameraInputsManager;
  36696. }
  36697. }
  36698. /**
  36699. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36701. */
  36702. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36703. /**
  36704. * Defines the camera the input is attached to.
  36705. */
  36706. camera: FreeCamera;
  36707. private _leftjoystick;
  36708. private _rightjoystick;
  36709. /**
  36710. * Gets the left stick of the virtual joystick.
  36711. * @returns The virtual Joystick
  36712. */
  36713. getLeftJoystick(): VirtualJoystick;
  36714. /**
  36715. * Gets the right stick of the virtual joystick.
  36716. * @returns The virtual Joystick
  36717. */
  36718. getRightJoystick(): VirtualJoystick;
  36719. /**
  36720. * Update the current camera state depending on the inputs that have been used this frame.
  36721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36722. */
  36723. checkInputs(): void;
  36724. /**
  36725. * Attach the input controls to a specific dom element to get the input from.
  36726. * @param element Defines the element the controls should be listened from
  36727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36728. */
  36729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36730. /**
  36731. * Detach the current controls from the specified dom element.
  36732. * @param element Defines the element to stop listening the inputs from
  36733. */
  36734. detachControl(element: Nullable<HTMLElement>): void;
  36735. /**
  36736. * Gets the class name of the current intput.
  36737. * @returns the class name
  36738. */
  36739. getClassName(): string;
  36740. /**
  36741. * Get the friendly name associated with the input class.
  36742. * @returns the input friendly name
  36743. */
  36744. getSimpleName(): string;
  36745. }
  36746. }
  36747. declare module "babylonjs/Cameras/Inputs/index" {
  36748. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36749. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36750. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36751. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36752. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36753. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36754. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36755. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36756. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36757. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36758. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36759. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36760. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36761. }
  36762. declare module "babylonjs/Cameras/touchCamera" {
  36763. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36764. import { Scene } from "babylonjs/scene";
  36765. import { Vector3 } from "babylonjs/Maths/math";
  36766. /**
  36767. * This represents a FPS type of camera controlled by touch.
  36768. * This is like a universal camera minus the Gamepad controls.
  36769. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36770. */
  36771. export class TouchCamera extends FreeCamera {
  36772. /**
  36773. * Defines the touch sensibility for rotation.
  36774. * The higher the faster.
  36775. */
  36776. touchAngularSensibility: number;
  36777. /**
  36778. * Defines the touch sensibility for move.
  36779. * The higher the faster.
  36780. */
  36781. touchMoveSensibility: number;
  36782. /**
  36783. * Instantiates a new touch camera.
  36784. * This represents a FPS type of camera controlled by touch.
  36785. * This is like a universal camera minus the Gamepad controls.
  36786. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36787. * @param name Define the name of the camera in the scene
  36788. * @param position Define the start position of the camera in the scene
  36789. * @param scene Define the scene the camera belongs to
  36790. */
  36791. constructor(name: string, position: Vector3, scene: Scene);
  36792. /**
  36793. * Gets the current object class name.
  36794. * @return the class name
  36795. */
  36796. getClassName(): string;
  36797. /** @hidden */
  36798. _setupInputs(): void;
  36799. }
  36800. }
  36801. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36802. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36803. import { Scene } from "babylonjs/scene";
  36804. import { Vector3, Axis } from "babylonjs/Maths/math";
  36805. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36806. /**
  36807. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36808. * being tilted forward or back and left or right.
  36809. */
  36810. export class DeviceOrientationCamera extends FreeCamera {
  36811. private _initialQuaternion;
  36812. private _quaternionCache;
  36813. /**
  36814. * Creates a new device orientation camera
  36815. * @param name The name of the camera
  36816. * @param position The start position camera
  36817. * @param scene The scene the camera belongs to
  36818. */
  36819. constructor(name: string, position: Vector3, scene: Scene);
  36820. /**
  36821. * Gets the current instance class name ("DeviceOrientationCamera").
  36822. * This helps avoiding instanceof at run time.
  36823. * @returns the class name
  36824. */
  36825. getClassName(): string;
  36826. /**
  36827. * @hidden
  36828. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36829. */
  36830. _checkInputs(): void;
  36831. /**
  36832. * Reset the camera to its default orientation on the specified axis only.
  36833. * @param axis The axis to reset
  36834. */
  36835. resetToCurrentRotation(axis?: Axis): void;
  36836. }
  36837. }
  36838. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36839. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36840. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36841. import { Nullable } from "babylonjs/types";
  36842. /**
  36843. * Manage the keyboard inputs to control the movement of a follow camera.
  36844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36845. */
  36846. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36847. /**
  36848. * Defines the camera the input is attached to.
  36849. */
  36850. camera: FollowCamera;
  36851. /**
  36852. * Defines the list of key codes associated with the up action (increase heightOffset)
  36853. */
  36854. keysHeightOffsetIncr: number[];
  36855. /**
  36856. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36857. */
  36858. keysHeightOffsetDecr: number[];
  36859. /**
  36860. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36861. */
  36862. keysHeightOffsetModifierAlt: boolean;
  36863. /**
  36864. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36865. */
  36866. keysHeightOffsetModifierCtrl: boolean;
  36867. /**
  36868. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36869. */
  36870. keysHeightOffsetModifierShift: boolean;
  36871. /**
  36872. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36873. */
  36874. keysRotationOffsetIncr: number[];
  36875. /**
  36876. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36877. */
  36878. keysRotationOffsetDecr: number[];
  36879. /**
  36880. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36881. */
  36882. keysRotationOffsetModifierAlt: boolean;
  36883. /**
  36884. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36885. */
  36886. keysRotationOffsetModifierCtrl: boolean;
  36887. /**
  36888. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36889. */
  36890. keysRotationOffsetModifierShift: boolean;
  36891. /**
  36892. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36893. */
  36894. keysRadiusIncr: number[];
  36895. /**
  36896. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36897. */
  36898. keysRadiusDecr: number[];
  36899. /**
  36900. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36901. */
  36902. keysRadiusModifierAlt: boolean;
  36903. /**
  36904. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36905. */
  36906. keysRadiusModifierCtrl: boolean;
  36907. /**
  36908. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36909. */
  36910. keysRadiusModifierShift: boolean;
  36911. /**
  36912. * Defines the rate of change of heightOffset.
  36913. */
  36914. heightSensibility: number;
  36915. /**
  36916. * Defines the rate of change of rotationOffset.
  36917. */
  36918. rotationSensibility: number;
  36919. /**
  36920. * Defines the rate of change of radius.
  36921. */
  36922. radiusSensibility: number;
  36923. private _keys;
  36924. private _ctrlPressed;
  36925. private _altPressed;
  36926. private _shiftPressed;
  36927. private _onCanvasBlurObserver;
  36928. private _onKeyboardObserver;
  36929. private _engine;
  36930. private _scene;
  36931. /**
  36932. * Attach the input controls to a specific dom element to get the input from.
  36933. * @param element Defines the element the controls should be listened from
  36934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36935. */
  36936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36937. /**
  36938. * Detach the current controls from the specified dom element.
  36939. * @param element Defines the element to stop listening the inputs from
  36940. */
  36941. detachControl(element: Nullable<HTMLElement>): void;
  36942. /**
  36943. * Update the current camera state depending on the inputs that have been used this frame.
  36944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36945. */
  36946. checkInputs(): void;
  36947. /**
  36948. * Gets the class name of the current input.
  36949. * @returns the class name
  36950. */
  36951. getClassName(): string;
  36952. /**
  36953. * Get the friendly name associated with the input class.
  36954. * @returns the input friendly name
  36955. */
  36956. getSimpleName(): string;
  36957. /**
  36958. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36959. * allow modification of the heightOffset value.
  36960. */
  36961. private _modifierHeightOffset;
  36962. /**
  36963. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36964. * allow modification of the rotationOffset value.
  36965. */
  36966. private _modifierRotationOffset;
  36967. /**
  36968. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36969. * allow modification of the radius value.
  36970. */
  36971. private _modifierRadius;
  36972. }
  36973. }
  36974. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36975. import { Nullable } from "babylonjs/types";
  36976. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36977. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36978. /**
  36979. * Manage the mouse wheel inputs to control a follow camera.
  36980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36981. */
  36982. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36983. /**
  36984. * Defines the camera the input is attached to.
  36985. */
  36986. camera: FollowCamera;
  36987. /**
  36988. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36989. */
  36990. axisControlRadius: boolean;
  36991. /**
  36992. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36993. */
  36994. axisControlHeight: boolean;
  36995. /**
  36996. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36997. */
  36998. axisControlRotation: boolean;
  36999. /**
  37000. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37001. * relation to mouseWheel events.
  37002. */
  37003. wheelPrecision: number;
  37004. /**
  37005. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37006. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37007. */
  37008. wheelDeltaPercentage: number;
  37009. private _wheel;
  37010. private _observer;
  37011. /**
  37012. * Attach the input controls to a specific dom element to get the input from.
  37013. * @param element Defines the element the controls should be listened from
  37014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37015. */
  37016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37017. /**
  37018. * Detach the current controls from the specified dom element.
  37019. * @param element Defines the element to stop listening the inputs from
  37020. */
  37021. detachControl(element: Nullable<HTMLElement>): void;
  37022. /**
  37023. * Gets the class name of the current intput.
  37024. * @returns the class name
  37025. */
  37026. getClassName(): string;
  37027. /**
  37028. * Get the friendly name associated with the input class.
  37029. * @returns the input friendly name
  37030. */
  37031. getSimpleName(): string;
  37032. }
  37033. }
  37034. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37035. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37036. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37037. /**
  37038. * Default Inputs manager for the FollowCamera.
  37039. * It groups all the default supported inputs for ease of use.
  37040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37041. */
  37042. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37043. /**
  37044. * Instantiates a new FollowCameraInputsManager.
  37045. * @param camera Defines the camera the inputs belong to
  37046. */
  37047. constructor(camera: FollowCamera);
  37048. /**
  37049. * Add keyboard input support to the input manager.
  37050. * @returns the current input manager
  37051. */
  37052. addKeyboard(): FollowCameraInputsManager;
  37053. /**
  37054. * Add mouse wheel input support to the input manager.
  37055. * @returns the current input manager
  37056. */
  37057. addMouseWheel(): FollowCameraInputsManager;
  37058. /**
  37059. * Add pointers input support to the input manager.
  37060. * @returns the current input manager
  37061. */
  37062. addPointers(): FollowCameraInputsManager;
  37063. /**
  37064. * Add orientation input support to the input manager.
  37065. * @returns the current input manager
  37066. */
  37067. addVRDeviceOrientation(): FollowCameraInputsManager;
  37068. }
  37069. }
  37070. declare module "babylonjs/Cameras/followCamera" {
  37071. import { Nullable } from "babylonjs/types";
  37072. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37073. import { Scene } from "babylonjs/scene";
  37074. import { Vector3 } from "babylonjs/Maths/math";
  37075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37076. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37077. /**
  37078. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37079. * an arc rotate version arcFollowCamera are available.
  37080. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37081. */
  37082. export class FollowCamera extends TargetCamera {
  37083. /**
  37084. * Distance the follow camera should follow an object at
  37085. */
  37086. radius: number;
  37087. /**
  37088. * Minimum allowed distance of the camera to the axis of rotation
  37089. * (The camera can not get closer).
  37090. * This can help limiting how the Camera is able to move in the scene.
  37091. */
  37092. lowerRadiusLimit: Nullable<number>;
  37093. /**
  37094. * Maximum allowed distance of the camera to the axis of rotation
  37095. * (The camera can not get further).
  37096. * This can help limiting how the Camera is able to move in the scene.
  37097. */
  37098. upperRadiusLimit: Nullable<number>;
  37099. /**
  37100. * Define a rotation offset between the camera and the object it follows
  37101. */
  37102. rotationOffset: number;
  37103. /**
  37104. * Minimum allowed angle to camera position relative to target object.
  37105. * This can help limiting how the Camera is able to move in the scene.
  37106. */
  37107. lowerRotationOffsetLimit: Nullable<number>;
  37108. /**
  37109. * Maximum allowed angle to camera position relative to target object.
  37110. * This can help limiting how the Camera is able to move in the scene.
  37111. */
  37112. upperRotationOffsetLimit: Nullable<number>;
  37113. /**
  37114. * Define a height offset between the camera and the object it follows.
  37115. * It can help following an object from the top (like a car chaing a plane)
  37116. */
  37117. heightOffset: number;
  37118. /**
  37119. * Minimum allowed height of camera position relative to target object.
  37120. * This can help limiting how the Camera is able to move in the scene.
  37121. */
  37122. lowerHeightOffsetLimit: Nullable<number>;
  37123. /**
  37124. * Maximum allowed height of camera position relative to target object.
  37125. * This can help limiting how the Camera is able to move in the scene.
  37126. */
  37127. upperHeightOffsetLimit: Nullable<number>;
  37128. /**
  37129. * Define how fast the camera can accelerate to follow it s target.
  37130. */
  37131. cameraAcceleration: number;
  37132. /**
  37133. * Define the speed limit of the camera following an object.
  37134. */
  37135. maxCameraSpeed: number;
  37136. /**
  37137. * Define the target of the camera.
  37138. */
  37139. lockedTarget: Nullable<AbstractMesh>;
  37140. /**
  37141. * Defines the input associated with the camera.
  37142. */
  37143. inputs: FollowCameraInputsManager;
  37144. /**
  37145. * Instantiates the follow camera.
  37146. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37147. * @param name Define the name of the camera in the scene
  37148. * @param position Define the position of the camera
  37149. * @param scene Define the scene the camera belong to
  37150. * @param lockedTarget Define the target of the camera
  37151. */
  37152. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37153. private _follow;
  37154. /**
  37155. * Attached controls to the current camera.
  37156. * @param element Defines the element the controls should be listened from
  37157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37158. */
  37159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37160. /**
  37161. * Detach the current controls from the camera.
  37162. * The camera will stop reacting to inputs.
  37163. * @param element Defines the element to stop listening the inputs from
  37164. */
  37165. detachControl(element: HTMLElement): void;
  37166. /** @hidden */
  37167. _checkInputs(): void;
  37168. private _checkLimits;
  37169. /**
  37170. * Gets the camera class name.
  37171. * @returns the class name
  37172. */
  37173. getClassName(): string;
  37174. }
  37175. /**
  37176. * Arc Rotate version of the follow camera.
  37177. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37178. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37179. */
  37180. export class ArcFollowCamera extends TargetCamera {
  37181. /** The longitudinal angle of the camera */
  37182. alpha: number;
  37183. /** The latitudinal angle of the camera */
  37184. beta: number;
  37185. /** The radius of the camera from its target */
  37186. radius: number;
  37187. /** Define the camera target (the messh it should follow) */
  37188. target: Nullable<AbstractMesh>;
  37189. private _cartesianCoordinates;
  37190. /**
  37191. * Instantiates a new ArcFollowCamera
  37192. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37193. * @param name Define the name of the camera
  37194. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37195. * @param beta Define the rotation angle of the camera around the elevation axis
  37196. * @param radius Define the radius of the camera from its target point
  37197. * @param target Define the target of the camera
  37198. * @param scene Define the scene the camera belongs to
  37199. */
  37200. constructor(name: string,
  37201. /** The longitudinal angle of the camera */
  37202. alpha: number,
  37203. /** The latitudinal angle of the camera */
  37204. beta: number,
  37205. /** The radius of the camera from its target */
  37206. radius: number,
  37207. /** Define the camera target (the messh it should follow) */
  37208. target: Nullable<AbstractMesh>, scene: Scene);
  37209. private _follow;
  37210. /** @hidden */
  37211. _checkInputs(): void;
  37212. /**
  37213. * Returns the class name of the object.
  37214. * It is mostly used internally for serialization purposes.
  37215. */
  37216. getClassName(): string;
  37217. }
  37218. }
  37219. declare module "babylonjs/Cameras/universalCamera" {
  37220. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37221. import { Scene } from "babylonjs/scene";
  37222. import { Vector3 } from "babylonjs/Maths/math";
  37223. /**
  37224. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  37225. * which still works and will still be found in many Playgrounds.
  37226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37227. */
  37228. export class UniversalCamera extends TouchCamera {
  37229. /**
  37230. * Defines the gamepad rotation sensiblity.
  37231. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37232. */
  37233. gamepadAngularSensibility: number;
  37234. /**
  37235. * Defines the gamepad move sensiblity.
  37236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37237. */
  37238. gamepadMoveSensibility: number;
  37239. /**
  37240. * 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,
  37241. * which still works and will still be found in many Playgrounds.
  37242. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37243. * @param name Define the name of the camera in the scene
  37244. * @param position Define the start position of the camera in the scene
  37245. * @param scene Define the scene the camera belongs to
  37246. */
  37247. constructor(name: string, position: Vector3, scene: Scene);
  37248. /**
  37249. * Gets the current object class name.
  37250. * @return the class name
  37251. */
  37252. getClassName(): string;
  37253. }
  37254. }
  37255. declare module "babylonjs/Cameras/gamepadCamera" {
  37256. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37257. import { Scene } from "babylonjs/scene";
  37258. import { Vector3 } from "babylonjs/Maths/math";
  37259. /**
  37260. * This represents a FPS type of camera. This is only here for back compat purpose.
  37261. * Please use the UniversalCamera instead as both are identical.
  37262. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37263. */
  37264. export class GamepadCamera extends UniversalCamera {
  37265. /**
  37266. * Instantiates a new Gamepad Camera
  37267. * This represents a FPS type of camera. This is only here for back compat purpose.
  37268. * Please use the UniversalCamera instead as both are identical.
  37269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37270. * @param name Define the name of the camera in the scene
  37271. * @param position Define the start position of the camera in the scene
  37272. * @param scene Define the scene the camera belongs to
  37273. */
  37274. constructor(name: string, position: Vector3, scene: Scene);
  37275. /**
  37276. * Gets the current object class name.
  37277. * @return the class name
  37278. */
  37279. getClassName(): string;
  37280. }
  37281. }
  37282. declare module "babylonjs/Shaders/pass.fragment" {
  37283. /** @hidden */
  37284. export var passPixelShader: {
  37285. name: string;
  37286. shader: string;
  37287. };
  37288. }
  37289. declare module "babylonjs/Shaders/passCube.fragment" {
  37290. /** @hidden */
  37291. export var passCubePixelShader: {
  37292. name: string;
  37293. shader: string;
  37294. };
  37295. }
  37296. declare module "babylonjs/PostProcesses/passPostProcess" {
  37297. import { Nullable } from "babylonjs/types";
  37298. import { Camera } from "babylonjs/Cameras/camera";
  37299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37300. import { Engine } from "babylonjs/Engines/engine";
  37301. import "babylonjs/Shaders/pass.fragment";
  37302. import "babylonjs/Shaders/passCube.fragment";
  37303. /**
  37304. * PassPostProcess which produces an output the same as it's input
  37305. */
  37306. export class PassPostProcess extends PostProcess {
  37307. /**
  37308. * Creates the PassPostProcess
  37309. * @param name The name of the effect.
  37310. * @param options The required width/height ratio to downsize to before computing the render pass.
  37311. * @param camera The camera to apply the render pass to.
  37312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37313. * @param engine The engine which the post process will be applied. (default: current engine)
  37314. * @param reusable If the post process can be reused on the same frame. (default: false)
  37315. * @param textureType The type of texture to be used when performing the post processing.
  37316. * @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)
  37317. */
  37318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37319. }
  37320. /**
  37321. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37322. */
  37323. export class PassCubePostProcess extends PostProcess {
  37324. private _face;
  37325. /**
  37326. * Gets or sets the cube face to display.
  37327. * * 0 is +X
  37328. * * 1 is -X
  37329. * * 2 is +Y
  37330. * * 3 is -Y
  37331. * * 4 is +Z
  37332. * * 5 is -Z
  37333. */
  37334. face: number;
  37335. /**
  37336. * Creates the PassCubePostProcess
  37337. * @param name The name of the effect.
  37338. * @param options The required width/height ratio to downsize to before computing the render pass.
  37339. * @param camera The camera to apply the render pass to.
  37340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37341. * @param engine The engine which the post process will be applied. (default: current engine)
  37342. * @param reusable If the post process can be reused on the same frame. (default: false)
  37343. * @param textureType The type of texture to be used when performing the post processing.
  37344. * @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)
  37345. */
  37346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37347. }
  37348. }
  37349. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37350. /** @hidden */
  37351. export var anaglyphPixelShader: {
  37352. name: string;
  37353. shader: string;
  37354. };
  37355. }
  37356. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37357. import { Engine } from "babylonjs/Engines/engine";
  37358. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37359. import { Camera } from "babylonjs/Cameras/camera";
  37360. import "babylonjs/Shaders/anaglyph.fragment";
  37361. /**
  37362. * Postprocess used to generate anaglyphic rendering
  37363. */
  37364. export class AnaglyphPostProcess extends PostProcess {
  37365. private _passedProcess;
  37366. /**
  37367. * Creates a new AnaglyphPostProcess
  37368. * @param name defines postprocess name
  37369. * @param options defines creation options or target ratio scale
  37370. * @param rigCameras defines cameras using this postprocess
  37371. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37372. * @param engine defines hosting engine
  37373. * @param reusable defines if the postprocess will be reused multiple times per frame
  37374. */
  37375. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37376. }
  37377. }
  37378. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37379. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37381. import { Scene } from "babylonjs/scene";
  37382. import { Vector3 } from "babylonjs/Maths/math";
  37383. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37384. /**
  37385. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37386. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37387. */
  37388. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37389. /**
  37390. * Creates a new AnaglyphArcRotateCamera
  37391. * @param name defines camera name
  37392. * @param alpha defines alpha angle (in radians)
  37393. * @param beta defines beta angle (in radians)
  37394. * @param radius defines radius
  37395. * @param target defines camera target
  37396. * @param interaxialDistance defines distance between each color axis
  37397. * @param scene defines the hosting scene
  37398. */
  37399. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37400. /**
  37401. * Gets camera class name
  37402. * @returns AnaglyphArcRotateCamera
  37403. */
  37404. getClassName(): string;
  37405. }
  37406. }
  37407. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37408. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  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 FreeCamera)
  37414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37415. */
  37416. export class AnaglyphFreeCamera extends FreeCamera {
  37417. /**
  37418. * Creates a new AnaglyphFreeCamera
  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 AnaglyphFreeCamera
  37428. */
  37429. getClassName(): string;
  37430. }
  37431. }
  37432. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37433. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  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 GamepadCamera)
  37439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37440. */
  37441. export class AnaglyphGamepadCamera extends GamepadCamera {
  37442. /**
  37443. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera
  37453. */
  37454. getClassName(): string;
  37455. }
  37456. }
  37457. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37458. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37459. import { Scene } from "babylonjs/scene";
  37460. import { Vector3 } from "babylonjs/Maths/math";
  37461. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37462. /**
  37463. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37464. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37465. */
  37466. export class AnaglyphUniversalCamera extends UniversalCamera {
  37467. /**
  37468. * Creates a new AnaglyphUniversalCamera
  37469. * @param name defines camera name
  37470. * @param position defines initial position
  37471. * @param interaxialDistance defines distance between each color axis
  37472. * @param scene defines the hosting scene
  37473. */
  37474. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37475. /**
  37476. * Gets camera class name
  37477. * @returns AnaglyphUniversalCamera
  37478. */
  37479. getClassName(): string;
  37480. }
  37481. }
  37482. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37483. /** @hidden */
  37484. export var stereoscopicInterlacePixelShader: {
  37485. name: string;
  37486. shader: string;
  37487. };
  37488. }
  37489. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37490. import { Camera } from "babylonjs/Cameras/camera";
  37491. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37492. import { Engine } from "babylonjs/Engines/engine";
  37493. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37494. /**
  37495. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37496. */
  37497. export class StereoscopicInterlacePostProcess extends PostProcess {
  37498. private _stepSize;
  37499. private _passedProcess;
  37500. /**
  37501. * Initializes a StereoscopicInterlacePostProcess
  37502. * @param name The name of the effect.
  37503. * @param rigCameras The rig cameras to be appled to the post process
  37504. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37506. * @param engine The engine which the post process will be applied. (default: current engine)
  37507. * @param reusable If the post process can be reused on the same frame. (default: false)
  37508. */
  37509. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37510. }
  37511. }
  37512. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37513. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37514. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37515. import { Scene } from "babylonjs/scene";
  37516. import { Vector3 } from "babylonjs/Maths/math";
  37517. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37518. /**
  37519. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37520. * @see http://doc.babylonjs.com/features/cameras
  37521. */
  37522. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37523. /**
  37524. * Creates a new StereoscopicArcRotateCamera
  37525. * @param name defines camera name
  37526. * @param alpha defines alpha angle (in radians)
  37527. * @param beta defines beta angle (in radians)
  37528. * @param radius defines radius
  37529. * @param target defines camera target
  37530. * @param interaxialDistance defines distance between each color axis
  37531. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37532. * @param scene defines the hosting scene
  37533. */
  37534. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37535. /**
  37536. * Gets camera class name
  37537. * @returns StereoscopicArcRotateCamera
  37538. */
  37539. getClassName(): string;
  37540. }
  37541. }
  37542. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37543. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37544. import { Scene } from "babylonjs/scene";
  37545. import { Vector3 } from "babylonjs/Maths/math";
  37546. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37547. /**
  37548. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37549. * @see http://doc.babylonjs.com/features/cameras
  37550. */
  37551. export class StereoscopicFreeCamera extends FreeCamera {
  37552. /**
  37553. * Creates a new StereoscopicFreeCamera
  37554. * @param name defines camera name
  37555. * @param position defines initial position
  37556. * @param interaxialDistance defines distance between each color axis
  37557. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37558. * @param scene defines the hosting scene
  37559. */
  37560. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37561. /**
  37562. * Gets camera class name
  37563. * @returns StereoscopicFreeCamera
  37564. */
  37565. getClassName(): string;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37569. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37570. import { Scene } from "babylonjs/scene";
  37571. import { Vector3 } from "babylonjs/Maths/math";
  37572. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37573. /**
  37574. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37575. * @see http://doc.babylonjs.com/features/cameras
  37576. */
  37577. export class StereoscopicGamepadCamera extends GamepadCamera {
  37578. /**
  37579. * Creates a new StereoscopicGamepadCamera
  37580. * @param name defines camera name
  37581. * @param position defines initial position
  37582. * @param interaxialDistance defines distance between each color axis
  37583. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37584. * @param scene defines the hosting scene
  37585. */
  37586. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37587. /**
  37588. * Gets camera class name
  37589. * @returns StereoscopicGamepadCamera
  37590. */
  37591. getClassName(): string;
  37592. }
  37593. }
  37594. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37595. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37596. import { Scene } from "babylonjs/scene";
  37597. import { Vector3 } from "babylonjs/Maths/math";
  37598. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37599. /**
  37600. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37601. * @see http://doc.babylonjs.com/features/cameras
  37602. */
  37603. export class StereoscopicUniversalCamera extends UniversalCamera {
  37604. /**
  37605. * Creates a new StereoscopicUniversalCamera
  37606. * @param name defines camera name
  37607. * @param position defines initial position
  37608. * @param interaxialDistance defines distance between each color axis
  37609. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37610. * @param scene defines the hosting scene
  37611. */
  37612. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37613. /**
  37614. * Gets camera class name
  37615. * @returns StereoscopicUniversalCamera
  37616. */
  37617. getClassName(): string;
  37618. }
  37619. }
  37620. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37621. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37622. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37623. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37624. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37625. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37626. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37627. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37628. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37629. }
  37630. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37631. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37632. import { Scene } from "babylonjs/scene";
  37633. import { Vector3 } from "babylonjs/Maths/math";
  37634. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37635. /**
  37636. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37637. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37638. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37639. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37640. */
  37641. export class VirtualJoysticksCamera extends FreeCamera {
  37642. /**
  37643. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37644. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37645. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37646. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37647. * @param name Define the name of the camera in the scene
  37648. * @param position Define the start position of the camera in the scene
  37649. * @param scene Define the scene the camera belongs to
  37650. */
  37651. constructor(name: string, position: Vector3, scene: Scene);
  37652. /**
  37653. * Gets the current object class name.
  37654. * @return the class name
  37655. */
  37656. getClassName(): string;
  37657. }
  37658. }
  37659. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37660. import { Matrix } from "babylonjs/Maths/math";
  37661. /**
  37662. * This represents all the required metrics to create a VR camera.
  37663. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37664. */
  37665. export class VRCameraMetrics {
  37666. /**
  37667. * Define the horizontal resolution off the screen.
  37668. */
  37669. hResolution: number;
  37670. /**
  37671. * Define the vertical resolution off the screen.
  37672. */
  37673. vResolution: number;
  37674. /**
  37675. * Define the horizontal screen size.
  37676. */
  37677. hScreenSize: number;
  37678. /**
  37679. * Define the vertical screen size.
  37680. */
  37681. vScreenSize: number;
  37682. /**
  37683. * Define the vertical screen center position.
  37684. */
  37685. vScreenCenter: number;
  37686. /**
  37687. * Define the distance of the eyes to the screen.
  37688. */
  37689. eyeToScreenDistance: number;
  37690. /**
  37691. * Define the distance between both lenses
  37692. */
  37693. lensSeparationDistance: number;
  37694. /**
  37695. * Define the distance between both viewer's eyes.
  37696. */
  37697. interpupillaryDistance: number;
  37698. /**
  37699. * Define the distortion factor of the VR postprocess.
  37700. * Please, touch with care.
  37701. */
  37702. distortionK: number[];
  37703. /**
  37704. * Define the chromatic aberration correction factors for the VR post process.
  37705. */
  37706. chromaAbCorrection: number[];
  37707. /**
  37708. * Define the scale factor of the post process.
  37709. * The smaller the better but the slower.
  37710. */
  37711. postProcessScaleFactor: number;
  37712. /**
  37713. * Define an offset for the lens center.
  37714. */
  37715. lensCenterOffset: number;
  37716. /**
  37717. * Define if the current vr camera should compensate the distortion of the lense or not.
  37718. */
  37719. compensateDistortion: boolean;
  37720. /**
  37721. * Gets the rendering aspect ratio based on the provided resolutions.
  37722. */
  37723. readonly aspectRatio: number;
  37724. /**
  37725. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37726. */
  37727. readonly aspectRatioFov: number;
  37728. /**
  37729. * @hidden
  37730. */
  37731. readonly leftHMatrix: Matrix;
  37732. /**
  37733. * @hidden
  37734. */
  37735. readonly rightHMatrix: Matrix;
  37736. /**
  37737. * @hidden
  37738. */
  37739. readonly leftPreViewMatrix: Matrix;
  37740. /**
  37741. * @hidden
  37742. */
  37743. readonly rightPreViewMatrix: Matrix;
  37744. /**
  37745. * Get the default VRMetrics based on the most generic setup.
  37746. * @returns the default vr metrics
  37747. */
  37748. static GetDefault(): VRCameraMetrics;
  37749. }
  37750. }
  37751. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37752. /** @hidden */
  37753. export var vrDistortionCorrectionPixelShader: {
  37754. name: string;
  37755. shader: string;
  37756. };
  37757. }
  37758. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37759. import { Camera } from "babylonjs/Cameras/camera";
  37760. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37762. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37763. /**
  37764. * VRDistortionCorrectionPostProcess used for mobile VR
  37765. */
  37766. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37767. private _isRightEye;
  37768. private _distortionFactors;
  37769. private _postProcessScaleFactor;
  37770. private _lensCenterOffset;
  37771. private _scaleIn;
  37772. private _scaleFactor;
  37773. private _lensCenter;
  37774. /**
  37775. * Initializes the VRDistortionCorrectionPostProcess
  37776. * @param name The name of the effect.
  37777. * @param camera The camera to apply the render pass to.
  37778. * @param isRightEye If this is for the right eye distortion
  37779. * @param vrMetrics All the required metrics for the VR camera
  37780. */
  37781. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37782. }
  37783. }
  37784. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37785. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37787. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37788. import { Scene } from "babylonjs/scene";
  37789. import { Vector3 } from "babylonjs/Maths/math";
  37790. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37791. import "babylonjs/Cameras/RigModes/vrRigMode";
  37792. /**
  37793. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37794. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37795. */
  37796. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37797. /**
  37798. * Creates a new VRDeviceOrientationArcRotateCamera
  37799. * @param name defines camera name
  37800. * @param alpha defines the camera rotation along the logitudinal axis
  37801. * @param beta defines the camera rotation along the latitudinal axis
  37802. * @param radius defines the camera distance from its target
  37803. * @param target defines the camera target
  37804. * @param scene defines the scene the camera belongs to
  37805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37807. */
  37808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37809. /**
  37810. * Gets camera class name
  37811. * @returns VRDeviceOrientationArcRotateCamera
  37812. */
  37813. getClassName(): string;
  37814. }
  37815. }
  37816. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37817. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37819. import { Scene } from "babylonjs/scene";
  37820. import { Vector3 } from "babylonjs/Maths/math";
  37821. import "babylonjs/Cameras/RigModes/vrRigMode";
  37822. /**
  37823. * Camera used to simulate VR rendering (based on FreeCamera)
  37824. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37825. */
  37826. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37827. /**
  37828. * Creates a new VRDeviceOrientationFreeCamera
  37829. * @param name defines camera name
  37830. * @param position defines the start position of the camera
  37831. * @param scene defines the scene the camera belongs to
  37832. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37833. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37834. */
  37835. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37836. /**
  37837. * Gets camera class name
  37838. * @returns VRDeviceOrientationFreeCamera
  37839. */
  37840. getClassName(): string;
  37841. }
  37842. }
  37843. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37844. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37845. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37846. import { Scene } from "babylonjs/scene";
  37847. import { Vector3 } from "babylonjs/Maths/math";
  37848. /**
  37849. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37850. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37851. */
  37852. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37853. /**
  37854. * Creates a new VRDeviceOrientationGamepadCamera
  37855. * @param name defines camera name
  37856. * @param position defines the start position of the camera
  37857. * @param scene defines the scene the camera belongs to
  37858. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37859. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37860. */
  37861. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37862. /**
  37863. * Gets camera class name
  37864. * @returns VRDeviceOrientationGamepadCamera
  37865. */
  37866. getClassName(): string;
  37867. }
  37868. }
  37869. declare module "babylonjs/Gamepads/xboxGamepad" {
  37870. import { Observable } from "babylonjs/Misc/observable";
  37871. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37872. /**
  37873. * Defines supported buttons for XBox360 compatible gamepads
  37874. */
  37875. export enum Xbox360Button {
  37876. /** A */
  37877. A = 0,
  37878. /** B */
  37879. B = 1,
  37880. /** X */
  37881. X = 2,
  37882. /** Y */
  37883. Y = 3,
  37884. /** Start */
  37885. Start = 4,
  37886. /** Back */
  37887. Back = 5,
  37888. /** Left button */
  37889. LB = 6,
  37890. /** Right button */
  37891. RB = 7,
  37892. /** Left stick */
  37893. LeftStick = 8,
  37894. /** Right stick */
  37895. RightStick = 9
  37896. }
  37897. /** Defines values for XBox360 DPad */
  37898. export enum Xbox360Dpad {
  37899. /** Up */
  37900. Up = 0,
  37901. /** Down */
  37902. Down = 1,
  37903. /** Left */
  37904. Left = 2,
  37905. /** Right */
  37906. Right = 3
  37907. }
  37908. /**
  37909. * Defines a XBox360 gamepad
  37910. */
  37911. export class Xbox360Pad extends Gamepad {
  37912. private _leftTrigger;
  37913. private _rightTrigger;
  37914. private _onlefttriggerchanged;
  37915. private _onrighttriggerchanged;
  37916. private _onbuttondown;
  37917. private _onbuttonup;
  37918. private _ondpaddown;
  37919. private _ondpadup;
  37920. /** Observable raised when a button is pressed */
  37921. onButtonDownObservable: Observable<Xbox360Button>;
  37922. /** Observable raised when a button is released */
  37923. onButtonUpObservable: Observable<Xbox360Button>;
  37924. /** Observable raised when a pad is pressed */
  37925. onPadDownObservable: Observable<Xbox360Dpad>;
  37926. /** Observable raised when a pad is released */
  37927. onPadUpObservable: Observable<Xbox360Dpad>;
  37928. private _buttonA;
  37929. private _buttonB;
  37930. private _buttonX;
  37931. private _buttonY;
  37932. private _buttonBack;
  37933. private _buttonStart;
  37934. private _buttonLB;
  37935. private _buttonRB;
  37936. private _buttonLeftStick;
  37937. private _buttonRightStick;
  37938. private _dPadUp;
  37939. private _dPadDown;
  37940. private _dPadLeft;
  37941. private _dPadRight;
  37942. private _isXboxOnePad;
  37943. /**
  37944. * Creates a new XBox360 gamepad object
  37945. * @param id defines the id of this gamepad
  37946. * @param index defines its index
  37947. * @param gamepad defines the internal HTML gamepad object
  37948. * @param xboxOne defines if it is a XBox One gamepad
  37949. */
  37950. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37951. /**
  37952. * Defines the callback to call when left trigger is pressed
  37953. * @param callback defines the callback to use
  37954. */
  37955. onlefttriggerchanged(callback: (value: number) => void): void;
  37956. /**
  37957. * Defines the callback to call when right trigger is pressed
  37958. * @param callback defines the callback to use
  37959. */
  37960. onrighttriggerchanged(callback: (value: number) => void): void;
  37961. /**
  37962. * Gets the left trigger value
  37963. */
  37964. /**
  37965. * Sets the left trigger value
  37966. */
  37967. leftTrigger: number;
  37968. /**
  37969. * Gets the right trigger value
  37970. */
  37971. /**
  37972. * Sets the right trigger value
  37973. */
  37974. rightTrigger: number;
  37975. /**
  37976. * Defines the callback to call when a button is pressed
  37977. * @param callback defines the callback to use
  37978. */
  37979. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37980. /**
  37981. * Defines the callback to call when a button is released
  37982. * @param callback defines the callback to use
  37983. */
  37984. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37985. /**
  37986. * Defines the callback to call when a pad is pressed
  37987. * @param callback defines the callback to use
  37988. */
  37989. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37990. /**
  37991. * Defines the callback to call when a pad is released
  37992. * @param callback defines the callback to use
  37993. */
  37994. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37995. private _setButtonValue;
  37996. private _setDPadValue;
  37997. /**
  37998. * Gets the value of the `A` button
  37999. */
  38000. /**
  38001. * Sets the value of the `A` button
  38002. */
  38003. buttonA: number;
  38004. /**
  38005. * Gets the value of the `B` button
  38006. */
  38007. /**
  38008. * Sets the value of the `B` button
  38009. */
  38010. buttonB: number;
  38011. /**
  38012. * Gets the value of the `X` button
  38013. */
  38014. /**
  38015. * Sets the value of the `X` button
  38016. */
  38017. buttonX: number;
  38018. /**
  38019. * Gets the value of the `Y` button
  38020. */
  38021. /**
  38022. * Sets the value of the `Y` button
  38023. */
  38024. buttonY: number;
  38025. /**
  38026. * Gets the value of the `Start` button
  38027. */
  38028. /**
  38029. * Sets the value of the `Start` button
  38030. */
  38031. buttonStart: number;
  38032. /**
  38033. * Gets the value of the `Back` button
  38034. */
  38035. /**
  38036. * Sets the value of the `Back` button
  38037. */
  38038. buttonBack: number;
  38039. /**
  38040. * Gets the value of the `Left` button
  38041. */
  38042. /**
  38043. * Sets the value of the `Left` button
  38044. */
  38045. buttonLB: number;
  38046. /**
  38047. * Gets the value of the `Right` button
  38048. */
  38049. /**
  38050. * Sets the value of the `Right` button
  38051. */
  38052. buttonRB: number;
  38053. /**
  38054. * Gets the value of the Left joystick
  38055. */
  38056. /**
  38057. * Sets the value of the Left joystick
  38058. */
  38059. buttonLeftStick: number;
  38060. /**
  38061. * Gets the value of the Right joystick
  38062. */
  38063. /**
  38064. * Sets the value of the Right joystick
  38065. */
  38066. buttonRightStick: number;
  38067. /**
  38068. * Gets the value of D-pad up
  38069. */
  38070. /**
  38071. * Sets the value of D-pad up
  38072. */
  38073. dPadUp: number;
  38074. /**
  38075. * Gets the value of D-pad down
  38076. */
  38077. /**
  38078. * Sets the value of D-pad down
  38079. */
  38080. dPadDown: number;
  38081. /**
  38082. * Gets the value of D-pad left
  38083. */
  38084. /**
  38085. * Sets the value of D-pad left
  38086. */
  38087. dPadLeft: number;
  38088. /**
  38089. * Gets the value of D-pad right
  38090. */
  38091. /**
  38092. * Sets the value of D-pad right
  38093. */
  38094. dPadRight: number;
  38095. /**
  38096. * Force the gamepad to synchronize with device values
  38097. */
  38098. update(): void;
  38099. /**
  38100. * Disposes the gamepad
  38101. */
  38102. dispose(): void;
  38103. }
  38104. }
  38105. declare module "babylonjs/Materials/pushMaterial" {
  38106. import { Nullable } from "babylonjs/types";
  38107. import { Scene } from "babylonjs/scene";
  38108. import { Matrix } from "babylonjs/Maths/math";
  38109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38110. import { Mesh } from "babylonjs/Meshes/mesh";
  38111. import { Material } from "babylonjs/Materials/material";
  38112. import { Effect } from "babylonjs/Materials/effect";
  38113. /**
  38114. * Base class of materials working in push mode in babylon JS
  38115. * @hidden
  38116. */
  38117. export class PushMaterial extends Material {
  38118. protected _activeEffect: Effect;
  38119. protected _normalMatrix: Matrix;
  38120. /**
  38121. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38122. * This means that the material can keep using a previous shader while a new one is being compiled.
  38123. * This is mostly used when shader parallel compilation is supported (true by default)
  38124. */
  38125. allowShaderHotSwapping: boolean;
  38126. constructor(name: string, scene: Scene);
  38127. getEffect(): Effect;
  38128. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38129. /**
  38130. * Binds the given world matrix to the active effect
  38131. *
  38132. * @param world the matrix to bind
  38133. */
  38134. bindOnlyWorldMatrix(world: Matrix): void;
  38135. /**
  38136. * Binds the given normal matrix to the active effect
  38137. *
  38138. * @param normalMatrix the matrix to bind
  38139. */
  38140. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38141. bind(world: Matrix, mesh?: Mesh): void;
  38142. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38143. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38144. }
  38145. }
  38146. declare module "babylonjs/Materials/materialFlags" {
  38147. /**
  38148. * This groups all the flags used to control the materials channel.
  38149. */
  38150. export class MaterialFlags {
  38151. private static _DiffuseTextureEnabled;
  38152. /**
  38153. * Are diffuse textures enabled in the application.
  38154. */
  38155. static DiffuseTextureEnabled: boolean;
  38156. private static _AmbientTextureEnabled;
  38157. /**
  38158. * Are ambient textures enabled in the application.
  38159. */
  38160. static AmbientTextureEnabled: boolean;
  38161. private static _OpacityTextureEnabled;
  38162. /**
  38163. * Are opacity textures enabled in the application.
  38164. */
  38165. static OpacityTextureEnabled: boolean;
  38166. private static _ReflectionTextureEnabled;
  38167. /**
  38168. * Are reflection textures enabled in the application.
  38169. */
  38170. static ReflectionTextureEnabled: boolean;
  38171. private static _EmissiveTextureEnabled;
  38172. /**
  38173. * Are emissive textures enabled in the application.
  38174. */
  38175. static EmissiveTextureEnabled: boolean;
  38176. private static _SpecularTextureEnabled;
  38177. /**
  38178. * Are specular textures enabled in the application.
  38179. */
  38180. static SpecularTextureEnabled: boolean;
  38181. private static _BumpTextureEnabled;
  38182. /**
  38183. * Are bump textures enabled in the application.
  38184. */
  38185. static BumpTextureEnabled: boolean;
  38186. private static _LightmapTextureEnabled;
  38187. /**
  38188. * Are lightmap textures enabled in the application.
  38189. */
  38190. static LightmapTextureEnabled: boolean;
  38191. private static _RefractionTextureEnabled;
  38192. /**
  38193. * Are refraction textures enabled in the application.
  38194. */
  38195. static RefractionTextureEnabled: boolean;
  38196. private static _ColorGradingTextureEnabled;
  38197. /**
  38198. * Are color grading textures enabled in the application.
  38199. */
  38200. static ColorGradingTextureEnabled: boolean;
  38201. private static _FresnelEnabled;
  38202. /**
  38203. * Are fresnels enabled in the application.
  38204. */
  38205. static FresnelEnabled: boolean;
  38206. private static _ClearCoatTextureEnabled;
  38207. /**
  38208. * Are clear coat textures enabled in the application.
  38209. */
  38210. static ClearCoatTextureEnabled: boolean;
  38211. private static _ClearCoatBumpTextureEnabled;
  38212. /**
  38213. * Are clear coat bump textures enabled in the application.
  38214. */
  38215. static ClearCoatBumpTextureEnabled: boolean;
  38216. private static _ClearCoatTintTextureEnabled;
  38217. /**
  38218. * Are clear coat tint textures enabled in the application.
  38219. */
  38220. static ClearCoatTintTextureEnabled: boolean;
  38221. }
  38222. }
  38223. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38224. /** @hidden */
  38225. export var defaultFragmentDeclaration: {
  38226. name: string;
  38227. shader: string;
  38228. };
  38229. }
  38230. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38231. /** @hidden */
  38232. export var defaultUboDeclaration: {
  38233. name: string;
  38234. shader: string;
  38235. };
  38236. }
  38237. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38238. /** @hidden */
  38239. export var lightFragmentDeclaration: {
  38240. name: string;
  38241. shader: string;
  38242. };
  38243. }
  38244. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38245. /** @hidden */
  38246. export var lightUboDeclaration: {
  38247. name: string;
  38248. shader: string;
  38249. };
  38250. }
  38251. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38252. /** @hidden */
  38253. export var lightsFragmentFunctions: {
  38254. name: string;
  38255. shader: string;
  38256. };
  38257. }
  38258. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38259. /** @hidden */
  38260. export var shadowsFragmentFunctions: {
  38261. name: string;
  38262. shader: string;
  38263. };
  38264. }
  38265. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38266. /** @hidden */
  38267. export var fresnelFunction: {
  38268. name: string;
  38269. shader: string;
  38270. };
  38271. }
  38272. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38273. /** @hidden */
  38274. export var reflectionFunction: {
  38275. name: string;
  38276. shader: string;
  38277. };
  38278. }
  38279. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38280. /** @hidden */
  38281. export var bumpFragmentFunctions: {
  38282. name: string;
  38283. shader: string;
  38284. };
  38285. }
  38286. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38287. /** @hidden */
  38288. export var logDepthDeclaration: {
  38289. name: string;
  38290. shader: string;
  38291. };
  38292. }
  38293. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38294. /** @hidden */
  38295. export var bumpFragment: {
  38296. name: string;
  38297. shader: string;
  38298. };
  38299. }
  38300. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38301. /** @hidden */
  38302. export var depthPrePass: {
  38303. name: string;
  38304. shader: string;
  38305. };
  38306. }
  38307. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38308. /** @hidden */
  38309. export var lightFragment: {
  38310. name: string;
  38311. shader: string;
  38312. };
  38313. }
  38314. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38315. /** @hidden */
  38316. export var logDepthFragment: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module "babylonjs/Shaders/default.fragment" {
  38322. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38323. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38327. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38328. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38329. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38330. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38331. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38332. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38333. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38334. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38335. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38336. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38338. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38339. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38340. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38341. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38342. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38343. /** @hidden */
  38344. export var defaultPixelShader: {
  38345. name: string;
  38346. shader: string;
  38347. };
  38348. }
  38349. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38350. /** @hidden */
  38351. export var defaultVertexDeclaration: {
  38352. name: string;
  38353. shader: string;
  38354. };
  38355. }
  38356. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38357. /** @hidden */
  38358. export var bumpVertexDeclaration: {
  38359. name: string;
  38360. shader: string;
  38361. };
  38362. }
  38363. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38364. /** @hidden */
  38365. export var bumpVertex: {
  38366. name: string;
  38367. shader: string;
  38368. };
  38369. }
  38370. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38371. /** @hidden */
  38372. export var fogVertex: {
  38373. name: string;
  38374. shader: string;
  38375. };
  38376. }
  38377. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38378. /** @hidden */
  38379. export var shadowsVertex: {
  38380. name: string;
  38381. shader: string;
  38382. };
  38383. }
  38384. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38385. /** @hidden */
  38386. export var pointCloudVertex: {
  38387. name: string;
  38388. shader: string;
  38389. };
  38390. }
  38391. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38392. /** @hidden */
  38393. export var logDepthVertex: {
  38394. name: string;
  38395. shader: string;
  38396. };
  38397. }
  38398. declare module "babylonjs/Shaders/default.vertex" {
  38399. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38400. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38401. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38402. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38404. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38406. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38411. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38413. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38414. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38415. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38416. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38417. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38418. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38419. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38420. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38421. /** @hidden */
  38422. export var defaultVertexShader: {
  38423. name: string;
  38424. shader: string;
  38425. };
  38426. }
  38427. declare module "babylonjs/Materials/standardMaterial" {
  38428. import { SmartArray } from "babylonjs/Misc/smartArray";
  38429. import { IAnimatable } from "babylonjs/Misc/tools";
  38430. import { Nullable } from "babylonjs/types";
  38431. import { Scene } from "babylonjs/scene";
  38432. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38435. import { Mesh } from "babylonjs/Meshes/mesh";
  38436. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38437. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38438. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38439. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38440. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38443. import "babylonjs/Shaders/default.fragment";
  38444. import "babylonjs/Shaders/default.vertex";
  38445. /** @hidden */
  38446. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38447. MAINUV1: boolean;
  38448. MAINUV2: boolean;
  38449. DIFFUSE: boolean;
  38450. DIFFUSEDIRECTUV: number;
  38451. AMBIENT: boolean;
  38452. AMBIENTDIRECTUV: number;
  38453. OPACITY: boolean;
  38454. OPACITYDIRECTUV: number;
  38455. OPACITYRGB: boolean;
  38456. REFLECTION: boolean;
  38457. EMISSIVE: boolean;
  38458. EMISSIVEDIRECTUV: number;
  38459. SPECULAR: boolean;
  38460. SPECULARDIRECTUV: number;
  38461. BUMP: boolean;
  38462. BUMPDIRECTUV: number;
  38463. PARALLAX: boolean;
  38464. PARALLAXOCCLUSION: boolean;
  38465. SPECULAROVERALPHA: boolean;
  38466. CLIPPLANE: boolean;
  38467. CLIPPLANE2: boolean;
  38468. CLIPPLANE3: boolean;
  38469. CLIPPLANE4: boolean;
  38470. ALPHATEST: boolean;
  38471. DEPTHPREPASS: boolean;
  38472. ALPHAFROMDIFFUSE: boolean;
  38473. POINTSIZE: boolean;
  38474. FOG: boolean;
  38475. SPECULARTERM: boolean;
  38476. DIFFUSEFRESNEL: boolean;
  38477. OPACITYFRESNEL: boolean;
  38478. REFLECTIONFRESNEL: boolean;
  38479. REFRACTIONFRESNEL: boolean;
  38480. EMISSIVEFRESNEL: boolean;
  38481. FRESNEL: boolean;
  38482. NORMAL: boolean;
  38483. UV1: boolean;
  38484. UV2: boolean;
  38485. VERTEXCOLOR: boolean;
  38486. VERTEXALPHA: boolean;
  38487. NUM_BONE_INFLUENCERS: number;
  38488. BonesPerMesh: number;
  38489. BONETEXTURE: boolean;
  38490. INSTANCES: boolean;
  38491. GLOSSINESS: boolean;
  38492. ROUGHNESS: boolean;
  38493. EMISSIVEASILLUMINATION: boolean;
  38494. LINKEMISSIVEWITHDIFFUSE: boolean;
  38495. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38496. LIGHTMAP: boolean;
  38497. LIGHTMAPDIRECTUV: number;
  38498. OBJECTSPACE_NORMALMAP: boolean;
  38499. USELIGHTMAPASSHADOWMAP: boolean;
  38500. REFLECTIONMAP_3D: boolean;
  38501. REFLECTIONMAP_SPHERICAL: boolean;
  38502. REFLECTIONMAP_PLANAR: boolean;
  38503. REFLECTIONMAP_CUBIC: boolean;
  38504. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38505. REFLECTIONMAP_PROJECTION: boolean;
  38506. REFLECTIONMAP_SKYBOX: boolean;
  38507. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38508. REFLECTIONMAP_EXPLICIT: boolean;
  38509. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38510. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38511. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38512. INVERTCUBICMAP: boolean;
  38513. LOGARITHMICDEPTH: boolean;
  38514. REFRACTION: boolean;
  38515. REFRACTIONMAP_3D: boolean;
  38516. REFLECTIONOVERALPHA: boolean;
  38517. TWOSIDEDLIGHTING: boolean;
  38518. SHADOWFLOAT: boolean;
  38519. MORPHTARGETS: boolean;
  38520. MORPHTARGETS_NORMAL: boolean;
  38521. MORPHTARGETS_TANGENT: boolean;
  38522. NUM_MORPH_INFLUENCERS: number;
  38523. NONUNIFORMSCALING: boolean;
  38524. PREMULTIPLYALPHA: boolean;
  38525. IMAGEPROCESSING: boolean;
  38526. VIGNETTE: boolean;
  38527. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38528. VIGNETTEBLENDMODEOPAQUE: boolean;
  38529. TONEMAPPING: boolean;
  38530. TONEMAPPING_ACES: boolean;
  38531. CONTRAST: boolean;
  38532. COLORCURVES: boolean;
  38533. COLORGRADING: boolean;
  38534. COLORGRADING3D: boolean;
  38535. SAMPLER3DGREENDEPTH: boolean;
  38536. SAMPLER3DBGRMAP: boolean;
  38537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38538. /**
  38539. * If the reflection texture on this material is in linear color space
  38540. * @hidden
  38541. */
  38542. IS_REFLECTION_LINEAR: boolean;
  38543. /**
  38544. * If the refraction texture on this material is in linear color space
  38545. * @hidden
  38546. */
  38547. IS_REFRACTION_LINEAR: boolean;
  38548. EXPOSURE: boolean;
  38549. constructor();
  38550. setReflectionMode(modeToEnable: string): void;
  38551. }
  38552. /**
  38553. * This is the default material used in Babylon. It is the best trade off between quality
  38554. * and performances.
  38555. * @see http://doc.babylonjs.com/babylon101/materials
  38556. */
  38557. export class StandardMaterial extends PushMaterial {
  38558. private _diffuseTexture;
  38559. /**
  38560. * The basic texture of the material as viewed under a light.
  38561. */
  38562. diffuseTexture: Nullable<BaseTexture>;
  38563. private _ambientTexture;
  38564. /**
  38565. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38566. */
  38567. ambientTexture: Nullable<BaseTexture>;
  38568. private _opacityTexture;
  38569. /**
  38570. * Define the transparency of the material from a texture.
  38571. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38572. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38573. */
  38574. opacityTexture: Nullable<BaseTexture>;
  38575. private _reflectionTexture;
  38576. /**
  38577. * Define the texture used to display the reflection.
  38578. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38579. */
  38580. reflectionTexture: Nullable<BaseTexture>;
  38581. private _emissiveTexture;
  38582. /**
  38583. * Define texture of the material as if self lit.
  38584. * This will be mixed in the final result even in the absence of light.
  38585. */
  38586. emissiveTexture: Nullable<BaseTexture>;
  38587. private _specularTexture;
  38588. /**
  38589. * Define how the color and intensity of the highlight given by the light in the material.
  38590. */
  38591. specularTexture: Nullable<BaseTexture>;
  38592. private _bumpTexture;
  38593. /**
  38594. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38595. * 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.
  38596. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38597. */
  38598. bumpTexture: Nullable<BaseTexture>;
  38599. private _lightmapTexture;
  38600. /**
  38601. * Complex lighting can be computationally expensive to compute at runtime.
  38602. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38603. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38604. */
  38605. lightmapTexture: Nullable<BaseTexture>;
  38606. private _refractionTexture;
  38607. /**
  38608. * Define the texture used to display the refraction.
  38609. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38610. */
  38611. refractionTexture: Nullable<BaseTexture>;
  38612. /**
  38613. * The color of the material lit by the environmental background lighting.
  38614. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38615. */
  38616. ambientColor: Color3;
  38617. /**
  38618. * The basic color of the material as viewed under a light.
  38619. */
  38620. diffuseColor: Color3;
  38621. /**
  38622. * Define how the color and intensity of the highlight given by the light in the material.
  38623. */
  38624. specularColor: Color3;
  38625. /**
  38626. * Define the color of the material as if self lit.
  38627. * This will be mixed in the final result even in the absence of light.
  38628. */
  38629. emissiveColor: Color3;
  38630. /**
  38631. * Defines how sharp are the highlights in the material.
  38632. * The bigger the value the sharper giving a more glossy feeling to the result.
  38633. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38634. */
  38635. specularPower: number;
  38636. private _useAlphaFromDiffuseTexture;
  38637. /**
  38638. * Does the transparency come from the diffuse texture alpha channel.
  38639. */
  38640. useAlphaFromDiffuseTexture: boolean;
  38641. private _useEmissiveAsIllumination;
  38642. /**
  38643. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38644. */
  38645. useEmissiveAsIllumination: boolean;
  38646. private _linkEmissiveWithDiffuse;
  38647. /**
  38648. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38649. * the emissive level when the final color is close to one.
  38650. */
  38651. linkEmissiveWithDiffuse: boolean;
  38652. private _useSpecularOverAlpha;
  38653. /**
  38654. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38655. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38656. */
  38657. useSpecularOverAlpha: boolean;
  38658. private _useReflectionOverAlpha;
  38659. /**
  38660. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38661. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38662. */
  38663. useReflectionOverAlpha: boolean;
  38664. private _disableLighting;
  38665. /**
  38666. * Does lights from the scene impacts this material.
  38667. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38668. */
  38669. disableLighting: boolean;
  38670. private _useObjectSpaceNormalMap;
  38671. /**
  38672. * Allows using an object space normal map (instead of tangent space).
  38673. */
  38674. useObjectSpaceNormalMap: boolean;
  38675. private _useParallax;
  38676. /**
  38677. * Is parallax enabled or not.
  38678. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38679. */
  38680. useParallax: boolean;
  38681. private _useParallaxOcclusion;
  38682. /**
  38683. * Is parallax occlusion enabled or not.
  38684. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38685. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38686. */
  38687. useParallaxOcclusion: boolean;
  38688. /**
  38689. * 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.
  38690. */
  38691. parallaxScaleBias: number;
  38692. private _roughness;
  38693. /**
  38694. * Helps to define how blurry the reflections should appears in the material.
  38695. */
  38696. roughness: number;
  38697. /**
  38698. * In case of refraction, define the value of the indice of refraction.
  38699. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38700. */
  38701. indexOfRefraction: number;
  38702. /**
  38703. * Invert the refraction texture alongside the y axis.
  38704. * It can be useful with procedural textures or probe for instance.
  38705. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38706. */
  38707. invertRefractionY: boolean;
  38708. /**
  38709. * Defines the alpha limits in alpha test mode.
  38710. */
  38711. alphaCutOff: number;
  38712. private _useLightmapAsShadowmap;
  38713. /**
  38714. * In case of light mapping, define whether the map contains light or shadow informations.
  38715. */
  38716. useLightmapAsShadowmap: boolean;
  38717. private _diffuseFresnelParameters;
  38718. /**
  38719. * Define the diffuse fresnel parameters of the material.
  38720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38721. */
  38722. diffuseFresnelParameters: FresnelParameters;
  38723. private _opacityFresnelParameters;
  38724. /**
  38725. * Define the opacity fresnel parameters of the material.
  38726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38727. */
  38728. opacityFresnelParameters: FresnelParameters;
  38729. private _reflectionFresnelParameters;
  38730. /**
  38731. * Define the reflection fresnel parameters of the material.
  38732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38733. */
  38734. reflectionFresnelParameters: FresnelParameters;
  38735. private _refractionFresnelParameters;
  38736. /**
  38737. * Define the refraction fresnel parameters of the material.
  38738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38739. */
  38740. refractionFresnelParameters: FresnelParameters;
  38741. private _emissiveFresnelParameters;
  38742. /**
  38743. * Define the emissive fresnel parameters of the material.
  38744. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38745. */
  38746. emissiveFresnelParameters: FresnelParameters;
  38747. private _useReflectionFresnelFromSpecular;
  38748. /**
  38749. * If true automatically deducts the fresnels values from the material specularity.
  38750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38751. */
  38752. useReflectionFresnelFromSpecular: boolean;
  38753. private _useGlossinessFromSpecularMapAlpha;
  38754. /**
  38755. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38756. */
  38757. useGlossinessFromSpecularMapAlpha: boolean;
  38758. private _maxSimultaneousLights;
  38759. /**
  38760. * Defines the maximum number of lights that can be used in the material
  38761. */
  38762. maxSimultaneousLights: number;
  38763. private _invertNormalMapX;
  38764. /**
  38765. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38766. */
  38767. invertNormalMapX: boolean;
  38768. private _invertNormalMapY;
  38769. /**
  38770. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38771. */
  38772. invertNormalMapY: boolean;
  38773. private _twoSidedLighting;
  38774. /**
  38775. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38776. */
  38777. twoSidedLighting: boolean;
  38778. /**
  38779. * Default configuration related to image processing available in the standard Material.
  38780. */
  38781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38782. /**
  38783. * Gets the image processing configuration used either in this material.
  38784. */
  38785. /**
  38786. * Sets the Default image processing configuration used either in the this material.
  38787. *
  38788. * If sets to null, the scene one is in use.
  38789. */
  38790. imageProcessingConfiguration: ImageProcessingConfiguration;
  38791. /**
  38792. * Keep track of the image processing observer to allow dispose and replace.
  38793. */
  38794. private _imageProcessingObserver;
  38795. /**
  38796. * Attaches a new image processing configuration to the Standard Material.
  38797. * @param configuration
  38798. */
  38799. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38800. /**
  38801. * Gets wether the color curves effect is enabled.
  38802. */
  38803. /**
  38804. * Sets wether the color curves effect is enabled.
  38805. */
  38806. cameraColorCurvesEnabled: boolean;
  38807. /**
  38808. * Gets wether the color grading effect is enabled.
  38809. */
  38810. /**
  38811. * Gets wether the color grading effect is enabled.
  38812. */
  38813. cameraColorGradingEnabled: boolean;
  38814. /**
  38815. * Gets wether tonemapping is enabled or not.
  38816. */
  38817. /**
  38818. * Sets wether tonemapping is enabled or not
  38819. */
  38820. cameraToneMappingEnabled: boolean;
  38821. /**
  38822. * The camera exposure used on this material.
  38823. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38824. * This corresponds to a photographic exposure.
  38825. */
  38826. /**
  38827. * The camera exposure used on this material.
  38828. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38829. * This corresponds to a photographic exposure.
  38830. */
  38831. cameraExposure: number;
  38832. /**
  38833. * Gets The camera contrast used on this material.
  38834. */
  38835. /**
  38836. * Sets The camera contrast used on this material.
  38837. */
  38838. cameraContrast: number;
  38839. /**
  38840. * Gets the Color Grading 2D Lookup Texture.
  38841. */
  38842. /**
  38843. * Sets the Color Grading 2D Lookup Texture.
  38844. */
  38845. cameraColorGradingTexture: Nullable<BaseTexture>;
  38846. /**
  38847. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38848. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38849. * 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;
  38850. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38851. */
  38852. /**
  38853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38855. * 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;
  38856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38857. */
  38858. cameraColorCurves: Nullable<ColorCurves>;
  38859. /**
  38860. * Custom callback helping to override the default shader used in the material.
  38861. */
  38862. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38863. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38864. protected _worldViewProjectionMatrix: Matrix;
  38865. protected _globalAmbientColor: Color3;
  38866. protected _useLogarithmicDepth: boolean;
  38867. /**
  38868. * Instantiates a new standard material.
  38869. * This is the default material used in Babylon. It is the best trade off between quality
  38870. * and performances.
  38871. * @see http://doc.babylonjs.com/babylon101/materials
  38872. * @param name Define the name of the material in the scene
  38873. * @param scene Define the scene the material belong to
  38874. */
  38875. constructor(name: string, scene: Scene);
  38876. /**
  38877. * Gets a boolean indicating that current material needs to register RTT
  38878. */
  38879. readonly hasRenderTargetTextures: boolean;
  38880. /**
  38881. * Gets the current class name of the material e.g. "StandardMaterial"
  38882. * Mainly use in serialization.
  38883. * @returns the class name
  38884. */
  38885. getClassName(): string;
  38886. /**
  38887. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38888. * You can try switching to logarithmic depth.
  38889. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38890. */
  38891. useLogarithmicDepth: boolean;
  38892. /**
  38893. * Specifies if the material will require alpha blending
  38894. * @returns a boolean specifying if alpha blending is needed
  38895. */
  38896. needAlphaBlending(): boolean;
  38897. /**
  38898. * Specifies if this material should be rendered in alpha test mode
  38899. * @returns a boolean specifying if an alpha test is needed.
  38900. */
  38901. needAlphaTesting(): boolean;
  38902. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38903. /**
  38904. * Get the texture used for alpha test purpose.
  38905. * @returns the diffuse texture in case of the standard material.
  38906. */
  38907. getAlphaTestTexture(): Nullable<BaseTexture>;
  38908. /**
  38909. * Get if the submesh is ready to be used and all its information available.
  38910. * Child classes can use it to update shaders
  38911. * @param mesh defines the mesh to check
  38912. * @param subMesh defines which submesh to check
  38913. * @param useInstances specifies that instances should be used
  38914. * @returns a boolean indicating that the submesh is ready or not
  38915. */
  38916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38917. /**
  38918. * Builds the material UBO layouts.
  38919. * Used internally during the effect preparation.
  38920. */
  38921. buildUniformLayout(): void;
  38922. /**
  38923. * Unbinds the material from the mesh
  38924. */
  38925. unbind(): void;
  38926. /**
  38927. * Binds the submesh to this material by preparing the effect and shader to draw
  38928. * @param world defines the world transformation matrix
  38929. * @param mesh defines the mesh containing the submesh
  38930. * @param subMesh defines the submesh to bind the material to
  38931. */
  38932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38933. /**
  38934. * Get the list of animatables in the material.
  38935. * @returns the list of animatables object used in the material
  38936. */
  38937. getAnimatables(): IAnimatable[];
  38938. /**
  38939. * Gets the active textures from the material
  38940. * @returns an array of textures
  38941. */
  38942. getActiveTextures(): BaseTexture[];
  38943. /**
  38944. * Specifies if the material uses a texture
  38945. * @param texture defines the texture to check against the material
  38946. * @returns a boolean specifying if the material uses the texture
  38947. */
  38948. hasTexture(texture: BaseTexture): boolean;
  38949. /**
  38950. * Disposes the material
  38951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38953. */
  38954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38955. /**
  38956. * Makes a duplicate of the material, and gives it a new name
  38957. * @param name defines the new name for the duplicated material
  38958. * @returns the cloned material
  38959. */
  38960. clone(name: string): StandardMaterial;
  38961. /**
  38962. * Serializes this material in a JSON representation
  38963. * @returns the serialized material object
  38964. */
  38965. serialize(): any;
  38966. /**
  38967. * Creates a standard material from parsed material data
  38968. * @param source defines the JSON representation of the material
  38969. * @param scene defines the hosting scene
  38970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38971. * @returns a new standard material
  38972. */
  38973. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38974. /**
  38975. * Are diffuse textures enabled in the application.
  38976. */
  38977. static DiffuseTextureEnabled: boolean;
  38978. /**
  38979. * Are ambient textures enabled in the application.
  38980. */
  38981. static AmbientTextureEnabled: boolean;
  38982. /**
  38983. * Are opacity textures enabled in the application.
  38984. */
  38985. static OpacityTextureEnabled: boolean;
  38986. /**
  38987. * Are reflection textures enabled in the application.
  38988. */
  38989. static ReflectionTextureEnabled: boolean;
  38990. /**
  38991. * Are emissive textures enabled in the application.
  38992. */
  38993. static EmissiveTextureEnabled: boolean;
  38994. /**
  38995. * Are specular textures enabled in the application.
  38996. */
  38997. static SpecularTextureEnabled: boolean;
  38998. /**
  38999. * Are bump textures enabled in the application.
  39000. */
  39001. static BumpTextureEnabled: boolean;
  39002. /**
  39003. * Are lightmap textures enabled in the application.
  39004. */
  39005. static LightmapTextureEnabled: boolean;
  39006. /**
  39007. * Are refraction textures enabled in the application.
  39008. */
  39009. static RefractionTextureEnabled: boolean;
  39010. /**
  39011. * Are color grading textures enabled in the application.
  39012. */
  39013. static ColorGradingTextureEnabled: boolean;
  39014. /**
  39015. * Are fresnels enabled in the application.
  39016. */
  39017. static FresnelEnabled: boolean;
  39018. }
  39019. }
  39020. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39021. import { Scene } from "babylonjs/scene";
  39022. import { Texture } from "babylonjs/Materials/Textures/texture";
  39023. /**
  39024. * A class extending Texture allowing drawing on a texture
  39025. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39026. */
  39027. export class DynamicTexture extends Texture {
  39028. private _generateMipMaps;
  39029. private _canvas;
  39030. private _context;
  39031. private _engine;
  39032. /**
  39033. * Creates a DynamicTexture
  39034. * @param name defines the name of the texture
  39035. * @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
  39036. * @param scene defines the scene where you want the texture
  39037. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39038. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39039. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39040. */
  39041. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39042. /**
  39043. * Get the current class name of the texture useful for serialization or dynamic coding.
  39044. * @returns "DynamicTexture"
  39045. */
  39046. getClassName(): string;
  39047. /**
  39048. * Gets the current state of canRescale
  39049. */
  39050. readonly canRescale: boolean;
  39051. private _recreate;
  39052. /**
  39053. * Scales the texture
  39054. * @param ratio the scale factor to apply to both width and height
  39055. */
  39056. scale(ratio: number): void;
  39057. /**
  39058. * Resizes the texture
  39059. * @param width the new width
  39060. * @param height the new height
  39061. */
  39062. scaleTo(width: number, height: number): void;
  39063. /**
  39064. * Gets the context of the canvas used by the texture
  39065. * @returns the canvas context of the dynamic texture
  39066. */
  39067. getContext(): CanvasRenderingContext2D;
  39068. /**
  39069. * Clears the texture
  39070. */
  39071. clear(): void;
  39072. /**
  39073. * Updates the texture
  39074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39075. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39076. */
  39077. update(invertY?: boolean, premulAlpha?: boolean): void;
  39078. /**
  39079. * Draws text onto the texture
  39080. * @param text defines the text to be drawn
  39081. * @param x defines the placement of the text from the left
  39082. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39083. * @param font defines the font to be used with font-style, font-size, font-name
  39084. * @param color defines the color used for the text
  39085. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39086. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39087. * @param update defines whether texture is immediately update (default is true)
  39088. */
  39089. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39090. /**
  39091. * Clones the texture
  39092. * @returns the clone of the texture.
  39093. */
  39094. clone(): DynamicTexture;
  39095. /**
  39096. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39097. * @returns a serialized dynamic texture object
  39098. */
  39099. serialize(): any;
  39100. /** @hidden */
  39101. _rebuild(): void;
  39102. }
  39103. }
  39104. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39105. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39107. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39108. /** @hidden */
  39109. export var imageProcessingPixelShader: {
  39110. name: string;
  39111. shader: string;
  39112. };
  39113. }
  39114. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39115. import { Nullable } from "babylonjs/types";
  39116. import { Color4 } from "babylonjs/Maths/math";
  39117. import { Camera } from "babylonjs/Cameras/camera";
  39118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39119. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39120. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39121. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39122. import { Engine } from "babylonjs/Engines/engine";
  39123. import "babylonjs/Shaders/imageProcessing.fragment";
  39124. import "babylonjs/Shaders/postprocess.vertex";
  39125. /**
  39126. * ImageProcessingPostProcess
  39127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39128. */
  39129. export class ImageProcessingPostProcess extends PostProcess {
  39130. /**
  39131. * Default configuration related to image processing available in the PBR Material.
  39132. */
  39133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39134. /**
  39135. * Gets the image processing configuration used either in this material.
  39136. */
  39137. /**
  39138. * Sets the Default image processing configuration used either in the this material.
  39139. *
  39140. * If sets to null, the scene one is in use.
  39141. */
  39142. imageProcessingConfiguration: ImageProcessingConfiguration;
  39143. /**
  39144. * Keep track of the image processing observer to allow dispose and replace.
  39145. */
  39146. private _imageProcessingObserver;
  39147. /**
  39148. * Attaches a new image processing configuration to the PBR Material.
  39149. * @param configuration
  39150. */
  39151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39152. /**
  39153. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39154. */
  39155. /**
  39156. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39157. */
  39158. colorCurves: Nullable<ColorCurves>;
  39159. /**
  39160. * Gets wether the color curves effect is enabled.
  39161. */
  39162. /**
  39163. * Sets wether the color curves effect is enabled.
  39164. */
  39165. colorCurvesEnabled: boolean;
  39166. /**
  39167. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39168. */
  39169. /**
  39170. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39171. */
  39172. colorGradingTexture: Nullable<BaseTexture>;
  39173. /**
  39174. * Gets wether the color grading effect is enabled.
  39175. */
  39176. /**
  39177. * Gets wether the color grading effect is enabled.
  39178. */
  39179. colorGradingEnabled: boolean;
  39180. /**
  39181. * Gets exposure used in the effect.
  39182. */
  39183. /**
  39184. * Sets exposure used in the effect.
  39185. */
  39186. exposure: number;
  39187. /**
  39188. * Gets wether tonemapping is enabled or not.
  39189. */
  39190. /**
  39191. * Sets wether tonemapping is enabled or not
  39192. */
  39193. toneMappingEnabled: boolean;
  39194. /**
  39195. * Gets contrast used in the effect.
  39196. */
  39197. /**
  39198. * Sets contrast used in the effect.
  39199. */
  39200. contrast: number;
  39201. /**
  39202. * Gets Vignette stretch size.
  39203. */
  39204. /**
  39205. * Sets Vignette stretch size.
  39206. */
  39207. vignetteStretch: number;
  39208. /**
  39209. * Gets Vignette centre X Offset.
  39210. */
  39211. /**
  39212. * Sets Vignette centre X Offset.
  39213. */
  39214. vignetteCentreX: number;
  39215. /**
  39216. * Gets Vignette centre Y Offset.
  39217. */
  39218. /**
  39219. * Sets Vignette centre Y Offset.
  39220. */
  39221. vignetteCentreY: number;
  39222. /**
  39223. * Gets Vignette weight or intensity of the vignette effect.
  39224. */
  39225. /**
  39226. * Sets Vignette weight or intensity of the vignette effect.
  39227. */
  39228. vignetteWeight: number;
  39229. /**
  39230. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39231. * if vignetteEnabled is set to true.
  39232. */
  39233. /**
  39234. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39235. * if vignetteEnabled is set to true.
  39236. */
  39237. vignetteColor: Color4;
  39238. /**
  39239. * Gets Camera field of view used by the Vignette effect.
  39240. */
  39241. /**
  39242. * Sets Camera field of view used by the Vignette effect.
  39243. */
  39244. vignetteCameraFov: number;
  39245. /**
  39246. * Gets the vignette blend mode allowing different kind of effect.
  39247. */
  39248. /**
  39249. * Sets the vignette blend mode allowing different kind of effect.
  39250. */
  39251. vignetteBlendMode: number;
  39252. /**
  39253. * Gets wether the vignette effect is enabled.
  39254. */
  39255. /**
  39256. * Sets wether the vignette effect is enabled.
  39257. */
  39258. vignetteEnabled: boolean;
  39259. private _fromLinearSpace;
  39260. /**
  39261. * Gets wether the input of the processing is in Gamma or Linear Space.
  39262. */
  39263. /**
  39264. * Sets wether the input of the processing is in Gamma or Linear Space.
  39265. */
  39266. fromLinearSpace: boolean;
  39267. /**
  39268. * Defines cache preventing GC.
  39269. */
  39270. private _defines;
  39271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39272. /**
  39273. * "ImageProcessingPostProcess"
  39274. * @returns "ImageProcessingPostProcess"
  39275. */
  39276. getClassName(): string;
  39277. protected _updateParameters(): void;
  39278. dispose(camera?: Camera): void;
  39279. }
  39280. }
  39281. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39282. import { Scene } from "babylonjs/scene";
  39283. import { Color3 } from "babylonjs/Maths/math";
  39284. import { Mesh } from "babylonjs/Meshes/mesh";
  39285. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39286. /**
  39287. * Class containing static functions to help procedurally build meshes
  39288. */
  39289. export class GroundBuilder {
  39290. /**
  39291. * Creates a ground mesh
  39292. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39293. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39295. * @param name defines the name of the mesh
  39296. * @param options defines the options used to create the mesh
  39297. * @param scene defines the hosting scene
  39298. * @returns the ground mesh
  39299. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39300. */
  39301. static CreateGround(name: string, options: {
  39302. width?: number;
  39303. height?: number;
  39304. subdivisions?: number;
  39305. subdivisionsX?: number;
  39306. subdivisionsY?: number;
  39307. updatable?: boolean;
  39308. }, scene: any): Mesh;
  39309. /**
  39310. * Creates a tiled ground mesh
  39311. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39312. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39313. * * 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
  39314. * * 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
  39315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39316. * @param name defines the name of the mesh
  39317. * @param options defines the options used to create the mesh
  39318. * @param scene defines the hosting scene
  39319. * @returns the tiled ground mesh
  39320. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39321. */
  39322. static CreateTiledGround(name: string, options: {
  39323. xmin: number;
  39324. zmin: number;
  39325. xmax: number;
  39326. zmax: number;
  39327. subdivisions?: {
  39328. w: number;
  39329. h: number;
  39330. };
  39331. precision?: {
  39332. w: number;
  39333. h: number;
  39334. };
  39335. updatable?: boolean;
  39336. }, scene: Scene): Mesh;
  39337. /**
  39338. * Creates a ground mesh from a height map
  39339. * * The parameter `url` sets the URL of the height map image resource.
  39340. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39341. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39342. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39343. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39344. * * 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.
  39345. * * 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).
  39346. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39348. * @param name defines the name of the mesh
  39349. * @param url defines the url to the height map
  39350. * @param options defines the options used to create the mesh
  39351. * @param scene defines the hosting scene
  39352. * @returns the ground mesh
  39353. * @see https://doc.babylonjs.com/babylon101/height_map
  39354. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39355. */
  39356. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39357. width?: number;
  39358. height?: number;
  39359. subdivisions?: number;
  39360. minHeight?: number;
  39361. maxHeight?: number;
  39362. colorFilter?: Color3;
  39363. alphaFilter?: number;
  39364. updatable?: boolean;
  39365. onReady?: (mesh: GroundMesh) => void;
  39366. }, scene: Scene): GroundMesh;
  39367. }
  39368. }
  39369. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39370. import { Vector4 } from "babylonjs/Maths/math";
  39371. import { Mesh } from "babylonjs/Meshes/mesh";
  39372. /**
  39373. * Class containing static functions to help procedurally build meshes
  39374. */
  39375. export class TorusBuilder {
  39376. /**
  39377. * Creates a torus mesh
  39378. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39379. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39380. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39384. * @param name defines the name of the mesh
  39385. * @param options defines the options used to create the mesh
  39386. * @param scene defines the hosting scene
  39387. * @returns the torus mesh
  39388. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39389. */
  39390. static CreateTorus(name: string, options: {
  39391. diameter?: number;
  39392. thickness?: number;
  39393. tessellation?: number;
  39394. updatable?: boolean;
  39395. sideOrientation?: number;
  39396. frontUVs?: Vector4;
  39397. backUVs?: Vector4;
  39398. }, scene: any): Mesh;
  39399. }
  39400. }
  39401. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39402. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39403. import { Mesh } from "babylonjs/Meshes/mesh";
  39404. /**
  39405. * Class containing static functions to help procedurally build meshes
  39406. */
  39407. export class CylinderBuilder {
  39408. /**
  39409. * Creates a cylinder or a cone mesh
  39410. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39411. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39412. * * 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.
  39413. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39414. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39415. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39416. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39417. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39418. * * 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).
  39419. * * 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
  39420. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39421. * * 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
  39422. * * 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.
  39423. * * If `enclose` is false, a ring surface is one element.
  39424. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39425. * * 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
  39426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39429. * @param name defines the name of the mesh
  39430. * @param options defines the options used to create the mesh
  39431. * @param scene defines the hosting scene
  39432. * @returns the cylinder mesh
  39433. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39434. */
  39435. static CreateCylinder(name: string, options: {
  39436. height?: number;
  39437. diameterTop?: number;
  39438. diameterBottom?: number;
  39439. diameter?: number;
  39440. tessellation?: number;
  39441. subdivisions?: number;
  39442. arc?: number;
  39443. faceColors?: Color4[];
  39444. faceUV?: Vector4[];
  39445. updatable?: boolean;
  39446. hasRings?: boolean;
  39447. enclose?: boolean;
  39448. sideOrientation?: number;
  39449. frontUVs?: Vector4;
  39450. backUVs?: Vector4;
  39451. }, scene: any): Mesh;
  39452. }
  39453. }
  39454. declare module "babylonjs/Gamepads/gamepadManager" {
  39455. import { Observable } from "babylonjs/Misc/observable";
  39456. import { Nullable } from "babylonjs/types";
  39457. import { Scene } from "babylonjs/scene";
  39458. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39459. /**
  39460. * Manager for handling gamepads
  39461. */
  39462. export class GamepadManager {
  39463. private _scene?;
  39464. private _babylonGamepads;
  39465. private _oneGamepadConnected;
  39466. /** @hidden */
  39467. _isMonitoring: boolean;
  39468. private _gamepadEventSupported;
  39469. private _gamepadSupport;
  39470. /**
  39471. * observable to be triggered when the gamepad controller has been connected
  39472. */
  39473. onGamepadConnectedObservable: Observable<Gamepad>;
  39474. /**
  39475. * observable to be triggered when the gamepad controller has been disconnected
  39476. */
  39477. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39478. private _onGamepadConnectedEvent;
  39479. private _onGamepadDisconnectedEvent;
  39480. /**
  39481. * Initializes the gamepad manager
  39482. * @param _scene BabylonJS scene
  39483. */
  39484. constructor(_scene?: Scene | undefined);
  39485. /**
  39486. * The gamepads in the game pad manager
  39487. */
  39488. readonly gamepads: Gamepad[];
  39489. /**
  39490. * Get the gamepad controllers based on type
  39491. * @param type The type of gamepad controller
  39492. * @returns Nullable gamepad
  39493. */
  39494. getGamepadByType(type?: number): Nullable<Gamepad>;
  39495. /**
  39496. * Disposes the gamepad manager
  39497. */
  39498. dispose(): void;
  39499. private _addNewGamepad;
  39500. private _startMonitoringGamepads;
  39501. private _stopMonitoringGamepads;
  39502. /** @hidden */
  39503. _checkGamepadsStatus(): void;
  39504. private _updateGamepadObjects;
  39505. }
  39506. }
  39507. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39508. import { Nullable } from "babylonjs/types";
  39509. import { Scene } from "babylonjs/scene";
  39510. import { ISceneComponent } from "babylonjs/sceneComponent";
  39511. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39512. module "babylonjs/scene" {
  39513. interface Scene {
  39514. /** @hidden */
  39515. _gamepadManager: Nullable<GamepadManager>;
  39516. /**
  39517. * Gets the gamepad manager associated with the scene
  39518. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39519. */
  39520. gamepadManager: GamepadManager;
  39521. }
  39522. }
  39523. module "babylonjs/Cameras/freeCameraInputsManager" {
  39524. /**
  39525. * Interface representing a free camera inputs manager
  39526. */
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Adds gamepad input support to the FreeCameraInputsManager.
  39530. * @returns the FreeCameraInputsManager
  39531. */
  39532. addGamepad(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39536. /**
  39537. * Interface representing an arc rotate camera inputs manager
  39538. */
  39539. interface ArcRotateCameraInputsManager {
  39540. /**
  39541. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39542. * @returns the camera inputs manager
  39543. */
  39544. addGamepad(): ArcRotateCameraInputsManager;
  39545. }
  39546. }
  39547. /**
  39548. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39549. */
  39550. export class GamepadSystemSceneComponent implements ISceneComponent {
  39551. /**
  39552. * The component name helpfull to identify the component in the list of scene components.
  39553. */
  39554. readonly name: string;
  39555. /**
  39556. * The scene the component belongs to.
  39557. */
  39558. scene: Scene;
  39559. /**
  39560. * Creates a new instance of the component for the given scene
  39561. * @param scene Defines the scene to register the component in
  39562. */
  39563. constructor(scene: Scene);
  39564. /**
  39565. * Registers the component in a given scene
  39566. */
  39567. register(): void;
  39568. /**
  39569. * Rebuilds the elements related to this component in case of
  39570. * context lost for instance.
  39571. */
  39572. rebuild(): void;
  39573. /**
  39574. * Disposes the component and the associated ressources
  39575. */
  39576. dispose(): void;
  39577. private _beforeCameraUpdate;
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39581. import { Observable } from "babylonjs/Misc/observable";
  39582. import { Nullable } from "babylonjs/types";
  39583. import { Camera } from "babylonjs/Cameras/camera";
  39584. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39585. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39586. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39587. import { Scene } from "babylonjs/scene";
  39588. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39589. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39591. import { Mesh } from "babylonjs/Meshes/mesh";
  39592. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39593. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39594. import "babylonjs/Meshes/Builders/groundBuilder";
  39595. import "babylonjs/Meshes/Builders/torusBuilder";
  39596. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39597. import "babylonjs/Gamepads/gamepadSceneComponent";
  39598. import "babylonjs/Animations/animatable";
  39599. /**
  39600. * Options to modify the vr teleportation behavior.
  39601. */
  39602. export interface VRTeleportationOptions {
  39603. /**
  39604. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39605. */
  39606. floorMeshName?: string;
  39607. /**
  39608. * A list of meshes to be used as the teleportation floor. (default: empty)
  39609. */
  39610. floorMeshes?: Mesh[];
  39611. }
  39612. /**
  39613. * Options to modify the vr experience helper's behavior.
  39614. */
  39615. export interface VRExperienceHelperOptions extends WebVROptions {
  39616. /**
  39617. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39618. */
  39619. createDeviceOrientationCamera?: boolean;
  39620. /**
  39621. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39622. */
  39623. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39624. /**
  39625. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39626. */
  39627. laserToggle?: boolean;
  39628. /**
  39629. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39630. */
  39631. floorMeshes?: Mesh[];
  39632. /**
  39633. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39634. */
  39635. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39636. }
  39637. /**
  39638. * Helps to quickly add VR support to an existing scene.
  39639. * See http://doc.babylonjs.com/how_to/webvr_helper
  39640. */
  39641. export class VRExperienceHelper {
  39642. /** Options to modify the vr experience helper's behavior. */
  39643. webVROptions: VRExperienceHelperOptions;
  39644. private _scene;
  39645. private _position;
  39646. private _btnVR;
  39647. private _btnVRDisplayed;
  39648. private _webVRsupported;
  39649. private _webVRready;
  39650. private _webVRrequesting;
  39651. private _webVRpresenting;
  39652. private _hasEnteredVR;
  39653. private _fullscreenVRpresenting;
  39654. private _canvas;
  39655. private _webVRCamera;
  39656. private _vrDeviceOrientationCamera;
  39657. private _deviceOrientationCamera;
  39658. private _existingCamera;
  39659. private _onKeyDown;
  39660. private _onVrDisplayPresentChange;
  39661. private _onVRDisplayChanged;
  39662. private _onVRRequestPresentStart;
  39663. private _onVRRequestPresentComplete;
  39664. /**
  39665. * Observable raised when entering VR.
  39666. */
  39667. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39668. /**
  39669. * Observable raised when exiting VR.
  39670. */
  39671. onExitingVRObservable: Observable<VRExperienceHelper>;
  39672. /**
  39673. * Observable raised when controller mesh is loaded.
  39674. */
  39675. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39676. /** Return this.onEnteringVRObservable
  39677. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39678. */
  39679. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39680. /** Return this.onExitingVRObservable
  39681. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39682. */
  39683. readonly onExitingVR: Observable<VRExperienceHelper>;
  39684. /** Return this.onControllerMeshLoadedObservable
  39685. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39686. */
  39687. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39688. private _rayLength;
  39689. private _useCustomVRButton;
  39690. private _teleportationRequested;
  39691. private _teleportActive;
  39692. private _floorMeshName;
  39693. private _floorMeshesCollection;
  39694. private _rotationAllowed;
  39695. private _teleportBackwardsVector;
  39696. private _teleportationTarget;
  39697. private _isDefaultTeleportationTarget;
  39698. private _postProcessMove;
  39699. private _teleportationFillColor;
  39700. private _teleportationBorderColor;
  39701. private _rotationAngle;
  39702. private _haloCenter;
  39703. private _cameraGazer;
  39704. private _padSensibilityUp;
  39705. private _padSensibilityDown;
  39706. private _leftController;
  39707. private _rightController;
  39708. /**
  39709. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39710. */
  39711. onNewMeshSelected: Observable<AbstractMesh>;
  39712. /**
  39713. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39714. */
  39715. onNewMeshPicked: Observable<PickingInfo>;
  39716. private _circleEase;
  39717. /**
  39718. * Observable raised before camera teleportation
  39719. */
  39720. onBeforeCameraTeleport: Observable<Vector3>;
  39721. /**
  39722. * Observable raised after camera teleportation
  39723. */
  39724. onAfterCameraTeleport: Observable<Vector3>;
  39725. /**
  39726. * Observable raised when current selected mesh gets unselected
  39727. */
  39728. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39729. private _raySelectionPredicate;
  39730. /**
  39731. * To be optionaly changed by user to define custom ray selection
  39732. */
  39733. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39734. /**
  39735. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39736. */
  39737. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39738. /**
  39739. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39740. */
  39741. teleportationEnabled: boolean;
  39742. private _defaultHeight;
  39743. private _teleportationInitialized;
  39744. private _interactionsEnabled;
  39745. private _interactionsRequested;
  39746. private _displayGaze;
  39747. private _displayLaserPointer;
  39748. /**
  39749. * The mesh used to display where the user is going to teleport.
  39750. */
  39751. /**
  39752. * Sets the mesh to be used to display where the user is going to teleport.
  39753. */
  39754. teleportationTarget: Mesh;
  39755. /**
  39756. * 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
  39757. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39758. * See http://doc.babylonjs.com/resources/baking_transformations
  39759. */
  39760. gazeTrackerMesh: Mesh;
  39761. /**
  39762. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39763. */
  39764. updateGazeTrackerScale: boolean;
  39765. /**
  39766. * If the gaze trackers color should be updated when selecting meshes
  39767. */
  39768. updateGazeTrackerColor: boolean;
  39769. /**
  39770. * The gaze tracking mesh corresponding to the left controller
  39771. */
  39772. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39773. /**
  39774. * The gaze tracking mesh corresponding to the right controller
  39775. */
  39776. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39777. /**
  39778. * If the ray of the gaze should be displayed.
  39779. */
  39780. /**
  39781. * Sets if the ray of the gaze should be displayed.
  39782. */
  39783. displayGaze: boolean;
  39784. /**
  39785. * If the ray of the LaserPointer should be displayed.
  39786. */
  39787. /**
  39788. * Sets if the ray of the LaserPointer should be displayed.
  39789. */
  39790. displayLaserPointer: boolean;
  39791. /**
  39792. * The deviceOrientationCamera used as the camera when not in VR.
  39793. */
  39794. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39795. /**
  39796. * Based on the current WebVR support, returns the current VR camera used.
  39797. */
  39798. readonly currentVRCamera: Nullable<Camera>;
  39799. /**
  39800. * The webVRCamera which is used when in VR.
  39801. */
  39802. readonly webVRCamera: WebVRFreeCamera;
  39803. /**
  39804. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39805. */
  39806. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39807. private readonly _teleportationRequestInitiated;
  39808. /**
  39809. * Defines wether or not Pointer lock should be requested when switching to
  39810. * full screen.
  39811. */
  39812. requestPointerLockOnFullScreen: boolean;
  39813. /**
  39814. * Instantiates a VRExperienceHelper.
  39815. * Helps to quickly add VR support to an existing scene.
  39816. * @param scene The scene the VRExperienceHelper belongs to.
  39817. * @param webVROptions Options to modify the vr experience helper's behavior.
  39818. */
  39819. constructor(scene: Scene,
  39820. /** Options to modify the vr experience helper's behavior. */
  39821. webVROptions?: VRExperienceHelperOptions);
  39822. private _onDefaultMeshLoaded;
  39823. private _onResize;
  39824. private _onFullscreenChange;
  39825. /**
  39826. * Gets a value indicating if we are currently in VR mode.
  39827. */
  39828. readonly isInVRMode: boolean;
  39829. private onVrDisplayPresentChange;
  39830. private onVRDisplayChanged;
  39831. private moveButtonToBottomRight;
  39832. private displayVRButton;
  39833. private updateButtonVisibility;
  39834. private _cachedAngularSensibility;
  39835. /**
  39836. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39837. * Otherwise, will use the fullscreen API.
  39838. */
  39839. enterVR(): void;
  39840. /**
  39841. * Attempt to exit VR, or fullscreen.
  39842. */
  39843. exitVR(): void;
  39844. /**
  39845. * The position of the vr experience helper.
  39846. */
  39847. /**
  39848. * Sets the position of the vr experience helper.
  39849. */
  39850. position: Vector3;
  39851. /**
  39852. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39853. */
  39854. enableInteractions(): void;
  39855. private readonly _noControllerIsActive;
  39856. private beforeRender;
  39857. private _isTeleportationFloor;
  39858. /**
  39859. * Adds a floor mesh to be used for teleportation.
  39860. * @param floorMesh the mesh to be used for teleportation.
  39861. */
  39862. addFloorMesh(floorMesh: Mesh): void;
  39863. /**
  39864. * Removes a floor mesh from being used for teleportation.
  39865. * @param floorMesh the mesh to be removed.
  39866. */
  39867. removeFloorMesh(floorMesh: Mesh): void;
  39868. /**
  39869. * Enables interactions and teleportation using the VR controllers and gaze.
  39870. * @param vrTeleportationOptions options to modify teleportation behavior.
  39871. */
  39872. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39873. private _onNewGamepadConnected;
  39874. private _tryEnableInteractionOnController;
  39875. private _onNewGamepadDisconnected;
  39876. private _enableInteractionOnController;
  39877. private _checkTeleportWithRay;
  39878. private _checkRotate;
  39879. private _checkTeleportBackwards;
  39880. private _enableTeleportationOnController;
  39881. private _createTeleportationCircles;
  39882. private _displayTeleportationTarget;
  39883. private _hideTeleportationTarget;
  39884. private _rotateCamera;
  39885. private _moveTeleportationSelectorTo;
  39886. private _workingVector;
  39887. private _workingQuaternion;
  39888. private _workingMatrix;
  39889. /**
  39890. * Teleports the users feet to the desired location
  39891. * @param location The location where the user's feet should be placed
  39892. */
  39893. teleportCamera(location: Vector3): void;
  39894. private _convertNormalToDirectionOfRay;
  39895. private _castRayAndSelectObject;
  39896. private _notifySelectedMeshUnselected;
  39897. /**
  39898. * Sets the color of the laser ray from the vr controllers.
  39899. * @param color new color for the ray.
  39900. */
  39901. changeLaserColor(color: Color3): void;
  39902. /**
  39903. * Sets the color of the ray from the vr headsets gaze.
  39904. * @param color new color for the ray.
  39905. */
  39906. changeGazeColor(color: Color3): void;
  39907. /**
  39908. * Exits VR and disposes of the vr experience helper
  39909. */
  39910. dispose(): void;
  39911. /**
  39912. * Gets the name of the VRExperienceHelper class
  39913. * @returns "VRExperienceHelper"
  39914. */
  39915. getClassName(): string;
  39916. }
  39917. }
  39918. declare module "babylonjs/Cameras/VR/index" {
  39919. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39920. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39921. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39922. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39923. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39924. export * from "babylonjs/Cameras/VR/webVRCamera";
  39925. }
  39926. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39927. import { Observable } from "babylonjs/Misc/observable";
  39928. import { Nullable } from "babylonjs/types";
  39929. import { IDisposable, Scene } from "babylonjs/scene";
  39930. import { Vector3 } from "babylonjs/Maths/math";
  39931. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39932. import { Ray } from "babylonjs/Culling/ray";
  39933. /**
  39934. * Manages an XRSession
  39935. * @see https://doc.babylonjs.com/how_to/webxr
  39936. */
  39937. export class WebXRSessionManager implements IDisposable {
  39938. private scene;
  39939. /**
  39940. * Fires every time a new xrFrame arrives which can be used to update the camera
  39941. */
  39942. onXRFrameObservable: Observable<any>;
  39943. /**
  39944. * Fires when the xr session is ended either by the device or manually done
  39945. */
  39946. onXRSessionEnded: Observable<any>;
  39947. /** @hidden */
  39948. _xrSession: XRSession;
  39949. /** @hidden */
  39950. _frameOfReference: XRFrameOfReference;
  39951. /** @hidden */
  39952. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39953. /** @hidden */
  39954. _currentXRFrame: Nullable<XRFrame>;
  39955. private _xrNavigator;
  39956. private _xrDevice;
  39957. private _tmpMatrix;
  39958. /**
  39959. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39960. * @param scene The scene which the session should be created for
  39961. */
  39962. constructor(scene: Scene);
  39963. /**
  39964. * Initializes the manager
  39965. * After initialization enterXR can be called to start an XR session
  39966. * @returns Promise which resolves after it is initialized
  39967. */
  39968. initializeAsync(): Promise<void>;
  39969. /**
  39970. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39971. * @param sessionCreationOptions xr options to create the session with
  39972. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39973. * @returns Promise which resolves after it enters XR
  39974. */
  39975. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39976. /**
  39977. * Stops the xrSession and restores the renderloop
  39978. * @returns Promise which resolves after it exits XR
  39979. */
  39980. exitXRAsync(): Promise<void>;
  39981. /**
  39982. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39983. * @param ray ray to cast into the environment
  39984. * @returns Promise which resolves with a collision point in the environment if it exists
  39985. */
  39986. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39987. /**
  39988. * Checks if a session would be supported for the creation options specified
  39989. * @param options creation options to check if they are supported
  39990. * @returns true if supported
  39991. */
  39992. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39993. /**
  39994. * @hidden
  39995. * Converts the render layer of xrSession to a render target
  39996. * @param session session to create render target for
  39997. * @param scene scene the new render target should be created for
  39998. */
  39999. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40000. /**
  40001. * Disposes of the session manager
  40002. */
  40003. dispose(): void;
  40004. }
  40005. }
  40006. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40007. import { Scene } from "babylonjs/scene";
  40008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40009. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40010. /**
  40011. * WebXR Camera which holds the views for the xrSession
  40012. * @see https://doc.babylonjs.com/how_to/webxr
  40013. */
  40014. export class WebXRCamera extends FreeCamera {
  40015. private static _TmpMatrix;
  40016. /**
  40017. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40018. * @param name the name of the camera
  40019. * @param scene the scene to add the camera to
  40020. */
  40021. constructor(name: string, scene: Scene);
  40022. private _updateNumberOfRigCameras;
  40023. /** @hidden */
  40024. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40025. /**
  40026. * Updates the cameras position from the current pose information of the XR session
  40027. * @param xrSessionManager the session containing pose information
  40028. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40029. */
  40030. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40031. }
  40032. }
  40033. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40034. import { Nullable } from "babylonjs/types";
  40035. import { Observable } from "babylonjs/Misc/observable";
  40036. import { IDisposable, Scene } from "babylonjs/scene";
  40037. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40039. import { Ray } from "babylonjs/Culling/ray";
  40040. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40041. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40042. /**
  40043. * States of the webXR experience
  40044. */
  40045. export enum WebXRState {
  40046. /**
  40047. * Transitioning to being in XR mode
  40048. */
  40049. ENTERING_XR = 0,
  40050. /**
  40051. * Transitioning to non XR mode
  40052. */
  40053. EXITING_XR = 1,
  40054. /**
  40055. * In XR mode and presenting
  40056. */
  40057. IN_XR = 2,
  40058. /**
  40059. * Not entered XR mode
  40060. */
  40061. NOT_IN_XR = 3
  40062. }
  40063. /**
  40064. * Helper class used to enable XR
  40065. * @see https://doc.babylonjs.com/how_to/webxr
  40066. */
  40067. export class WebXRExperienceHelper implements IDisposable {
  40068. private scene;
  40069. /**
  40070. * 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
  40071. */
  40072. container: AbstractMesh;
  40073. /**
  40074. * Camera used to render xr content
  40075. */
  40076. camera: WebXRCamera;
  40077. /**
  40078. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40079. */
  40080. state: WebXRState;
  40081. private _setState;
  40082. private static _TmpVector;
  40083. /**
  40084. * Fires when the state of the experience helper has changed
  40085. */
  40086. onStateChangedObservable: Observable<WebXRState>;
  40087. /** @hidden */
  40088. _sessionManager: WebXRSessionManager;
  40089. private _nonVRCamera;
  40090. private _originalSceneAutoClear;
  40091. private _supported;
  40092. /**
  40093. * Creates the experience helper
  40094. * @param scene the scene to attach the experience helper to
  40095. * @returns a promise for the experience helper
  40096. */
  40097. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40098. /**
  40099. * Creates a WebXRExperienceHelper
  40100. * @param scene The scene the helper should be created in
  40101. */
  40102. private constructor();
  40103. /**
  40104. * Exits XR mode and returns the scene to its original state
  40105. * @returns promise that resolves after xr mode has exited
  40106. */
  40107. exitXRAsync(): Promise<void>;
  40108. /**
  40109. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40110. * @param sessionCreationOptions options for the XR session
  40111. * @param frameOfReference frame of reference of the XR session
  40112. * @returns promise that resolves after xr mode has entered
  40113. */
  40114. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40115. /**
  40116. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40117. * @param ray ray to cast into the environment
  40118. * @returns Promise which resolves with a collision point in the environment if it exists
  40119. */
  40120. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40121. /**
  40122. * Updates the global position of the camera by moving the camera's container
  40123. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40124. * @param position The desired global position of the camera
  40125. */
  40126. setPositionOfCameraUsingContainer(position: Vector3): void;
  40127. /**
  40128. * Rotates the xr camera by rotating the camera's container around the camera's position
  40129. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40130. * @param rotation the desired quaternion rotation to apply to the camera
  40131. */
  40132. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40133. /**
  40134. * Checks if the creation options are supported by the xr session
  40135. * @param options creation options
  40136. * @returns true if supported
  40137. */
  40138. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40139. /**
  40140. * Disposes of the experience helper
  40141. */
  40142. dispose(): void;
  40143. }
  40144. }
  40145. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40146. import { Nullable } from "babylonjs/types";
  40147. import { Observable } from "babylonjs/Misc/observable";
  40148. import { IDisposable, Scene } from "babylonjs/scene";
  40149. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40150. /**
  40151. * Button which can be used to enter a different mode of XR
  40152. */
  40153. export class WebXREnterExitUIButton {
  40154. /** button element */
  40155. element: HTMLElement;
  40156. /** XR initialization options for the button */
  40157. initializationOptions: XRSessionCreationOptions;
  40158. /**
  40159. * Creates a WebXREnterExitUIButton
  40160. * @param element button element
  40161. * @param initializationOptions XR initialization options for the button
  40162. */
  40163. constructor(
  40164. /** button element */
  40165. element: HTMLElement,
  40166. /** XR initialization options for the button */
  40167. initializationOptions: XRSessionCreationOptions);
  40168. /**
  40169. * Overwritable function which can be used to update the button's visuals when the state changes
  40170. * @param activeButton the current active button in the UI
  40171. */
  40172. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40173. }
  40174. /**
  40175. * Options to create the webXR UI
  40176. */
  40177. export class WebXREnterExitUIOptions {
  40178. /**
  40179. * Context to enter xr with
  40180. */
  40181. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40182. /**
  40183. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40184. */
  40185. customButtons?: Array<WebXREnterExitUIButton>;
  40186. }
  40187. /**
  40188. * UI to allow the user to enter/exit XR mode
  40189. */
  40190. export class WebXREnterExitUI implements IDisposable {
  40191. private scene;
  40192. private _overlay;
  40193. private _buttons;
  40194. private _activeButton;
  40195. /**
  40196. * Fired every time the active button is changed.
  40197. *
  40198. * When xr is entered via a button that launches xr that button will be the callback parameter
  40199. *
  40200. * When exiting xr the callback parameter will be null)
  40201. */
  40202. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40203. /**
  40204. * Creates UI to allow the user to enter/exit XR mode
  40205. * @param scene the scene to add the ui to
  40206. * @param helper the xr experience helper to enter/exit xr with
  40207. * @param options options to configure the UI
  40208. * @returns the created ui
  40209. */
  40210. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40211. private constructor();
  40212. private _updateButtons;
  40213. /**
  40214. * Disposes of the object
  40215. */
  40216. dispose(): void;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/XR/webXRInput" {
  40220. import { IDisposable, Scene } from "babylonjs/scene";
  40221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40222. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40223. /**
  40224. * Represents an XR input
  40225. */
  40226. export class WebXRController {
  40227. /**
  40228. * 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
  40229. */
  40230. grip?: AbstractMesh;
  40231. /**
  40232. * Pointer which can be used to select objects or attach a visible laser to
  40233. */
  40234. pointer: AbstractMesh;
  40235. /**
  40236. * Creates the controller
  40237. * @see https://doc.babylonjs.com/how_to/webxr
  40238. * @param scene the scene which the controller should be associated to
  40239. */
  40240. constructor(scene: Scene);
  40241. /**
  40242. * Disposes of the object
  40243. */
  40244. dispose(): void;
  40245. }
  40246. /**
  40247. * XR input used to track XR inputs such as controllers/rays
  40248. */
  40249. export class WebXRInput implements IDisposable {
  40250. private helper;
  40251. /**
  40252. * XR controllers being tracked
  40253. */
  40254. controllers: Array<WebXRController>;
  40255. private _tmpMatrix;
  40256. private _frameObserver;
  40257. /**
  40258. * Initializes the WebXRInput
  40259. * @param helper experience helper which the input should be created for
  40260. */
  40261. constructor(helper: WebXRExperienceHelper);
  40262. /**
  40263. * Disposes of the object
  40264. */
  40265. dispose(): void;
  40266. }
  40267. }
  40268. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40269. import { Nullable } from "babylonjs/types";
  40270. import { IDisposable } from "babylonjs/scene";
  40271. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40272. /**
  40273. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40274. */
  40275. export class WebXRManagedOutputCanvas implements IDisposable {
  40276. private _canvas;
  40277. /**
  40278. * xrpresent context of the canvas which can be used to display/mirror xr content
  40279. */
  40280. canvasContext: Nullable<WebGLRenderingContext>;
  40281. /**
  40282. * Initializes the canvas to be added/removed upon entering/exiting xr
  40283. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40284. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40285. */
  40286. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40287. /**
  40288. * Disposes of the object
  40289. */
  40290. dispose(): void;
  40291. private _setManagedOutputCanvas;
  40292. private _addCanvas;
  40293. private _removeCanvas;
  40294. }
  40295. }
  40296. declare module "babylonjs/Cameras/XR/index" {
  40297. export * from "babylonjs/Cameras/XR/webXRCamera";
  40298. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40299. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40300. export * from "babylonjs/Cameras/XR/webXRInput";
  40301. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40302. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40303. }
  40304. declare module "babylonjs/Cameras/RigModes/index" {
  40305. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40306. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40307. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40308. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40309. }
  40310. declare module "babylonjs/Cameras/index" {
  40311. export * from "babylonjs/Cameras/Inputs/index";
  40312. export * from "babylonjs/Cameras/cameraInputsManager";
  40313. export * from "babylonjs/Cameras/camera";
  40314. export * from "babylonjs/Cameras/targetCamera";
  40315. export * from "babylonjs/Cameras/freeCamera";
  40316. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40317. export * from "babylonjs/Cameras/touchCamera";
  40318. export * from "babylonjs/Cameras/arcRotateCamera";
  40319. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40320. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40321. export * from "babylonjs/Cameras/flyCamera";
  40322. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40323. export * from "babylonjs/Cameras/followCamera";
  40324. export * from "babylonjs/Cameras/gamepadCamera";
  40325. export * from "babylonjs/Cameras/Stereoscopic/index";
  40326. export * from "babylonjs/Cameras/universalCamera";
  40327. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40328. export * from "babylonjs/Cameras/VR/index";
  40329. export * from "babylonjs/Cameras/XR/index";
  40330. export * from "babylonjs/Cameras/RigModes/index";
  40331. }
  40332. declare module "babylonjs/Collisions/index" {
  40333. export * from "babylonjs/Collisions/collider";
  40334. export * from "babylonjs/Collisions/collisionCoordinator";
  40335. export * from "babylonjs/Collisions/pickingInfo";
  40336. export * from "babylonjs/Collisions/intersectionInfo";
  40337. }
  40338. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40339. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40340. import { Vector3, Plane } from "babylonjs/Maths/math";
  40341. import { Ray } from "babylonjs/Culling/ray";
  40342. /**
  40343. * Contains an array of blocks representing the octree
  40344. */
  40345. export interface IOctreeContainer<T> {
  40346. /**
  40347. * Blocks within the octree
  40348. */
  40349. blocks: Array<OctreeBlock<T>>;
  40350. }
  40351. /**
  40352. * Class used to store a cell in an octree
  40353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40354. */
  40355. export class OctreeBlock<T> {
  40356. /**
  40357. * Gets the content of the current block
  40358. */
  40359. entries: T[];
  40360. /**
  40361. * Gets the list of block children
  40362. */
  40363. blocks: Array<OctreeBlock<T>>;
  40364. private _depth;
  40365. private _maxDepth;
  40366. private _capacity;
  40367. private _minPoint;
  40368. private _maxPoint;
  40369. private _boundingVectors;
  40370. private _creationFunc;
  40371. /**
  40372. * Creates a new block
  40373. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40374. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40375. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40376. * @param depth defines the current depth of this block in the octree
  40377. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40378. * @param creationFunc defines a callback to call when an element is added to the block
  40379. */
  40380. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40381. /**
  40382. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40383. */
  40384. readonly capacity: number;
  40385. /**
  40386. * Gets the minimum vector (in world space) of the block's bounding box
  40387. */
  40388. readonly minPoint: Vector3;
  40389. /**
  40390. * Gets the maximum vector (in world space) of the block's bounding box
  40391. */
  40392. readonly maxPoint: Vector3;
  40393. /**
  40394. * Add a new element to this block
  40395. * @param entry defines the element to add
  40396. */
  40397. addEntry(entry: T): void;
  40398. /**
  40399. * Remove an element from this block
  40400. * @param entry defines the element to remove
  40401. */
  40402. removeEntry(entry: T): void;
  40403. /**
  40404. * Add an array of elements to this block
  40405. * @param entries defines the array of elements to add
  40406. */
  40407. addEntries(entries: T[]): void;
  40408. /**
  40409. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40410. * @param frustumPlanes defines the frustum planes to test
  40411. * @param selection defines the array to store current content if selection is positive
  40412. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40413. */
  40414. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40415. /**
  40416. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40417. * @param sphereCenter defines the bounding sphere center
  40418. * @param sphereRadius defines the bounding sphere radius
  40419. * @param selection defines the array to store current content if selection is positive
  40420. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40421. */
  40422. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40423. /**
  40424. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40425. * @param ray defines the ray to test with
  40426. * @param selection defines the array to store current content if selection is positive
  40427. */
  40428. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40429. /**
  40430. * Subdivide the content into child blocks (this block will then be empty)
  40431. */
  40432. createInnerBlocks(): void;
  40433. /**
  40434. * @hidden
  40435. */
  40436. 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;
  40437. }
  40438. }
  40439. declare module "babylonjs/Culling/Octrees/octree" {
  40440. import { SmartArray } from "babylonjs/Misc/smartArray";
  40441. import { Vector3, Plane } from "babylonjs/Maths/math";
  40442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40444. import { Ray } from "babylonjs/Culling/ray";
  40445. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40446. /**
  40447. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40449. */
  40450. export class Octree<T> {
  40451. /** 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.) */
  40452. maxDepth: number;
  40453. /**
  40454. * Blocks within the octree containing objects
  40455. */
  40456. blocks: Array<OctreeBlock<T>>;
  40457. /**
  40458. * Content stored in the octree
  40459. */
  40460. dynamicContent: T[];
  40461. private _maxBlockCapacity;
  40462. private _selectionContent;
  40463. private _creationFunc;
  40464. /**
  40465. * Creates a octree
  40466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40467. * @param creationFunc function to be used to instatiate the octree
  40468. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40469. * @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.)
  40470. */
  40471. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40472. /** 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.) */
  40473. maxDepth?: number);
  40474. /**
  40475. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40476. * @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);
  40477. * @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);
  40478. * @param entries meshes to be added to the octree blocks
  40479. */
  40480. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40481. /**
  40482. * Adds a mesh to the octree
  40483. * @param entry Mesh to add to the octree
  40484. */
  40485. addMesh(entry: T): void;
  40486. /**
  40487. * Remove an element from the octree
  40488. * @param entry defines the element to remove
  40489. */
  40490. removeMesh(entry: T): void;
  40491. /**
  40492. * Selects an array of meshes within the frustum
  40493. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40494. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40495. * @returns array of meshes within the frustum
  40496. */
  40497. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40498. /**
  40499. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40500. * @param sphereCenter defines the bounding sphere center
  40501. * @param sphereRadius defines the bounding sphere radius
  40502. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40503. * @returns an array of objects that intersect the sphere
  40504. */
  40505. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40506. /**
  40507. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40508. * @param ray defines the ray to test with
  40509. * @returns array of intersected objects
  40510. */
  40511. intersectsRay(ray: Ray): SmartArray<T>;
  40512. /**
  40513. * Adds a mesh into the octree block if it intersects the block
  40514. */
  40515. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40516. /**
  40517. * Adds a submesh into the octree block if it intersects the block
  40518. */
  40519. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40520. }
  40521. }
  40522. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40523. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40524. import { Scene } from "babylonjs/scene";
  40525. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40527. import { Ray } from "babylonjs/Culling/ray";
  40528. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40529. import { Collider } from "babylonjs/Collisions/collider";
  40530. module "babylonjs/scene" {
  40531. interface Scene {
  40532. /**
  40533. * @hidden
  40534. * Backing Filed
  40535. */
  40536. _selectionOctree: Octree<AbstractMesh>;
  40537. /**
  40538. * Gets the octree used to boost mesh selection (picking)
  40539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40540. */
  40541. selectionOctree: Octree<AbstractMesh>;
  40542. /**
  40543. * Creates or updates the octree used to boost selection (picking)
  40544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40545. * @param maxCapacity defines the maximum capacity per leaf
  40546. * @param maxDepth defines the maximum depth of the octree
  40547. * @returns an octree of AbstractMesh
  40548. */
  40549. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40550. }
  40551. }
  40552. module "babylonjs/Meshes/abstractMesh" {
  40553. interface AbstractMesh {
  40554. /**
  40555. * @hidden
  40556. * Backing Field
  40557. */
  40558. _submeshesOctree: Octree<SubMesh>;
  40559. /**
  40560. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40561. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40562. * @param maxCapacity defines the maximum size of each block (64 by default)
  40563. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40564. * @returns the new octree
  40565. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40567. */
  40568. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40569. }
  40570. }
  40571. /**
  40572. * Defines the octree scene component responsible to manage any octrees
  40573. * in a given scene.
  40574. */
  40575. export class OctreeSceneComponent {
  40576. /**
  40577. * The component name helpfull to identify the component in the list of scene components.
  40578. */
  40579. readonly name: string;
  40580. /**
  40581. * The scene the component belongs to.
  40582. */
  40583. scene: Scene;
  40584. /**
  40585. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40586. */
  40587. readonly checksIsEnabled: boolean;
  40588. /**
  40589. * Creates a new instance of the component for the given scene
  40590. * @param scene Defines the scene to register the component in
  40591. */
  40592. constructor(scene: Scene);
  40593. /**
  40594. * Registers the component in a given scene
  40595. */
  40596. register(): void;
  40597. /**
  40598. * Return the list of active meshes
  40599. * @returns the list of active meshes
  40600. */
  40601. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40602. /**
  40603. * Return the list of active sub meshes
  40604. * @param mesh The mesh to get the candidates sub meshes from
  40605. * @returns the list of active sub meshes
  40606. */
  40607. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40608. private _tempRay;
  40609. /**
  40610. * Return the list of sub meshes intersecting with a given local ray
  40611. * @param mesh defines the mesh to find the submesh for
  40612. * @param localRay defines the ray in local space
  40613. * @returns the list of intersecting sub meshes
  40614. */
  40615. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40616. /**
  40617. * Return the list of sub meshes colliding with a collider
  40618. * @param mesh defines the mesh to find the submesh for
  40619. * @param collider defines the collider to evaluate the collision against
  40620. * @returns the list of colliding sub meshes
  40621. */
  40622. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40623. /**
  40624. * Rebuilds the elements related to this component in case of
  40625. * context lost for instance.
  40626. */
  40627. rebuild(): void;
  40628. /**
  40629. * Disposes the component and the associated ressources.
  40630. */
  40631. dispose(): void;
  40632. }
  40633. }
  40634. declare module "babylonjs/Culling/Octrees/index" {
  40635. export * from "babylonjs/Culling/Octrees/octree";
  40636. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40637. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40638. }
  40639. declare module "babylonjs/Culling/index" {
  40640. export * from "babylonjs/Culling/boundingBox";
  40641. export * from "babylonjs/Culling/boundingInfo";
  40642. export * from "babylonjs/Culling/boundingSphere";
  40643. export * from "babylonjs/Culling/Octrees/index";
  40644. export * from "babylonjs/Culling/ray";
  40645. }
  40646. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40647. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40648. import { Nullable } from "babylonjs/types";
  40649. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40650. import { Scene } from "babylonjs/scene";
  40651. /**
  40652. * Class containing static functions to help procedurally build meshes
  40653. */
  40654. export class LinesBuilder {
  40655. /**
  40656. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40657. * * 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
  40658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40659. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40660. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40661. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40662. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40663. * * 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
  40664. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40667. * @param name defines the name of the new line system
  40668. * @param options defines the options used to create the line system
  40669. * @param scene defines the hosting scene
  40670. * @returns a new line system mesh
  40671. */
  40672. static CreateLineSystem(name: string, options: {
  40673. lines: Vector3[][];
  40674. updatable?: boolean;
  40675. instance?: Nullable<LinesMesh>;
  40676. colors?: Nullable<Color4[][]>;
  40677. useVertexAlpha?: boolean;
  40678. }, scene: Nullable<Scene>): LinesMesh;
  40679. /**
  40680. * Creates a line mesh
  40681. * 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
  40682. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40683. * * The parameter `points` is an array successive Vector3
  40684. * * 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
  40685. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40686. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40687. * * When updating an instance, remember that only point positions can change, not the number of points
  40688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40690. * @param name defines the name of the new line system
  40691. * @param options defines the options used to create the line system
  40692. * @param scene defines the hosting scene
  40693. * @returns a new line mesh
  40694. */
  40695. static CreateLines(name: string, options: {
  40696. points: Vector3[];
  40697. updatable?: boolean;
  40698. instance?: Nullable<LinesMesh>;
  40699. colors?: Color4[];
  40700. useVertexAlpha?: boolean;
  40701. }, scene?: Nullable<Scene>): LinesMesh;
  40702. /**
  40703. * Creates a dashed line mesh
  40704. * * 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
  40705. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40706. * * The parameter `points` is an array successive Vector3
  40707. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40708. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40709. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40710. * * 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
  40711. * * When updating an instance, remember that only point positions can change, not the number of points
  40712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40713. * @param name defines the name of the mesh
  40714. * @param options defines the options used to create the mesh
  40715. * @param scene defines the hosting scene
  40716. * @returns the dashed line mesh
  40717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40718. */
  40719. static CreateDashedLines(name: string, options: {
  40720. points: Vector3[];
  40721. dashSize?: number;
  40722. gapSize?: number;
  40723. dashNb?: number;
  40724. updatable?: boolean;
  40725. instance?: LinesMesh;
  40726. }, scene?: Nullable<Scene>): LinesMesh;
  40727. }
  40728. }
  40729. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40730. import { IDisposable, Scene } from "babylonjs/scene";
  40731. import { Nullable } from "babylonjs/types";
  40732. import { Observable } from "babylonjs/Misc/observable";
  40733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40734. /**
  40735. * Renders a layer on top of an existing scene
  40736. */
  40737. export class UtilityLayerRenderer implements IDisposable {
  40738. /** the original scene that will be rendered on top of */
  40739. originalScene: Scene;
  40740. private _pointerCaptures;
  40741. private _lastPointerEvents;
  40742. private static _DefaultUtilityLayer;
  40743. private static _DefaultKeepDepthUtilityLayer;
  40744. /**
  40745. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40746. */
  40747. pickUtilitySceneFirst: boolean;
  40748. /**
  40749. * 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)
  40750. */
  40751. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40752. /**
  40753. * 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)
  40754. */
  40755. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40756. /**
  40757. * The scene that is rendered on top of the original scene
  40758. */
  40759. utilityLayerScene: Scene;
  40760. /**
  40761. * If the utility layer should automatically be rendered on top of existing scene
  40762. */
  40763. shouldRender: boolean;
  40764. /**
  40765. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40766. */
  40767. onlyCheckPointerDownEvents: boolean;
  40768. /**
  40769. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40770. */
  40771. processAllEvents: boolean;
  40772. /**
  40773. * Observable raised when the pointer move from the utility layer scene to the main scene
  40774. */
  40775. onPointerOutObservable: Observable<number>;
  40776. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40777. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40778. private _afterRenderObserver;
  40779. private _sceneDisposeObserver;
  40780. private _originalPointerObserver;
  40781. /**
  40782. * Instantiates a UtilityLayerRenderer
  40783. * @param originalScene the original scene that will be rendered on top of
  40784. * @param handleEvents boolean indicating if the utility layer should handle events
  40785. */
  40786. constructor(
  40787. /** the original scene that will be rendered on top of */
  40788. originalScene: Scene, handleEvents?: boolean);
  40789. private _notifyObservers;
  40790. /**
  40791. * Renders the utility layers scene on top of the original scene
  40792. */
  40793. render(): void;
  40794. /**
  40795. * Disposes of the renderer
  40796. */
  40797. dispose(): void;
  40798. private _updateCamera;
  40799. }
  40800. }
  40801. declare module "babylonjs/Gizmos/gizmo" {
  40802. import { Nullable } from "babylonjs/types";
  40803. import { IDisposable } from "babylonjs/scene";
  40804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40805. import { Mesh } from "babylonjs/Meshes/mesh";
  40806. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40807. /**
  40808. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40809. */
  40810. export class Gizmo implements IDisposable {
  40811. /** The utility layer the gizmo will be added to */
  40812. gizmoLayer: UtilityLayerRenderer;
  40813. /**
  40814. * The root mesh of the gizmo
  40815. */
  40816. _rootMesh: Mesh;
  40817. private _attachedMesh;
  40818. /**
  40819. * Ratio for the scale of the gizmo (Default: 1)
  40820. */
  40821. scaleRatio: number;
  40822. private _tmpMatrix;
  40823. /**
  40824. * If a custom mesh has been set (Default: false)
  40825. */
  40826. protected _customMeshSet: boolean;
  40827. /**
  40828. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40829. * * When set, interactions will be enabled
  40830. */
  40831. attachedMesh: Nullable<AbstractMesh>;
  40832. /**
  40833. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40834. * @param mesh The mesh to replace the default mesh of the gizmo
  40835. */
  40836. setCustomMesh(mesh: Mesh): void;
  40837. /**
  40838. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40839. */
  40840. updateGizmoRotationToMatchAttachedMesh: boolean;
  40841. /**
  40842. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40843. */
  40844. updateGizmoPositionToMatchAttachedMesh: boolean;
  40845. /**
  40846. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40847. */
  40848. protected _updateScale: boolean;
  40849. protected _interactionsEnabled: boolean;
  40850. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40851. private _beforeRenderObserver;
  40852. /**
  40853. * Creates a gizmo
  40854. * @param gizmoLayer The utility layer the gizmo will be added to
  40855. */
  40856. constructor(
  40857. /** The utility layer the gizmo will be added to */
  40858. gizmoLayer?: UtilityLayerRenderer);
  40859. private _tempVector;
  40860. /**
  40861. * @hidden
  40862. * Updates the gizmo to match the attached mesh's position/rotation
  40863. */
  40864. protected _update(): void;
  40865. /**
  40866. * Disposes of the gizmo
  40867. */
  40868. dispose(): void;
  40869. }
  40870. }
  40871. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40872. import { Observable } from "babylonjs/Misc/observable";
  40873. import { Nullable } from "babylonjs/types";
  40874. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40875. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40877. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40878. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40879. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40880. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40881. import { Scene } from "babylonjs/scene";
  40882. /**
  40883. * Single axis drag gizmo
  40884. */
  40885. export class AxisDragGizmo extends Gizmo {
  40886. /**
  40887. * Drag behavior responsible for the gizmos dragging interactions
  40888. */
  40889. dragBehavior: PointerDragBehavior;
  40890. private _pointerObserver;
  40891. /**
  40892. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40893. */
  40894. snapDistance: number;
  40895. /**
  40896. * Event that fires each time the gizmo snaps to a new location.
  40897. * * snapDistance is the the change in distance
  40898. */
  40899. onSnapObservable: Observable<{
  40900. snapDistance: number;
  40901. }>;
  40902. /** @hidden */
  40903. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40904. /** @hidden */
  40905. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40906. /**
  40907. * Creates an AxisDragGizmo
  40908. * @param gizmoLayer The utility layer the gizmo will be added to
  40909. * @param dragAxis The axis which the gizmo will be able to drag on
  40910. * @param color The color of the gizmo
  40911. */
  40912. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40913. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40914. /**
  40915. * Disposes of the gizmo
  40916. */
  40917. dispose(): void;
  40918. }
  40919. }
  40920. declare module "babylonjs/Debug/axesViewer" {
  40921. import { Vector3 } from "babylonjs/Maths/math";
  40922. import { Nullable } from "babylonjs/types";
  40923. import { Scene } from "babylonjs/scene";
  40924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40925. /**
  40926. * The Axes viewer will show 3 axes in a specific point in space
  40927. */
  40928. export class AxesViewer {
  40929. private _xAxis;
  40930. private _yAxis;
  40931. private _zAxis;
  40932. private _scaleLinesFactor;
  40933. private _instanced;
  40934. /**
  40935. * Gets the hosting scene
  40936. */
  40937. scene: Scene;
  40938. /**
  40939. * Gets or sets a number used to scale line length
  40940. */
  40941. scaleLines: number;
  40942. /** Gets the node hierarchy used to render x-axis */
  40943. readonly xAxis: TransformNode;
  40944. /** Gets the node hierarchy used to render y-axis */
  40945. readonly yAxis: TransformNode;
  40946. /** Gets the node hierarchy used to render z-axis */
  40947. readonly zAxis: TransformNode;
  40948. /**
  40949. * Creates a new AxesViewer
  40950. * @param scene defines the hosting scene
  40951. * @param scaleLines defines a number used to scale line length (1 by default)
  40952. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40953. * @param xAxis defines the node hierarchy used to render the x-axis
  40954. * @param yAxis defines the node hierarchy used to render the y-axis
  40955. * @param zAxis defines the node hierarchy used to render the z-axis
  40956. */
  40957. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40958. /**
  40959. * Force the viewer to update
  40960. * @param position defines the position of the viewer
  40961. * @param xaxis defines the x axis of the viewer
  40962. * @param yaxis defines the y axis of the viewer
  40963. * @param zaxis defines the z axis of the viewer
  40964. */
  40965. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40966. /**
  40967. * Creates an instance of this axes viewer.
  40968. * @returns a new axes viewer with instanced meshes
  40969. */
  40970. createInstance(): AxesViewer;
  40971. /** Releases resources */
  40972. dispose(): void;
  40973. private static _SetRenderingGroupId;
  40974. }
  40975. }
  40976. declare module "babylonjs/Debug/boneAxesViewer" {
  40977. import { Nullable } from "babylonjs/types";
  40978. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40979. import { Vector3 } from "babylonjs/Maths/math";
  40980. import { Mesh } from "babylonjs/Meshes/mesh";
  40981. import { Bone } from "babylonjs/Bones/bone";
  40982. import { Scene } from "babylonjs/scene";
  40983. /**
  40984. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40985. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40986. */
  40987. export class BoneAxesViewer extends AxesViewer {
  40988. /**
  40989. * Gets or sets the target mesh where to display the axes viewer
  40990. */
  40991. mesh: Nullable<Mesh>;
  40992. /**
  40993. * Gets or sets the target bone where to display the axes viewer
  40994. */
  40995. bone: Nullable<Bone>;
  40996. /** Gets current position */
  40997. pos: Vector3;
  40998. /** Gets direction of X axis */
  40999. xaxis: Vector3;
  41000. /** Gets direction of Y axis */
  41001. yaxis: Vector3;
  41002. /** Gets direction of Z axis */
  41003. zaxis: Vector3;
  41004. /**
  41005. * Creates a new BoneAxesViewer
  41006. * @param scene defines the hosting scene
  41007. * @param bone defines the target bone
  41008. * @param mesh defines the target mesh
  41009. * @param scaleLines defines a scaling factor for line length (1 by default)
  41010. */
  41011. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41012. /**
  41013. * Force the viewer to update
  41014. */
  41015. update(): void;
  41016. /** Releases resources */
  41017. dispose(): void;
  41018. }
  41019. }
  41020. declare module "babylonjs/Debug/debugLayer" {
  41021. import { Observable } from "babylonjs/Misc/observable";
  41022. import { Scene } from "babylonjs/scene";
  41023. /**
  41024. * Interface used to define scene explorer extensibility option
  41025. */
  41026. export interface IExplorerExtensibilityOption {
  41027. /**
  41028. * Define the option label
  41029. */
  41030. label: string;
  41031. /**
  41032. * Defines the action to execute on click
  41033. */
  41034. action: (entity: any) => void;
  41035. }
  41036. /**
  41037. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41038. */
  41039. export interface IExplorerExtensibilityGroup {
  41040. /**
  41041. * Defines a predicate to test if a given type mut be extended
  41042. */
  41043. predicate: (entity: any) => boolean;
  41044. /**
  41045. * Gets the list of options added to a type
  41046. */
  41047. entries: IExplorerExtensibilityOption[];
  41048. }
  41049. /**
  41050. * Interface used to define the options to use to create the Inspector
  41051. */
  41052. export interface IInspectorOptions {
  41053. /**
  41054. * Display in overlay mode (default: false)
  41055. */
  41056. overlay?: boolean;
  41057. /**
  41058. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41059. */
  41060. globalRoot?: HTMLElement;
  41061. /**
  41062. * Display the Scene explorer
  41063. */
  41064. showExplorer?: boolean;
  41065. /**
  41066. * Display the property inspector
  41067. */
  41068. showInspector?: boolean;
  41069. /**
  41070. * Display in embed mode (both panes on the right)
  41071. */
  41072. embedMode?: boolean;
  41073. /**
  41074. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41075. */
  41076. handleResize?: boolean;
  41077. /**
  41078. * Allow the panes to popup (default: true)
  41079. */
  41080. enablePopup?: boolean;
  41081. /**
  41082. * Allow the panes to be closed by users (default: true)
  41083. */
  41084. enableClose?: boolean;
  41085. /**
  41086. * Optional list of extensibility entries
  41087. */
  41088. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41089. /**
  41090. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41091. */
  41092. inspectorURL?: string;
  41093. }
  41094. module "babylonjs/scene" {
  41095. interface Scene {
  41096. /**
  41097. * @hidden
  41098. * Backing field
  41099. */
  41100. _debugLayer: DebugLayer;
  41101. /**
  41102. * Gets the debug layer (aka Inspector) associated with the scene
  41103. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41104. */
  41105. debugLayer: DebugLayer;
  41106. }
  41107. }
  41108. /**
  41109. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41110. * what is happening in your scene
  41111. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41112. */
  41113. export class DebugLayer {
  41114. /**
  41115. * Define the url to get the inspector script from.
  41116. * By default it uses the babylonjs CDN.
  41117. * @ignoreNaming
  41118. */
  41119. static InspectorURL: string;
  41120. private _scene;
  41121. private BJSINSPECTOR;
  41122. /**
  41123. * Observable triggered when a property is changed through the inspector.
  41124. */
  41125. onPropertyChangedObservable: Observable<{
  41126. object: any;
  41127. property: string;
  41128. value: any;
  41129. initialValue: any;
  41130. }>;
  41131. /**
  41132. * Instantiates a new debug layer.
  41133. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41134. * what is happening in your scene
  41135. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41136. * @param scene Defines the scene to inspect
  41137. */
  41138. constructor(scene: Scene);
  41139. /** Creates the inspector window. */
  41140. private _createInspector;
  41141. /**
  41142. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41143. * @param entity defines the entity to select
  41144. * @param lineContainerTitle defines the specific block to highlight
  41145. */
  41146. select(entity: any, lineContainerTitle?: string): void;
  41147. /** Get the inspector from bundle or global */
  41148. private _getGlobalInspector;
  41149. /**
  41150. * Get if the inspector is visible or not.
  41151. * @returns true if visible otherwise, false
  41152. */
  41153. isVisible(): boolean;
  41154. /**
  41155. * Hide the inspector and close its window.
  41156. */
  41157. hide(): void;
  41158. /**
  41159. * Launch the debugLayer.
  41160. * @param config Define the configuration of the inspector
  41161. * @return a promise fulfilled when the debug layer is visible
  41162. */
  41163. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41164. }
  41165. }
  41166. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41167. import { Nullable } from "babylonjs/types";
  41168. import { Scene } from "babylonjs/scene";
  41169. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41170. import { Mesh } from "babylonjs/Meshes/mesh";
  41171. /**
  41172. * Class containing static functions to help procedurally build meshes
  41173. */
  41174. export class BoxBuilder {
  41175. /**
  41176. * Creates a box mesh
  41177. * * The parameter `size` sets the size (float) of each box side (default 1)
  41178. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41179. * * 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)
  41180. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41184. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41185. * @param name defines the name of the mesh
  41186. * @param options defines the options used to create the mesh
  41187. * @param scene defines the hosting scene
  41188. * @returns the box mesh
  41189. */
  41190. static CreateBox(name: string, options: {
  41191. size?: number;
  41192. width?: number;
  41193. height?: number;
  41194. depth?: number;
  41195. faceUV?: Vector4[];
  41196. faceColors?: Color4[];
  41197. sideOrientation?: number;
  41198. frontUVs?: Vector4;
  41199. backUVs?: Vector4;
  41200. updatable?: boolean;
  41201. }, scene?: Nullable<Scene>): Mesh;
  41202. }
  41203. }
  41204. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41205. import { Vector4 } from "babylonjs/Maths/math";
  41206. import { Mesh } from "babylonjs/Meshes/mesh";
  41207. /**
  41208. * Class containing static functions to help procedurally build meshes
  41209. */
  41210. export class SphereBuilder {
  41211. /**
  41212. * Creates a sphere mesh
  41213. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41214. * * 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`)
  41215. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41216. * * 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
  41217. * * 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)
  41218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41221. * @param name defines the name of the mesh
  41222. * @param options defines the options used to create the mesh
  41223. * @param scene defines the hosting scene
  41224. * @returns the sphere mesh
  41225. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41226. */
  41227. static CreateSphere(name: string, options: {
  41228. segments?: number;
  41229. diameter?: number;
  41230. diameterX?: number;
  41231. diameterY?: number;
  41232. diameterZ?: number;
  41233. arc?: number;
  41234. slice?: number;
  41235. sideOrientation?: number;
  41236. frontUVs?: Vector4;
  41237. backUVs?: Vector4;
  41238. updatable?: boolean;
  41239. }, scene: any): Mesh;
  41240. }
  41241. }
  41242. declare module "babylonjs/Debug/physicsViewer" {
  41243. import { Nullable } from "babylonjs/types";
  41244. import { Scene } from "babylonjs/scene";
  41245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41246. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41247. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41248. /**
  41249. * Used to show the physics impostor around the specific mesh
  41250. */
  41251. export class PhysicsViewer {
  41252. /** @hidden */
  41253. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41254. /** @hidden */
  41255. protected _meshes: Array<Nullable<AbstractMesh>>;
  41256. /** @hidden */
  41257. protected _scene: Nullable<Scene>;
  41258. /** @hidden */
  41259. protected _numMeshes: number;
  41260. /** @hidden */
  41261. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41262. private _renderFunction;
  41263. private _utilityLayer;
  41264. private _debugBoxMesh;
  41265. private _debugSphereMesh;
  41266. private _debugMaterial;
  41267. /**
  41268. * Creates a new PhysicsViewer
  41269. * @param scene defines the hosting scene
  41270. */
  41271. constructor(scene: Scene);
  41272. /** @hidden */
  41273. protected _updateDebugMeshes(): void;
  41274. /**
  41275. * Renders a specified physic impostor
  41276. * @param impostor defines the impostor to render
  41277. * @returns the new debug mesh used to render the impostor
  41278. */
  41279. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41280. /**
  41281. * Hides a specified physic impostor
  41282. * @param impostor defines the impostor to hide
  41283. */
  41284. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41285. private _getDebugMaterial;
  41286. private _getDebugBoxMesh;
  41287. private _getDebugSphereMesh;
  41288. private _getDebugMesh;
  41289. /** Releases all resources */
  41290. dispose(): void;
  41291. }
  41292. }
  41293. declare module "babylonjs/Debug/rayHelper" {
  41294. import { Nullable } from "babylonjs/types";
  41295. import { Ray } from "babylonjs/Culling/ray";
  41296. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41297. import { Scene } from "babylonjs/scene";
  41298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41299. import "babylonjs/Meshes/Builders/linesBuilder";
  41300. /**
  41301. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41302. * in order to better appreciate the issue one might have.
  41303. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41304. */
  41305. export class RayHelper {
  41306. /**
  41307. * Defines the ray we are currently tryin to visualize.
  41308. */
  41309. ray: Nullable<Ray>;
  41310. private _renderPoints;
  41311. private _renderLine;
  41312. private _renderFunction;
  41313. private _scene;
  41314. private _updateToMeshFunction;
  41315. private _attachedToMesh;
  41316. private _meshSpaceDirection;
  41317. private _meshSpaceOrigin;
  41318. /**
  41319. * Helper function to create a colored helper in a scene in one line.
  41320. * @param ray Defines the ray we are currently tryin to visualize
  41321. * @param scene Defines the scene the ray is used in
  41322. * @param color Defines the color we want to see the ray in
  41323. * @returns The newly created ray helper.
  41324. */
  41325. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41326. /**
  41327. * Instantiate a new ray helper.
  41328. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41329. * in order to better appreciate the issue one might have.
  41330. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41331. * @param ray Defines the ray we are currently tryin to visualize
  41332. */
  41333. constructor(ray: Ray);
  41334. /**
  41335. * Shows the ray we are willing to debug.
  41336. * @param scene Defines the scene the ray needs to be rendered in
  41337. * @param color Defines the color the ray needs to be rendered in
  41338. */
  41339. show(scene: Scene, color?: Color3): void;
  41340. /**
  41341. * Hides the ray we are debugging.
  41342. */
  41343. hide(): void;
  41344. private _render;
  41345. /**
  41346. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41347. * @param mesh Defines the mesh we want the helper attached to
  41348. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41349. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41350. * @param length Defines the length of the ray
  41351. */
  41352. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41353. /**
  41354. * Detach the ray helper from the mesh it has previously been attached to.
  41355. */
  41356. detachFromMesh(): void;
  41357. private _updateToMesh;
  41358. /**
  41359. * Dispose the helper and release its associated resources.
  41360. */
  41361. dispose(): void;
  41362. }
  41363. }
  41364. declare module "babylonjs/Debug/skeletonViewer" {
  41365. import { Color3 } from "babylonjs/Maths/math";
  41366. import { Scene } from "babylonjs/scene";
  41367. import { Nullable } from "babylonjs/types";
  41368. import { Skeleton } from "babylonjs/Bones/skeleton";
  41369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41370. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41371. /**
  41372. * Class used to render a debug view of a given skeleton
  41373. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41374. */
  41375. export class SkeletonViewer {
  41376. /** defines the skeleton to render */
  41377. skeleton: Skeleton;
  41378. /** defines the mesh attached to the skeleton */
  41379. mesh: AbstractMesh;
  41380. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41381. autoUpdateBonesMatrices: boolean;
  41382. /** defines the rendering group id to use with the viewer */
  41383. renderingGroupId: number;
  41384. /** Gets or sets the color used to render the skeleton */
  41385. color: Color3;
  41386. private _scene;
  41387. private _debugLines;
  41388. private _debugMesh;
  41389. private _isEnabled;
  41390. private _renderFunction;
  41391. private _utilityLayer;
  41392. /**
  41393. * Returns the mesh used to render the bones
  41394. */
  41395. readonly debugMesh: Nullable<LinesMesh>;
  41396. /**
  41397. * Creates a new SkeletonViewer
  41398. * @param skeleton defines the skeleton to render
  41399. * @param mesh defines the mesh attached to the skeleton
  41400. * @param scene defines the hosting scene
  41401. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41402. * @param renderingGroupId defines the rendering group id to use with the viewer
  41403. */
  41404. constructor(
  41405. /** defines the skeleton to render */
  41406. skeleton: Skeleton,
  41407. /** defines the mesh attached to the skeleton */
  41408. mesh: AbstractMesh, scene: Scene,
  41409. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41410. autoUpdateBonesMatrices?: boolean,
  41411. /** defines the rendering group id to use with the viewer */
  41412. renderingGroupId?: number);
  41413. /** Gets or sets a boolean indicating if the viewer is enabled */
  41414. isEnabled: boolean;
  41415. private _getBonePosition;
  41416. private _getLinesForBonesWithLength;
  41417. private _getLinesForBonesNoLength;
  41418. /** Update the viewer to sync with current skeleton state */
  41419. update(): void;
  41420. /** Release associated resources */
  41421. dispose(): void;
  41422. }
  41423. }
  41424. declare module "babylonjs/Debug/index" {
  41425. export * from "babylonjs/Debug/axesViewer";
  41426. export * from "babylonjs/Debug/boneAxesViewer";
  41427. export * from "babylonjs/Debug/debugLayer";
  41428. export * from "babylonjs/Debug/physicsViewer";
  41429. export * from "babylonjs/Debug/rayHelper";
  41430. export * from "babylonjs/Debug/skeletonViewer";
  41431. }
  41432. declare module "babylonjs/Engines/nullEngine" {
  41433. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41434. import { Scene } from "babylonjs/scene";
  41435. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41436. import { Engine } from "babylonjs/Engines/engine";
  41437. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41438. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41440. import { Effect } from "babylonjs/Materials/effect";
  41441. /**
  41442. * Options to create the null engine
  41443. */
  41444. export class NullEngineOptions {
  41445. /**
  41446. * Render width (Default: 512)
  41447. */
  41448. renderWidth: number;
  41449. /**
  41450. * Render height (Default: 256)
  41451. */
  41452. renderHeight: number;
  41453. /**
  41454. * Texture size (Default: 512)
  41455. */
  41456. textureSize: number;
  41457. /**
  41458. * If delta time between frames should be constant
  41459. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41460. */
  41461. deterministicLockstep: boolean;
  41462. /**
  41463. * Maximum about of steps between frames (Default: 4)
  41464. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41465. */
  41466. lockstepMaxSteps: number;
  41467. }
  41468. /**
  41469. * The null engine class provides support for headless version of babylon.js.
  41470. * This can be used in server side scenario or for testing purposes
  41471. */
  41472. export class NullEngine extends Engine {
  41473. private _options;
  41474. /**
  41475. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41476. */
  41477. isDeterministicLockStep(): boolean;
  41478. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41479. getLockstepMaxSteps(): number;
  41480. /**
  41481. * Sets hardware scaling, used to save performance if needed
  41482. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41483. */
  41484. getHardwareScalingLevel(): number;
  41485. constructor(options?: NullEngineOptions);
  41486. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41487. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41488. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41489. getRenderWidth(useScreen?: boolean): number;
  41490. getRenderHeight(useScreen?: boolean): number;
  41491. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41492. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41493. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41494. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41495. bindSamplers(effect: Effect): void;
  41496. enableEffect(effect: Effect): void;
  41497. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41498. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41499. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41500. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41501. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41502. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41503. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41504. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41505. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41506. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41507. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41508. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41509. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41510. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41511. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41512. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41513. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41514. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41515. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41516. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41517. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41518. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41519. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41520. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41521. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41522. bindBuffers(vertexBuffers: {
  41523. [key: string]: VertexBuffer;
  41524. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41525. wipeCaches(bruteForce?: boolean): void;
  41526. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41527. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41528. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41529. /** @hidden */
  41530. _createTexture(): WebGLTexture;
  41531. /** @hidden */
  41532. _releaseTexture(texture: InternalTexture): void;
  41533. 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;
  41534. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41535. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41536. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41537. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41538. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41539. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41540. areAllEffectsReady(): boolean;
  41541. /**
  41542. * @hidden
  41543. * Get the current error code of the webGL context
  41544. * @returns the error code
  41545. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41546. */
  41547. getError(): number;
  41548. /** @hidden */
  41549. _getUnpackAlignement(): number;
  41550. /** @hidden */
  41551. _unpackFlipY(value: boolean): void;
  41552. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41553. /**
  41554. * Updates a dynamic vertex buffer.
  41555. * @param vertexBuffer the vertex buffer to update
  41556. * @param data the data used to update the vertex buffer
  41557. * @param byteOffset the byte offset of the data (optional)
  41558. * @param byteLength the byte length of the data (optional)
  41559. */
  41560. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41561. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41562. /** @hidden */
  41563. _bindTexture(channel: number, texture: InternalTexture): void;
  41564. /** @hidden */
  41565. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41566. releaseEffects(): void;
  41567. displayLoadingUI(): void;
  41568. hideLoadingUI(): void;
  41569. /** @hidden */
  41570. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41571. /** @hidden */
  41572. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41573. /** @hidden */
  41574. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41575. /** @hidden */
  41576. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41577. }
  41578. }
  41579. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41580. import { Nullable, int } from "babylonjs/types";
  41581. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41582. /** @hidden */
  41583. export class _OcclusionDataStorage {
  41584. /** @hidden */
  41585. occlusionInternalRetryCounter: number;
  41586. /** @hidden */
  41587. isOcclusionQueryInProgress: boolean;
  41588. /** @hidden */
  41589. isOccluded: boolean;
  41590. /** @hidden */
  41591. occlusionRetryCount: number;
  41592. /** @hidden */
  41593. occlusionType: number;
  41594. /** @hidden */
  41595. occlusionQueryAlgorithmType: number;
  41596. }
  41597. module "babylonjs/Engines/engine" {
  41598. interface Engine {
  41599. /**
  41600. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41601. * @return the new query
  41602. */
  41603. createQuery(): WebGLQuery;
  41604. /**
  41605. * Delete and release a webGL query
  41606. * @param query defines the query to delete
  41607. * @return the current engine
  41608. */
  41609. deleteQuery(query: WebGLQuery): Engine;
  41610. /**
  41611. * Check if a given query has resolved and got its value
  41612. * @param query defines the query to check
  41613. * @returns true if the query got its value
  41614. */
  41615. isQueryResultAvailable(query: WebGLQuery): boolean;
  41616. /**
  41617. * Gets the value of a given query
  41618. * @param query defines the query to check
  41619. * @returns the value of the query
  41620. */
  41621. getQueryResult(query: WebGLQuery): number;
  41622. /**
  41623. * Initiates an occlusion query
  41624. * @param algorithmType defines the algorithm to use
  41625. * @param query defines the query to use
  41626. * @returns the current engine
  41627. * @see http://doc.babylonjs.com/features/occlusionquery
  41628. */
  41629. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41630. /**
  41631. * Ends an occlusion query
  41632. * @see http://doc.babylonjs.com/features/occlusionquery
  41633. * @param algorithmType defines the algorithm to use
  41634. * @returns the current engine
  41635. */
  41636. endOcclusionQuery(algorithmType: number): Engine;
  41637. /**
  41638. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41639. * Please note that only one query can be issued at a time
  41640. * @returns a time token used to track the time span
  41641. */
  41642. startTimeQuery(): Nullable<_TimeToken>;
  41643. /**
  41644. * Ends a time query
  41645. * @param token defines the token used to measure the time span
  41646. * @returns the time spent (in ns)
  41647. */
  41648. endTimeQuery(token: _TimeToken): int;
  41649. /** @hidden */
  41650. _currentNonTimestampToken: Nullable<_TimeToken>;
  41651. /** @hidden */
  41652. _createTimeQuery(): WebGLQuery;
  41653. /** @hidden */
  41654. _deleteTimeQuery(query: WebGLQuery): void;
  41655. /** @hidden */
  41656. _getGlAlgorithmType(algorithmType: number): number;
  41657. /** @hidden */
  41658. _getTimeQueryResult(query: WebGLQuery): any;
  41659. /** @hidden */
  41660. _getTimeQueryAvailability(query: WebGLQuery): any;
  41661. }
  41662. }
  41663. module "babylonjs/Meshes/abstractMesh" {
  41664. interface AbstractMesh {
  41665. /**
  41666. * Backing filed
  41667. * @hidden
  41668. */
  41669. __occlusionDataStorage: _OcclusionDataStorage;
  41670. /**
  41671. * Access property
  41672. * @hidden
  41673. */
  41674. _occlusionDataStorage: _OcclusionDataStorage;
  41675. /**
  41676. * 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.
  41677. * The default value is -1 which means don't break the query and wait till the result
  41678. * @see http://doc.babylonjs.com/features/occlusionquery
  41679. */
  41680. occlusionRetryCount: number;
  41681. /**
  41682. * 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:
  41683. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41684. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41685. * * 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.
  41686. * @see http://doc.babylonjs.com/features/occlusionquery
  41687. */
  41688. occlusionType: number;
  41689. /**
  41690. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41691. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41692. * * 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.
  41693. * @see http://doc.babylonjs.com/features/occlusionquery
  41694. */
  41695. occlusionQueryAlgorithmType: number;
  41696. /**
  41697. * 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
  41698. * @see http://doc.babylonjs.com/features/occlusionquery
  41699. */
  41700. isOccluded: boolean;
  41701. /**
  41702. * Flag to check the progress status of the query
  41703. * @see http://doc.babylonjs.com/features/occlusionquery
  41704. */
  41705. isOcclusionQueryInProgress: boolean;
  41706. }
  41707. }
  41708. }
  41709. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41710. import { Nullable } from "babylonjs/types";
  41711. /** @hidden */
  41712. export var _forceTransformFeedbackToBundle: boolean;
  41713. module "babylonjs/Engines/engine" {
  41714. interface Engine {
  41715. /**
  41716. * Creates a webGL transform feedback object
  41717. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41718. * @returns the webGL transform feedback object
  41719. */
  41720. createTransformFeedback(): WebGLTransformFeedback;
  41721. /**
  41722. * Delete a webGL transform feedback object
  41723. * @param value defines the webGL transform feedback object to delete
  41724. */
  41725. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41726. /**
  41727. * Bind a webGL transform feedback object to the webgl context
  41728. * @param value defines the webGL transform feedback object to bind
  41729. */
  41730. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41731. /**
  41732. * Begins a transform feedback operation
  41733. * @param usePoints defines if points or triangles must be used
  41734. */
  41735. beginTransformFeedback(usePoints: boolean): void;
  41736. /**
  41737. * Ends a transform feedback operation
  41738. */
  41739. endTransformFeedback(): void;
  41740. /**
  41741. * Specify the varyings to use with transform feedback
  41742. * @param program defines the associated webGL program
  41743. * @param value defines the list of strings representing the varying names
  41744. */
  41745. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41746. /**
  41747. * Bind a webGL buffer for a transform feedback operation
  41748. * @param value defines the webGL buffer to bind
  41749. */
  41750. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41751. }
  41752. }
  41753. }
  41754. declare module "babylonjs/Engines/Extensions/index" {
  41755. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41756. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41757. }
  41758. declare module "babylonjs/Engines/index" {
  41759. export * from "babylonjs/Engines/constants";
  41760. export * from "babylonjs/Engines/engine";
  41761. export * from "babylonjs/Engines/engineStore";
  41762. export * from "babylonjs/Engines/nullEngine";
  41763. export * from "babylonjs/Engines/Extensions/index";
  41764. }
  41765. declare module "babylonjs/Events/clipboardEvents" {
  41766. /**
  41767. * Gather the list of clipboard event types as constants.
  41768. */
  41769. export class ClipboardEventTypes {
  41770. /**
  41771. * The clipboard event is fired when a copy command is active (pressed).
  41772. */
  41773. static readonly COPY: number;
  41774. /**
  41775. * The clipboard event is fired when a cut command is active (pressed).
  41776. */
  41777. static readonly CUT: number;
  41778. /**
  41779. * The clipboard event is fired when a paste command is active (pressed).
  41780. */
  41781. static readonly PASTE: number;
  41782. }
  41783. /**
  41784. * This class is used to store clipboard related info for the onClipboardObservable event.
  41785. */
  41786. export class ClipboardInfo {
  41787. /**
  41788. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41789. */
  41790. type: number;
  41791. /**
  41792. * Defines the related dom event
  41793. */
  41794. event: ClipboardEvent;
  41795. /**
  41796. *Creates an instance of ClipboardInfo.
  41797. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41798. * @param event Defines the related dom event
  41799. */
  41800. constructor(
  41801. /**
  41802. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41803. */
  41804. type: number,
  41805. /**
  41806. * Defines the related dom event
  41807. */
  41808. event: ClipboardEvent);
  41809. /**
  41810. * Get the clipboard event's type from the keycode.
  41811. * @param keyCode Defines the keyCode for the current keyboard event.
  41812. * @return {number}
  41813. */
  41814. static GetTypeFromCharacter(keyCode: number): number;
  41815. }
  41816. }
  41817. declare module "babylonjs/Events/index" {
  41818. export * from "babylonjs/Events/keyboardEvents";
  41819. export * from "babylonjs/Events/pointerEvents";
  41820. export * from "babylonjs/Events/clipboardEvents";
  41821. }
  41822. declare module "babylonjs/Loading/sceneLoader" {
  41823. import { Observable } from "babylonjs/Misc/observable";
  41824. import { Nullable } from "babylonjs/types";
  41825. import { Scene } from "babylonjs/scene";
  41826. import { Engine } from "babylonjs/Engines/engine";
  41827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41828. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41829. import { AssetContainer } from "babylonjs/assetContainer";
  41830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41831. import { Skeleton } from "babylonjs/Bones/skeleton";
  41832. /**
  41833. * Class used to represent data loading progression
  41834. */
  41835. export class SceneLoaderProgressEvent {
  41836. /** defines if data length to load can be evaluated */
  41837. readonly lengthComputable: boolean;
  41838. /** defines the loaded data length */
  41839. readonly loaded: number;
  41840. /** defines the data length to load */
  41841. readonly total: number;
  41842. /**
  41843. * Create a new progress event
  41844. * @param lengthComputable defines if data length to load can be evaluated
  41845. * @param loaded defines the loaded data length
  41846. * @param total defines the data length to load
  41847. */
  41848. constructor(
  41849. /** defines if data length to load can be evaluated */
  41850. lengthComputable: boolean,
  41851. /** defines the loaded data length */
  41852. loaded: number,
  41853. /** defines the data length to load */
  41854. total: number);
  41855. /**
  41856. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41857. * @param event defines the source event
  41858. * @returns a new SceneLoaderProgressEvent
  41859. */
  41860. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41861. }
  41862. /**
  41863. * Interface used by SceneLoader plugins to define supported file extensions
  41864. */
  41865. export interface ISceneLoaderPluginExtensions {
  41866. /**
  41867. * Defines the list of supported extensions
  41868. */
  41869. [extension: string]: {
  41870. isBinary: boolean;
  41871. };
  41872. }
  41873. /**
  41874. * Interface used by SceneLoader plugin factory
  41875. */
  41876. export interface ISceneLoaderPluginFactory {
  41877. /**
  41878. * Defines the name of the factory
  41879. */
  41880. name: string;
  41881. /**
  41882. * Function called to create a new plugin
  41883. * @return the new plugin
  41884. */
  41885. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41886. /**
  41887. * Boolean indicating if the plugin can direct load specific data
  41888. */
  41889. canDirectLoad?: (data: string) => boolean;
  41890. }
  41891. /**
  41892. * Interface used to define a SceneLoader plugin
  41893. */
  41894. export interface ISceneLoaderPlugin {
  41895. /**
  41896. * The friendly name of this plugin.
  41897. */
  41898. name: string;
  41899. /**
  41900. * The file extensions supported by this plugin.
  41901. */
  41902. extensions: string | ISceneLoaderPluginExtensions;
  41903. /**
  41904. * Import meshes into a scene.
  41905. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41906. * @param scene The scene to import into
  41907. * @param data The data to import
  41908. * @param rootUrl The root url for scene and resources
  41909. * @param meshes The meshes array to import into
  41910. * @param particleSystems The particle systems array to import into
  41911. * @param skeletons The skeletons array to import into
  41912. * @param onError The callback when import fails
  41913. * @returns True if successful or false otherwise
  41914. */
  41915. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41916. /**
  41917. * Load into a scene.
  41918. * @param scene The scene to load into
  41919. * @param data The data to import
  41920. * @param rootUrl The root url for scene and resources
  41921. * @param onError The callback when import fails
  41922. * @returns true if successful or false otherwise
  41923. */
  41924. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41925. /**
  41926. * The callback that returns true if the data can be directly loaded.
  41927. */
  41928. canDirectLoad?: (data: string) => boolean;
  41929. /**
  41930. * The callback that allows custom handling of the root url based on the response url.
  41931. */
  41932. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41933. /**
  41934. * Load into an asset container.
  41935. * @param scene The scene to load into
  41936. * @param data The data to import
  41937. * @param rootUrl The root url for scene and resources
  41938. * @param onError The callback when import fails
  41939. * @returns The loaded asset container
  41940. */
  41941. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41942. }
  41943. /**
  41944. * Interface used to define an async SceneLoader plugin
  41945. */
  41946. export interface ISceneLoaderPluginAsync {
  41947. /**
  41948. * The friendly name of this plugin.
  41949. */
  41950. name: string;
  41951. /**
  41952. * The file extensions supported by this plugin.
  41953. */
  41954. extensions: string | ISceneLoaderPluginExtensions;
  41955. /**
  41956. * Import meshes into a scene.
  41957. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41958. * @param scene The scene to import into
  41959. * @param data The data to import
  41960. * @param rootUrl The root url for scene and resources
  41961. * @param onProgress The callback when the load progresses
  41962. * @param fileName Defines the name of the file to load
  41963. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41964. */
  41965. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41966. meshes: AbstractMesh[];
  41967. particleSystems: IParticleSystem[];
  41968. skeletons: Skeleton[];
  41969. animationGroups: AnimationGroup[];
  41970. }>;
  41971. /**
  41972. * Load into a scene.
  41973. * @param scene The scene to load into
  41974. * @param data The data to import
  41975. * @param rootUrl The root url for scene and resources
  41976. * @param onProgress The callback when the load progresses
  41977. * @param fileName Defines the name of the file to load
  41978. * @returns Nothing
  41979. */
  41980. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41981. /**
  41982. * The callback that returns true if the data can be directly loaded.
  41983. */
  41984. canDirectLoad?: (data: string) => boolean;
  41985. /**
  41986. * The callback that allows custom handling of the root url based on the response url.
  41987. */
  41988. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41989. /**
  41990. * Load into an asset container.
  41991. * @param scene The scene to load into
  41992. * @param data The data to import
  41993. * @param rootUrl The root url for scene and resources
  41994. * @param onProgress The callback when the load progresses
  41995. * @param fileName Defines the name of the file to load
  41996. * @returns The loaded asset container
  41997. */
  41998. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41999. }
  42000. /**
  42001. * Class used to load scene from various file formats using registered plugins
  42002. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42003. */
  42004. export class SceneLoader {
  42005. /**
  42006. * No logging while loading
  42007. */
  42008. static readonly NO_LOGGING: number;
  42009. /**
  42010. * Minimal logging while loading
  42011. */
  42012. static readonly MINIMAL_LOGGING: number;
  42013. /**
  42014. * Summary logging while loading
  42015. */
  42016. static readonly SUMMARY_LOGGING: number;
  42017. /**
  42018. * Detailled logging while loading
  42019. */
  42020. static readonly DETAILED_LOGGING: number;
  42021. /**
  42022. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42023. */
  42024. static ForceFullSceneLoadingForIncremental: boolean;
  42025. /**
  42026. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42027. */
  42028. static ShowLoadingScreen: boolean;
  42029. /**
  42030. * Defines the current logging level (while loading the scene)
  42031. * @ignorenaming
  42032. */
  42033. static loggingLevel: number;
  42034. /**
  42035. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42036. */
  42037. static CleanBoneMatrixWeights: boolean;
  42038. /**
  42039. * Event raised when a plugin is used to load a scene
  42040. */
  42041. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42042. private static _registeredPlugins;
  42043. private static _getDefaultPlugin;
  42044. private static _getPluginForExtension;
  42045. private static _getPluginForDirectLoad;
  42046. private static _getPluginForFilename;
  42047. private static _getDirectLoad;
  42048. private static _loadData;
  42049. private static _getFileInfo;
  42050. /**
  42051. * Gets a plugin that can load the given extension
  42052. * @param extension defines the extension to load
  42053. * @returns a plugin or null if none works
  42054. */
  42055. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42056. /**
  42057. * Gets a boolean indicating that the given extension can be loaded
  42058. * @param extension defines the extension to load
  42059. * @returns true if the extension is supported
  42060. */
  42061. static IsPluginForExtensionAvailable(extension: string): boolean;
  42062. /**
  42063. * Adds a new plugin to the list of registered plugins
  42064. * @param plugin defines the plugin to add
  42065. */
  42066. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42067. /**
  42068. * Import meshes into a scene
  42069. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42070. * @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)
  42071. * @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)
  42072. * @param scene the instance of BABYLON.Scene to append to
  42073. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42074. * @param onProgress a callback with a progress event for each file being loaded
  42075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42076. * @param pluginExtension the extension used to determine the plugin
  42077. * @returns The loaded plugin
  42078. */
  42079. 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>;
  42080. /**
  42081. * Import meshes into a scene
  42082. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42083. * @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)
  42084. * @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)
  42085. * @param scene the instance of BABYLON.Scene to append to
  42086. * @param onProgress a callback with a progress event for each file being loaded
  42087. * @param pluginExtension the extension used to determine the plugin
  42088. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42089. */
  42090. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42091. meshes: AbstractMesh[];
  42092. particleSystems: IParticleSystem[];
  42093. skeletons: Skeleton[];
  42094. animationGroups: AnimationGroup[];
  42095. }>;
  42096. /**
  42097. * Load a scene
  42098. * @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)
  42099. * @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)
  42100. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42101. * @param onSuccess a callback with the scene when import succeeds
  42102. * @param onProgress a callback with a progress event for each file being loaded
  42103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42104. * @param pluginExtension the extension used to determine the plugin
  42105. * @returns The loaded plugin
  42106. */
  42107. 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>;
  42108. /**
  42109. * Load a scene
  42110. * @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)
  42111. * @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)
  42112. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42113. * @param onProgress a callback with a progress event for each file being loaded
  42114. * @param pluginExtension the extension used to determine the plugin
  42115. * @returns The loaded scene
  42116. */
  42117. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42118. /**
  42119. * Append a scene
  42120. * @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)
  42121. * @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)
  42122. * @param scene is the instance of BABYLON.Scene to append to
  42123. * @param onSuccess a callback with the scene when import succeeds
  42124. * @param onProgress a callback with a progress event for each file being loaded
  42125. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42126. * @param pluginExtension the extension used to determine the plugin
  42127. * @returns The loaded plugin
  42128. */
  42129. 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>;
  42130. /**
  42131. * Append a scene
  42132. * @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)
  42133. * @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)
  42134. * @param scene is the instance of BABYLON.Scene to append to
  42135. * @param onProgress a callback with a progress event for each file being loaded
  42136. * @param pluginExtension the extension used to determine the plugin
  42137. * @returns The given scene
  42138. */
  42139. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42140. /**
  42141. * Load a scene into an asset container
  42142. * @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)
  42143. * @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)
  42144. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42145. * @param onSuccess a callback with the scene when import succeeds
  42146. * @param onProgress a callback with a progress event for each file being loaded
  42147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42148. * @param pluginExtension the extension used to determine the plugin
  42149. * @returns The loaded plugin
  42150. */
  42151. 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>;
  42152. /**
  42153. * Load a scene into an asset container
  42154. * @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)
  42155. * @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)
  42156. * @param scene is the instance of Scene to append to
  42157. * @param onProgress a callback with a progress event for each file being loaded
  42158. * @param pluginExtension the extension used to determine the plugin
  42159. * @returns The loaded asset container
  42160. */
  42161. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42162. }
  42163. }
  42164. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42165. import { Scene } from "babylonjs/scene";
  42166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42167. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42168. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42169. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42170. /**
  42171. * Google Daydream controller
  42172. */
  42173. export class DaydreamController extends WebVRController {
  42174. /**
  42175. * Base Url for the controller model.
  42176. */
  42177. static MODEL_BASE_URL: string;
  42178. /**
  42179. * File name for the controller model.
  42180. */
  42181. static MODEL_FILENAME: string;
  42182. /**
  42183. * Gamepad Id prefix used to identify Daydream Controller.
  42184. */
  42185. static readonly GAMEPAD_ID_PREFIX: string;
  42186. /**
  42187. * Creates a new DaydreamController from a gamepad
  42188. * @param vrGamepad the gamepad that the controller should be created from
  42189. */
  42190. constructor(vrGamepad: any);
  42191. /**
  42192. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42193. * @param scene scene in which to add meshes
  42194. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42195. */
  42196. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42197. /**
  42198. * Called once for each button that changed state since the last frame
  42199. * @param buttonIdx Which button index changed
  42200. * @param state New state of the button
  42201. * @param changes Which properties on the state changed since last frame
  42202. */
  42203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42204. }
  42205. }
  42206. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42207. import { Scene } from "babylonjs/scene";
  42208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42209. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42210. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42211. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42212. /**
  42213. * Gear VR Controller
  42214. */
  42215. export class GearVRController extends WebVRController {
  42216. /**
  42217. * Base Url for the controller model.
  42218. */
  42219. static MODEL_BASE_URL: string;
  42220. /**
  42221. * File name for the controller model.
  42222. */
  42223. static MODEL_FILENAME: string;
  42224. /**
  42225. * Gamepad Id prefix used to identify this controller.
  42226. */
  42227. static readonly GAMEPAD_ID_PREFIX: string;
  42228. private readonly _buttonIndexToObservableNameMap;
  42229. /**
  42230. * Creates a new GearVRController from a gamepad
  42231. * @param vrGamepad the gamepad that the controller should be created from
  42232. */
  42233. constructor(vrGamepad: any);
  42234. /**
  42235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42236. * @param scene scene in which to add meshes
  42237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42238. */
  42239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42240. /**
  42241. * Called once for each button that changed state since the last frame
  42242. * @param buttonIdx Which button index changed
  42243. * @param state New state of the button
  42244. * @param changes Which properties on the state changed since last frame
  42245. */
  42246. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42247. }
  42248. }
  42249. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42250. import { Scene } from "babylonjs/scene";
  42251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42252. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42253. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42254. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42255. /**
  42256. * Generic Controller
  42257. */
  42258. export class GenericController extends WebVRController {
  42259. /**
  42260. * Base Url for the controller model.
  42261. */
  42262. static readonly MODEL_BASE_URL: string;
  42263. /**
  42264. * File name for the controller model.
  42265. */
  42266. static readonly MODEL_FILENAME: string;
  42267. /**
  42268. * Creates a new GenericController 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. * Called once for each button that changed state since the last frame
  42280. * @param buttonIdx Which button index changed
  42281. * @param state New state of the button
  42282. * @param changes Which properties on the state changed since last frame
  42283. */
  42284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42285. }
  42286. }
  42287. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42288. import { Observable } from "babylonjs/Misc/observable";
  42289. import { Scene } from "babylonjs/scene";
  42290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42291. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42292. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42293. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42294. /**
  42295. * Oculus Touch Controller
  42296. */
  42297. export class OculusTouchController extends WebVRController {
  42298. /**
  42299. * Base Url for the controller model.
  42300. */
  42301. static MODEL_BASE_URL: string;
  42302. /**
  42303. * File name for the left controller model.
  42304. */
  42305. static MODEL_LEFT_FILENAME: string;
  42306. /**
  42307. * File name for the right controller model.
  42308. */
  42309. static MODEL_RIGHT_FILENAME: string;
  42310. /**
  42311. * Fired when the secondary trigger on this controller is modified
  42312. */
  42313. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42314. /**
  42315. * Fired when the thumb rest on this controller is modified
  42316. */
  42317. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42318. /**
  42319. * Creates a new OculusTouchController from a gamepad
  42320. * @param vrGamepad the gamepad that the controller should be created from
  42321. */
  42322. constructor(vrGamepad: any);
  42323. /**
  42324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42325. * @param scene scene in which to add meshes
  42326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42327. */
  42328. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42329. /**
  42330. * Fired when the A button on this controller is modified
  42331. */
  42332. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42333. /**
  42334. * Fired when the B button on this controller is modified
  42335. */
  42336. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42337. /**
  42338. * Fired when the X button on this controller is modified
  42339. */
  42340. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42341. /**
  42342. * Fired when the Y button on this controller is modified
  42343. */
  42344. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42345. /**
  42346. * Called once for each button that changed state since the last frame
  42347. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42348. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42349. * 2) secondary trigger (same)
  42350. * 3) A (right) X (left), touch, pressed = value
  42351. * 4) B / Y
  42352. * 5) thumb rest
  42353. * @param buttonIdx Which button index changed
  42354. * @param state New state of the button
  42355. * @param changes Which properties on the state changed since last frame
  42356. */
  42357. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42358. }
  42359. }
  42360. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42361. import { Scene } from "babylonjs/scene";
  42362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42363. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42364. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42365. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42366. import { Observable } from "babylonjs/Misc/observable";
  42367. /**
  42368. * Vive Controller
  42369. */
  42370. export class ViveController extends WebVRController {
  42371. /**
  42372. * Base Url for the controller model.
  42373. */
  42374. static MODEL_BASE_URL: string;
  42375. /**
  42376. * File name for the controller model.
  42377. */
  42378. static MODEL_FILENAME: string;
  42379. /**
  42380. * Creates a new ViveController from a gamepad
  42381. * @param vrGamepad the gamepad that the controller should be created from
  42382. */
  42383. constructor(vrGamepad: any);
  42384. /**
  42385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42386. * @param scene scene in which to add meshes
  42387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42388. */
  42389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42390. /**
  42391. * Fired when the left button on this controller is modified
  42392. */
  42393. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42394. /**
  42395. * Fired when the right button on this controller is modified
  42396. */
  42397. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42398. /**
  42399. * Fired when the menu button on this controller is modified
  42400. */
  42401. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42402. /**
  42403. * Called once for each button that changed state since the last frame
  42404. * Vive mapping:
  42405. * 0: touchpad
  42406. * 1: trigger
  42407. * 2: left AND right buttons
  42408. * 3: menu button
  42409. * @param buttonIdx Which button index changed
  42410. * @param state New state of the button
  42411. * @param changes Which properties on the state changed since last frame
  42412. */
  42413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42414. }
  42415. }
  42416. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42417. import { Observable } from "babylonjs/Misc/observable";
  42418. import { Scene } from "babylonjs/scene";
  42419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42420. import { Ray } from "babylonjs/Culling/ray";
  42421. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42422. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42423. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42424. /**
  42425. * Defines the WindowsMotionController object that the state of the windows motion controller
  42426. */
  42427. export class WindowsMotionController extends WebVRController {
  42428. /**
  42429. * The base url used to load the left and right controller models
  42430. */
  42431. static MODEL_BASE_URL: string;
  42432. /**
  42433. * The name of the left controller model file
  42434. */
  42435. static MODEL_LEFT_FILENAME: string;
  42436. /**
  42437. * The name of the right controller model file
  42438. */
  42439. static MODEL_RIGHT_FILENAME: string;
  42440. /**
  42441. * The controller name prefix for this controller type
  42442. */
  42443. static readonly GAMEPAD_ID_PREFIX: string;
  42444. /**
  42445. * The controller id pattern for this controller type
  42446. */
  42447. private static readonly GAMEPAD_ID_PATTERN;
  42448. private _loadedMeshInfo;
  42449. private readonly _mapping;
  42450. /**
  42451. * Fired when the trackpad on this controller is clicked
  42452. */
  42453. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42454. /**
  42455. * Fired when the trackpad on this controller is modified
  42456. */
  42457. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42458. /**
  42459. * The current x and y values of this controller's trackpad
  42460. */
  42461. trackpad: StickValues;
  42462. /**
  42463. * Creates a new WindowsMotionController from a gamepad
  42464. * @param vrGamepad the gamepad that the controller should be created from
  42465. */
  42466. constructor(vrGamepad: any);
  42467. /**
  42468. * Fired when the trigger on this controller is modified
  42469. */
  42470. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42471. /**
  42472. * Fired when the menu button on this controller is modified
  42473. */
  42474. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42475. /**
  42476. * Fired when the grip button on this controller is modified
  42477. */
  42478. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42479. /**
  42480. * Fired when the thumbstick button on this controller is modified
  42481. */
  42482. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42483. /**
  42484. * Fired when the touchpad button on this controller is modified
  42485. */
  42486. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42487. /**
  42488. * Fired when the touchpad values on this controller are modified
  42489. */
  42490. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42491. private _updateTrackpad;
  42492. /**
  42493. * Called once per frame by the engine.
  42494. */
  42495. update(): void;
  42496. /**
  42497. * Called once for each button that changed state since the last frame
  42498. * @param buttonIdx Which button index changed
  42499. * @param state New state of the button
  42500. * @param changes Which properties on the state changed since last frame
  42501. */
  42502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42503. /**
  42504. * Moves the buttons on the controller mesh based on their current state
  42505. * @param buttonName the name of the button to move
  42506. * @param buttonValue the value of the button which determines the buttons new position
  42507. */
  42508. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42509. /**
  42510. * Moves the axis on the controller mesh based on its current state
  42511. * @param axis the index of the axis
  42512. * @param axisValue the value of the axis which determines the meshes new position
  42513. * @hidden
  42514. */
  42515. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42516. /**
  42517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42518. * @param scene scene in which to add meshes
  42519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42520. */
  42521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42522. /**
  42523. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42524. * can be transformed by button presses and axes values, based on this._mapping.
  42525. *
  42526. * @param scene scene in which the meshes exist
  42527. * @param meshes list of meshes that make up the controller model to process
  42528. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42529. */
  42530. private processModel;
  42531. private createMeshInfo;
  42532. /**
  42533. * Gets the ray of the controller in the direction the controller is pointing
  42534. * @param length the length the resulting ray should be
  42535. * @returns a ray in the direction the controller is pointing
  42536. */
  42537. getForwardRay(length?: number): Ray;
  42538. /**
  42539. * Disposes of the controller
  42540. */
  42541. dispose(): void;
  42542. }
  42543. }
  42544. declare module "babylonjs/Gamepads/Controllers/index" {
  42545. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42546. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42547. export * from "babylonjs/Gamepads/Controllers/genericController";
  42548. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42549. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42550. export * from "babylonjs/Gamepads/Controllers/viveController";
  42551. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42552. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42553. }
  42554. declare module "babylonjs/Gamepads/index" {
  42555. export * from "babylonjs/Gamepads/Controllers/index";
  42556. export * from "babylonjs/Gamepads/gamepad";
  42557. export * from "babylonjs/Gamepads/gamepadManager";
  42558. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42559. export * from "babylonjs/Gamepads/xboxGamepad";
  42560. }
  42561. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42562. import { Observable } from "babylonjs/Misc/observable";
  42563. import { Nullable } from "babylonjs/types";
  42564. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42566. import { Mesh } from "babylonjs/Meshes/mesh";
  42567. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42568. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42569. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42570. /**
  42571. * Single axis scale gizmo
  42572. */
  42573. export class AxisScaleGizmo extends Gizmo {
  42574. private _coloredMaterial;
  42575. /**
  42576. * Drag behavior responsible for the gizmos dragging interactions
  42577. */
  42578. dragBehavior: PointerDragBehavior;
  42579. private _pointerObserver;
  42580. /**
  42581. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42582. */
  42583. snapDistance: number;
  42584. /**
  42585. * Event that fires each time the gizmo snaps to a new location.
  42586. * * snapDistance is the the change in distance
  42587. */
  42588. onSnapObservable: Observable<{
  42589. snapDistance: number;
  42590. }>;
  42591. /**
  42592. * If the scaling operation should be done on all axis (default: false)
  42593. */
  42594. uniformScaling: boolean;
  42595. /**
  42596. * Creates an AxisScaleGizmo
  42597. * @param gizmoLayer The utility layer the gizmo will be added to
  42598. * @param dragAxis The axis which the gizmo will be able to scale on
  42599. * @param color The color of the gizmo
  42600. */
  42601. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42602. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42603. /**
  42604. * Disposes of the gizmo
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42609. * @param mesh The mesh to replace the default mesh of the gizmo
  42610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42611. */
  42612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42613. }
  42614. }
  42615. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42616. import { Observable } from "babylonjs/Misc/observable";
  42617. import { Nullable } from "babylonjs/types";
  42618. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42620. import { Mesh } from "babylonjs/Meshes/mesh";
  42621. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42622. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42623. import "babylonjs/Meshes/Builders/boxBuilder";
  42624. /**
  42625. * Bounding box gizmo
  42626. */
  42627. export class BoundingBoxGizmo extends Gizmo {
  42628. private _lineBoundingBox;
  42629. private _rotateSpheresParent;
  42630. private _scaleBoxesParent;
  42631. private _boundingDimensions;
  42632. private _renderObserver;
  42633. private _pointerObserver;
  42634. private _scaleDragSpeed;
  42635. private _tmpQuaternion;
  42636. private _tmpVector;
  42637. private _tmpRotationMatrix;
  42638. /**
  42639. * 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)
  42640. */
  42641. ignoreChildren: boolean;
  42642. /**
  42643. * 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)
  42644. */
  42645. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42646. /**
  42647. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42648. */
  42649. rotationSphereSize: number;
  42650. /**
  42651. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42652. */
  42653. scaleBoxSize: number;
  42654. /**
  42655. * 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)
  42656. */
  42657. fixedDragMeshScreenSize: boolean;
  42658. /**
  42659. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42660. */
  42661. fixedDragMeshScreenSizeDistanceFactor: number;
  42662. /**
  42663. * Fired when a rotation sphere or scale box is dragged
  42664. */
  42665. onDragStartObservable: Observable<{}>;
  42666. /**
  42667. * Fired when a scale box is dragged
  42668. */
  42669. onScaleBoxDragObservable: Observable<{}>;
  42670. /**
  42671. * Fired when a scale box drag is ended
  42672. */
  42673. onScaleBoxDragEndObservable: Observable<{}>;
  42674. /**
  42675. * Fired when a rotation sphere is dragged
  42676. */
  42677. onRotationSphereDragObservable: Observable<{}>;
  42678. /**
  42679. * Fired when a rotation sphere drag is ended
  42680. */
  42681. onRotationSphereDragEndObservable: Observable<{}>;
  42682. /**
  42683. * 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)
  42684. */
  42685. scalePivot: Nullable<Vector3>;
  42686. private _anchorMesh;
  42687. private _existingMeshScale;
  42688. private _dragMesh;
  42689. private pointerDragBehavior;
  42690. private coloredMaterial;
  42691. private hoverColoredMaterial;
  42692. /**
  42693. * Sets the color of the bounding box gizmo
  42694. * @param color the color to set
  42695. */
  42696. setColor(color: Color3): void;
  42697. /**
  42698. * Creates an BoundingBoxGizmo
  42699. * @param gizmoLayer The utility layer the gizmo will be added to
  42700. * @param color The color of the gizmo
  42701. */
  42702. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42704. private _selectNode;
  42705. /**
  42706. * Updates the bounding box information for the Gizmo
  42707. */
  42708. updateBoundingBox(): void;
  42709. private _updateRotationSpheres;
  42710. private _updateScaleBoxes;
  42711. /**
  42712. * Enables rotation on the specified axis and disables rotation on the others
  42713. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42714. */
  42715. setEnabledRotationAxis(axis: string): void;
  42716. /**
  42717. * Enables/disables scaling
  42718. * @param enable if scaling should be enabled
  42719. */
  42720. setEnabledScaling(enable: boolean): void;
  42721. private _updateDummy;
  42722. /**
  42723. * Enables a pointer drag behavior on the bounding box of the gizmo
  42724. */
  42725. enableDragBehavior(): void;
  42726. /**
  42727. * Disposes of the gizmo
  42728. */
  42729. dispose(): void;
  42730. /**
  42731. * 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)
  42732. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42733. * @returns the bounding box mesh with the passed in mesh as a child
  42734. */
  42735. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42736. /**
  42737. * CustomMeshes are not supported by this gizmo
  42738. * @param mesh The mesh to replace the default mesh of the gizmo
  42739. */
  42740. setCustomMesh(mesh: Mesh): void;
  42741. }
  42742. }
  42743. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42744. import { Observable } from "babylonjs/Misc/observable";
  42745. import { Nullable } from "babylonjs/types";
  42746. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42748. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42749. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42750. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42751. import "babylonjs/Meshes/Builders/linesBuilder";
  42752. /**
  42753. * Single plane rotation gizmo
  42754. */
  42755. export class PlaneRotationGizmo extends Gizmo {
  42756. /**
  42757. * Drag behavior responsible for the gizmos dragging interactions
  42758. */
  42759. dragBehavior: PointerDragBehavior;
  42760. private _pointerObserver;
  42761. /**
  42762. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42763. */
  42764. snapDistance: number;
  42765. /**
  42766. * Event that fires each time the gizmo snaps to a new location.
  42767. * * snapDistance is the the change in distance
  42768. */
  42769. onSnapObservable: Observable<{
  42770. snapDistance: number;
  42771. }>;
  42772. /**
  42773. * Creates a PlaneRotationGizmo
  42774. * @param gizmoLayer The utility layer the gizmo will be added to
  42775. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42776. * @param color The color of the gizmo
  42777. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42778. */
  42779. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42780. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42781. /**
  42782. * Disposes of the gizmo
  42783. */
  42784. dispose(): void;
  42785. }
  42786. }
  42787. declare module "babylonjs/Gizmos/rotationGizmo" {
  42788. import { Observable } from "babylonjs/Misc/observable";
  42789. import { Nullable } from "babylonjs/types";
  42790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42791. import { Mesh } from "babylonjs/Meshes/mesh";
  42792. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42793. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42794. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42795. /**
  42796. * Gizmo that enables rotating a mesh along 3 axis
  42797. */
  42798. export class RotationGizmo extends Gizmo {
  42799. /**
  42800. * Internal gizmo used for interactions on the x axis
  42801. */
  42802. xGizmo: PlaneRotationGizmo;
  42803. /**
  42804. * Internal gizmo used for interactions on the y axis
  42805. */
  42806. yGizmo: PlaneRotationGizmo;
  42807. /**
  42808. * Internal gizmo used for interactions on the z axis
  42809. */
  42810. zGizmo: PlaneRotationGizmo;
  42811. /** Fires an event when any of it's sub gizmos are dragged */
  42812. onDragStartObservable: Observable<{}>;
  42813. /** Fires an event when any of it's sub gizmos are released from dragging */
  42814. onDragEndObservable: Observable<{}>;
  42815. attachedMesh: Nullable<AbstractMesh>;
  42816. /**
  42817. * Creates a RotationGizmo
  42818. * @param gizmoLayer The utility layer the gizmo will be added to
  42819. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42820. */
  42821. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42822. updateGizmoRotationToMatchAttachedMesh: boolean;
  42823. /**
  42824. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42825. */
  42826. snapDistance: number;
  42827. /**
  42828. * Ratio for the scale of the gizmo (Default: 1)
  42829. */
  42830. scaleRatio: number;
  42831. /**
  42832. * Disposes of the gizmo
  42833. */
  42834. dispose(): void;
  42835. /**
  42836. * CustomMeshes are not supported by this gizmo
  42837. * @param mesh The mesh to replace the default mesh of the gizmo
  42838. */
  42839. setCustomMesh(mesh: Mesh): void;
  42840. }
  42841. }
  42842. declare module "babylonjs/Gizmos/positionGizmo" {
  42843. import { Observable } from "babylonjs/Misc/observable";
  42844. import { Nullable } from "babylonjs/types";
  42845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42846. import { Mesh } from "babylonjs/Meshes/mesh";
  42847. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42848. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42849. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42850. /**
  42851. * Gizmo that enables dragging a mesh along 3 axis
  42852. */
  42853. export class PositionGizmo extends Gizmo {
  42854. /**
  42855. * Internal gizmo used for interactions on the x axis
  42856. */
  42857. xGizmo: AxisDragGizmo;
  42858. /**
  42859. * Internal gizmo used for interactions on the y axis
  42860. */
  42861. yGizmo: AxisDragGizmo;
  42862. /**
  42863. * Internal gizmo used for interactions on the z axis
  42864. */
  42865. zGizmo: AxisDragGizmo;
  42866. /** Fires an event when any of it's sub gizmos are dragged */
  42867. onDragStartObservable: Observable<{}>;
  42868. /** Fires an event when any of it's sub gizmos are released from dragging */
  42869. onDragEndObservable: Observable<{}>;
  42870. attachedMesh: Nullable<AbstractMesh>;
  42871. /**
  42872. * Creates a PositionGizmo
  42873. * @param gizmoLayer The utility layer the gizmo will be added to
  42874. */
  42875. constructor(gizmoLayer?: UtilityLayerRenderer);
  42876. updateGizmoRotationToMatchAttachedMesh: boolean;
  42877. /**
  42878. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42879. */
  42880. snapDistance: number;
  42881. /**
  42882. * Ratio for the scale of the gizmo (Default: 1)
  42883. */
  42884. scaleRatio: number;
  42885. /**
  42886. * Disposes of the gizmo
  42887. */
  42888. dispose(): void;
  42889. /**
  42890. * CustomMeshes are not supported by this gizmo
  42891. * @param mesh The mesh to replace the default mesh of the gizmo
  42892. */
  42893. setCustomMesh(mesh: Mesh): void;
  42894. }
  42895. }
  42896. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42897. import { Scene } from "babylonjs/scene";
  42898. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42899. import { Mesh } from "babylonjs/Meshes/mesh";
  42900. /**
  42901. * Class containing static functions to help procedurally build meshes
  42902. */
  42903. export class PolyhedronBuilder {
  42904. /**
  42905. * Creates a polyhedron mesh
  42906. * * 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
  42907. * * The parameter `size` (positive float, default 1) sets the polygon size
  42908. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42909. * * 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`
  42910. * * 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
  42911. * * 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)`)
  42912. * * 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
  42913. * * 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
  42914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42917. * @param name defines the name of the mesh
  42918. * @param options defines the options used to create the mesh
  42919. * @param scene defines the hosting scene
  42920. * @returns the polyhedron mesh
  42921. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42922. */
  42923. static CreatePolyhedron(name: string, options: {
  42924. type?: number;
  42925. size?: number;
  42926. sizeX?: number;
  42927. sizeY?: number;
  42928. sizeZ?: number;
  42929. custom?: any;
  42930. faceUV?: Vector4[];
  42931. faceColors?: Color4[];
  42932. flat?: boolean;
  42933. updatable?: boolean;
  42934. sideOrientation?: number;
  42935. frontUVs?: Vector4;
  42936. backUVs?: Vector4;
  42937. }, scene: Scene): Mesh;
  42938. }
  42939. }
  42940. declare module "babylonjs/Gizmos/scaleGizmo" {
  42941. import { Observable } from "babylonjs/Misc/observable";
  42942. import { Nullable } from "babylonjs/types";
  42943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42944. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42945. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42946. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42947. /**
  42948. * Gizmo that enables scaling a mesh along 3 axis
  42949. */
  42950. export class ScaleGizmo extends Gizmo {
  42951. /**
  42952. * Internal gizmo used for interactions on the x axis
  42953. */
  42954. xGizmo: AxisScaleGizmo;
  42955. /**
  42956. * Internal gizmo used for interactions on the y axis
  42957. */
  42958. yGizmo: AxisScaleGizmo;
  42959. /**
  42960. * Internal gizmo used for interactions on the z axis
  42961. */
  42962. zGizmo: AxisScaleGizmo;
  42963. /**
  42964. * Internal gizmo used to scale all axis equally
  42965. */
  42966. uniformScaleGizmo: AxisScaleGizmo;
  42967. /** Fires an event when any of it's sub gizmos are dragged */
  42968. onDragStartObservable: Observable<{}>;
  42969. /** Fires an event when any of it's sub gizmos are released from dragging */
  42970. onDragEndObservable: Observable<{}>;
  42971. attachedMesh: Nullable<AbstractMesh>;
  42972. /**
  42973. * Creates a ScaleGizmo
  42974. * @param gizmoLayer The utility layer the gizmo will be added to
  42975. */
  42976. constructor(gizmoLayer?: UtilityLayerRenderer);
  42977. updateGizmoRotationToMatchAttachedMesh: boolean;
  42978. /**
  42979. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42980. */
  42981. snapDistance: number;
  42982. /**
  42983. * Ratio for the scale of the gizmo (Default: 1)
  42984. */
  42985. scaleRatio: number;
  42986. /**
  42987. * Disposes of the gizmo
  42988. */
  42989. dispose(): void;
  42990. }
  42991. }
  42992. declare module "babylonjs/Gizmos/gizmoManager" {
  42993. import { Observable } from "babylonjs/Misc/observable";
  42994. import { Nullable } from "babylonjs/types";
  42995. import { Scene, IDisposable } from "babylonjs/scene";
  42996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42997. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42998. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42999. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43000. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43001. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43002. /**
  43003. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43004. */
  43005. export class GizmoManager implements IDisposable {
  43006. private scene;
  43007. /**
  43008. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43009. */
  43010. gizmos: {
  43011. positionGizmo: Nullable<PositionGizmo>;
  43012. rotationGizmo: Nullable<RotationGizmo>;
  43013. scaleGizmo: Nullable<ScaleGizmo>;
  43014. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43015. };
  43016. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43017. clearGizmoOnEmptyPointerEvent: boolean;
  43018. /** Fires an event when the manager is attached to a mesh */
  43019. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43020. private _gizmosEnabled;
  43021. private _pointerObserver;
  43022. private _attachedMesh;
  43023. private _boundingBoxColor;
  43024. private _defaultUtilityLayer;
  43025. private _defaultKeepDepthUtilityLayer;
  43026. /**
  43027. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43028. */
  43029. boundingBoxDragBehavior: SixDofDragBehavior;
  43030. /**
  43031. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43032. */
  43033. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43034. /**
  43035. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43036. */
  43037. usePointerToAttachGizmos: boolean;
  43038. /**
  43039. * Instatiates a gizmo manager
  43040. * @param scene the scene to overlay the gizmos on top of
  43041. */
  43042. constructor(scene: Scene);
  43043. /**
  43044. * Attaches a set of gizmos to the specified mesh
  43045. * @param mesh The mesh the gizmo's should be attached to
  43046. */
  43047. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43048. /**
  43049. * If the position gizmo is enabled
  43050. */
  43051. positionGizmoEnabled: boolean;
  43052. /**
  43053. * If the rotation gizmo is enabled
  43054. */
  43055. rotationGizmoEnabled: boolean;
  43056. /**
  43057. * If the scale gizmo is enabled
  43058. */
  43059. scaleGizmoEnabled: boolean;
  43060. /**
  43061. * If the boundingBox gizmo is enabled
  43062. */
  43063. boundingBoxGizmoEnabled: boolean;
  43064. /**
  43065. * Disposes of the gizmo manager
  43066. */
  43067. dispose(): void;
  43068. }
  43069. }
  43070. declare module "babylonjs/Gizmos/lightGizmo" {
  43071. import { Nullable } from "babylonjs/types";
  43072. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43074. import { Light } from "babylonjs/Lights/light";
  43075. /**
  43076. * Gizmo that enables viewing a light
  43077. */
  43078. export class LightGizmo extends Gizmo {
  43079. private _box;
  43080. /**
  43081. * Creates a LightGizmo
  43082. * @param gizmoLayer The utility layer the gizmo will be added to
  43083. */
  43084. constructor(gizmoLayer?: UtilityLayerRenderer);
  43085. private _light;
  43086. /**
  43087. * The light that the gizmo is attached to
  43088. */
  43089. light: Nullable<Light>;
  43090. /**
  43091. * @hidden
  43092. * Updates the gizmo to match the attached mesh's position/rotation
  43093. */
  43094. protected _update(): void;
  43095. }
  43096. }
  43097. declare module "babylonjs/Gizmos/index" {
  43098. export * from "babylonjs/Gizmos/axisDragGizmo";
  43099. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43100. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43101. export * from "babylonjs/Gizmos/gizmo";
  43102. export * from "babylonjs/Gizmos/gizmoManager";
  43103. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43104. export * from "babylonjs/Gizmos/positionGizmo";
  43105. export * from "babylonjs/Gizmos/rotationGizmo";
  43106. export * from "babylonjs/Gizmos/scaleGizmo";
  43107. export * from "babylonjs/Gizmos/lightGizmo";
  43108. }
  43109. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43110. /** @hidden */
  43111. export var backgroundFragmentDeclaration: {
  43112. name: string;
  43113. shader: string;
  43114. };
  43115. }
  43116. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43117. /** @hidden */
  43118. export var backgroundUboDeclaration: {
  43119. name: string;
  43120. shader: string;
  43121. };
  43122. }
  43123. declare module "babylonjs/Shaders/background.fragment" {
  43124. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43125. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43126. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43128. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43129. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43130. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43131. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43132. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43133. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43134. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43135. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43136. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43137. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43138. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43139. /** @hidden */
  43140. export var backgroundPixelShader: {
  43141. name: string;
  43142. shader: string;
  43143. };
  43144. }
  43145. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43146. /** @hidden */
  43147. export var backgroundVertexDeclaration: {
  43148. name: string;
  43149. shader: string;
  43150. };
  43151. }
  43152. declare module "babylonjs/Shaders/background.vertex" {
  43153. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43154. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43155. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43156. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43157. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43159. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43160. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43161. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43162. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43163. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43164. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43165. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43166. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43167. /** @hidden */
  43168. export var backgroundVertexShader: {
  43169. name: string;
  43170. shader: string;
  43171. };
  43172. }
  43173. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43174. import { Nullable, int, float } from "babylonjs/types";
  43175. import { Scene } from "babylonjs/scene";
  43176. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43177. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43179. import { Mesh } from "babylonjs/Meshes/mesh";
  43180. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43181. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43182. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43184. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43185. import "babylonjs/Shaders/background.fragment";
  43186. import "babylonjs/Shaders/background.vertex";
  43187. /**
  43188. * Background material used to create an efficient environement around your scene.
  43189. */
  43190. export class BackgroundMaterial extends PushMaterial {
  43191. /**
  43192. * Standard reflectance value at parallel view angle.
  43193. */
  43194. static StandardReflectance0: number;
  43195. /**
  43196. * Standard reflectance value at grazing angle.
  43197. */
  43198. static StandardReflectance90: number;
  43199. protected _primaryColor: Color3;
  43200. /**
  43201. * Key light Color (multiply against the environement texture)
  43202. */
  43203. primaryColor: Color3;
  43204. protected __perceptualColor: Nullable<Color3>;
  43205. /**
  43206. * Experimental Internal Use Only.
  43207. *
  43208. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43209. * This acts as a helper to set the primary color to a more "human friendly" value.
  43210. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43211. * output color as close as possible from the chosen value.
  43212. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43213. * part of lighting setup.)
  43214. */
  43215. _perceptualColor: Nullable<Color3>;
  43216. protected _primaryColorShadowLevel: float;
  43217. /**
  43218. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43219. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43220. */
  43221. primaryColorShadowLevel: float;
  43222. protected _primaryColorHighlightLevel: float;
  43223. /**
  43224. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43225. * The primary color is used at the level chosen to define what the white area would look.
  43226. */
  43227. primaryColorHighlightLevel: float;
  43228. protected _reflectionTexture: Nullable<BaseTexture>;
  43229. /**
  43230. * Reflection Texture used in the material.
  43231. * Should be author in a specific way for the best result (refer to the documentation).
  43232. */
  43233. reflectionTexture: Nullable<BaseTexture>;
  43234. protected _reflectionBlur: float;
  43235. /**
  43236. * Reflection Texture level of blur.
  43237. *
  43238. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43239. * texture twice.
  43240. */
  43241. reflectionBlur: float;
  43242. protected _diffuseTexture: Nullable<BaseTexture>;
  43243. /**
  43244. * Diffuse Texture used in the material.
  43245. * Should be author in a specific way for the best result (refer to the documentation).
  43246. */
  43247. diffuseTexture: Nullable<BaseTexture>;
  43248. protected _shadowLights: Nullable<IShadowLight[]>;
  43249. /**
  43250. * Specify the list of lights casting shadow on the material.
  43251. * All scene shadow lights will be included if null.
  43252. */
  43253. shadowLights: Nullable<IShadowLight[]>;
  43254. protected _shadowLevel: float;
  43255. /**
  43256. * Helps adjusting the shadow to a softer level if required.
  43257. * 0 means black shadows and 1 means no shadows.
  43258. */
  43259. shadowLevel: float;
  43260. protected _sceneCenter: Vector3;
  43261. /**
  43262. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43263. * It is usually zero but might be interesting to modify according to your setup.
  43264. */
  43265. sceneCenter: Vector3;
  43266. protected _opacityFresnel: boolean;
  43267. /**
  43268. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43269. * This helps ensuring a nice transition when the camera goes under the ground.
  43270. */
  43271. opacityFresnel: boolean;
  43272. protected _reflectionFresnel: boolean;
  43273. /**
  43274. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43275. * This helps adding a mirror texture on the ground.
  43276. */
  43277. reflectionFresnel: boolean;
  43278. protected _reflectionFalloffDistance: number;
  43279. /**
  43280. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43281. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43282. */
  43283. reflectionFalloffDistance: number;
  43284. protected _reflectionAmount: number;
  43285. /**
  43286. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43287. */
  43288. reflectionAmount: number;
  43289. protected _reflectionReflectance0: number;
  43290. /**
  43291. * This specifies the weight of the reflection at grazing angle.
  43292. */
  43293. reflectionReflectance0: number;
  43294. protected _reflectionReflectance90: number;
  43295. /**
  43296. * This specifies the weight of the reflection at a perpendicular point of view.
  43297. */
  43298. reflectionReflectance90: number;
  43299. /**
  43300. * Sets the reflection reflectance fresnel values according to the default standard
  43301. * empirically know to work well :-)
  43302. */
  43303. reflectionStandardFresnelWeight: number;
  43304. protected _useRGBColor: boolean;
  43305. /**
  43306. * Helps to directly use the maps channels instead of their level.
  43307. */
  43308. useRGBColor: boolean;
  43309. protected _enableNoise: boolean;
  43310. /**
  43311. * This helps reducing the banding effect that could occur on the background.
  43312. */
  43313. enableNoise: boolean;
  43314. /**
  43315. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43316. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43317. * Recommended to be keep at 1.0 except for special cases.
  43318. */
  43319. fovMultiplier: number;
  43320. private _fovMultiplier;
  43321. /**
  43322. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43323. */
  43324. useEquirectangularFOV: boolean;
  43325. private _maxSimultaneousLights;
  43326. /**
  43327. * Number of Simultaneous lights allowed on the material.
  43328. */
  43329. maxSimultaneousLights: int;
  43330. /**
  43331. * Default configuration related to image processing available in the Background Material.
  43332. */
  43333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43334. /**
  43335. * Keep track of the image processing observer to allow dispose and replace.
  43336. */
  43337. private _imageProcessingObserver;
  43338. /**
  43339. * Attaches a new image processing configuration to the PBR Material.
  43340. * @param configuration (if null the scene configuration will be use)
  43341. */
  43342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43343. /**
  43344. * Gets the image processing configuration used either in this material.
  43345. */
  43346. /**
  43347. * Sets the Default image processing configuration used either in the this material.
  43348. *
  43349. * If sets to null, the scene one is in use.
  43350. */
  43351. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43352. /**
  43353. * Gets wether the color curves effect is enabled.
  43354. */
  43355. /**
  43356. * Sets wether the color curves effect is enabled.
  43357. */
  43358. cameraColorCurvesEnabled: boolean;
  43359. /**
  43360. * Gets wether the color grading effect is enabled.
  43361. */
  43362. /**
  43363. * Gets wether the color grading effect is enabled.
  43364. */
  43365. cameraColorGradingEnabled: boolean;
  43366. /**
  43367. * Gets wether tonemapping is enabled or not.
  43368. */
  43369. /**
  43370. * Sets wether tonemapping is enabled or not
  43371. */
  43372. cameraToneMappingEnabled: boolean;
  43373. /**
  43374. * The camera exposure used on this material.
  43375. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43376. * This corresponds to a photographic exposure.
  43377. */
  43378. /**
  43379. * The camera exposure used on this material.
  43380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43381. * This corresponds to a photographic exposure.
  43382. */
  43383. cameraExposure: float;
  43384. /**
  43385. * Gets The camera contrast used on this material.
  43386. */
  43387. /**
  43388. * Sets The camera contrast used on this material.
  43389. */
  43390. cameraContrast: float;
  43391. /**
  43392. * Gets the Color Grading 2D Lookup Texture.
  43393. */
  43394. /**
  43395. * Sets the Color Grading 2D Lookup Texture.
  43396. */
  43397. cameraColorGradingTexture: Nullable<BaseTexture>;
  43398. /**
  43399. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43400. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43401. * 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;
  43402. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43403. */
  43404. /**
  43405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43407. * 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;
  43408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43409. */
  43410. cameraColorCurves: Nullable<ColorCurves>;
  43411. /**
  43412. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43413. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43414. */
  43415. switchToBGR: boolean;
  43416. private _renderTargets;
  43417. private _reflectionControls;
  43418. private _white;
  43419. private _primaryShadowColor;
  43420. private _primaryHighlightColor;
  43421. /**
  43422. * Instantiates a Background Material in the given scene
  43423. * @param name The friendly name of the material
  43424. * @param scene The scene to add the material to
  43425. */
  43426. constructor(name: string, scene: Scene);
  43427. /**
  43428. * Gets a boolean indicating that current material needs to register RTT
  43429. */
  43430. readonly hasRenderTargetTextures: boolean;
  43431. /**
  43432. * The entire material has been created in order to prevent overdraw.
  43433. * @returns false
  43434. */
  43435. needAlphaTesting(): boolean;
  43436. /**
  43437. * The entire material has been created in order to prevent overdraw.
  43438. * @returns true if blending is enable
  43439. */
  43440. needAlphaBlending(): boolean;
  43441. /**
  43442. * Checks wether the material is ready to be rendered for a given mesh.
  43443. * @param mesh The mesh to render
  43444. * @param subMesh The submesh to check against
  43445. * @param useInstances Specify wether or not the material is used with instances
  43446. * @returns true if all the dependencies are ready (Textures, Effects...)
  43447. */
  43448. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43449. /**
  43450. * Compute the primary color according to the chosen perceptual color.
  43451. */
  43452. private _computePrimaryColorFromPerceptualColor;
  43453. /**
  43454. * Compute the highlights and shadow colors according to their chosen levels.
  43455. */
  43456. private _computePrimaryColors;
  43457. /**
  43458. * Build the uniform buffer used in the material.
  43459. */
  43460. buildUniformLayout(): void;
  43461. /**
  43462. * Unbind the material.
  43463. */
  43464. unbind(): void;
  43465. /**
  43466. * Bind only the world matrix to the material.
  43467. * @param world The world matrix to bind.
  43468. */
  43469. bindOnlyWorldMatrix(world: Matrix): void;
  43470. /**
  43471. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43472. * @param world The world matrix to bind.
  43473. * @param subMesh The submesh to bind for.
  43474. */
  43475. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43476. /**
  43477. * Dispose the material.
  43478. * @param forceDisposeEffect Force disposal of the associated effect.
  43479. * @param forceDisposeTextures Force disposal of the associated textures.
  43480. */
  43481. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43482. /**
  43483. * Clones the material.
  43484. * @param name The cloned name.
  43485. * @returns The cloned material.
  43486. */
  43487. clone(name: string): BackgroundMaterial;
  43488. /**
  43489. * Serializes the current material to its JSON representation.
  43490. * @returns The JSON representation.
  43491. */
  43492. serialize(): any;
  43493. /**
  43494. * Gets the class name of the material
  43495. * @returns "BackgroundMaterial"
  43496. */
  43497. getClassName(): string;
  43498. /**
  43499. * Parse a JSON input to create back a background material.
  43500. * @param source The JSON data to parse
  43501. * @param scene The scene to create the parsed material in
  43502. * @param rootUrl The root url of the assets the material depends upon
  43503. * @returns the instantiated BackgroundMaterial.
  43504. */
  43505. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43506. }
  43507. }
  43508. declare module "babylonjs/Helpers/environmentHelper" {
  43509. import { Observable } from "babylonjs/Misc/observable";
  43510. import { Nullable } from "babylonjs/types";
  43511. import { Scene } from "babylonjs/scene";
  43512. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43514. import { Mesh } from "babylonjs/Meshes/mesh";
  43515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43516. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43517. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43518. import "babylonjs/Meshes/Builders/planeBuilder";
  43519. import "babylonjs/Meshes/Builders/boxBuilder";
  43520. /**
  43521. * Represents the different options available during the creation of
  43522. * a Environment helper.
  43523. *
  43524. * This can control the default ground, skybox and image processing setup of your scene.
  43525. */
  43526. export interface IEnvironmentHelperOptions {
  43527. /**
  43528. * Specifies wether or not to create a ground.
  43529. * True by default.
  43530. */
  43531. createGround: boolean;
  43532. /**
  43533. * Specifies the ground size.
  43534. * 15 by default.
  43535. */
  43536. groundSize: number;
  43537. /**
  43538. * The texture used on the ground for the main color.
  43539. * Comes from the BabylonJS CDN by default.
  43540. *
  43541. * Remarks: Can be either a texture or a url.
  43542. */
  43543. groundTexture: string | BaseTexture;
  43544. /**
  43545. * The color mixed in the ground texture by default.
  43546. * BabylonJS clearColor by default.
  43547. */
  43548. groundColor: Color3;
  43549. /**
  43550. * Specifies the ground opacity.
  43551. * 1 by default.
  43552. */
  43553. groundOpacity: number;
  43554. /**
  43555. * Enables the ground to receive shadows.
  43556. * True by default.
  43557. */
  43558. enableGroundShadow: boolean;
  43559. /**
  43560. * Helps preventing the shadow to be fully black on the ground.
  43561. * 0.5 by default.
  43562. */
  43563. groundShadowLevel: number;
  43564. /**
  43565. * Creates a mirror texture attach to the ground.
  43566. * false by default.
  43567. */
  43568. enableGroundMirror: boolean;
  43569. /**
  43570. * Specifies the ground mirror size ratio.
  43571. * 0.3 by default as the default kernel is 64.
  43572. */
  43573. groundMirrorSizeRatio: number;
  43574. /**
  43575. * Specifies the ground mirror blur kernel size.
  43576. * 64 by default.
  43577. */
  43578. groundMirrorBlurKernel: number;
  43579. /**
  43580. * Specifies the ground mirror visibility amount.
  43581. * 1 by default
  43582. */
  43583. groundMirrorAmount: number;
  43584. /**
  43585. * Specifies the ground mirror reflectance weight.
  43586. * This uses the standard weight of the background material to setup the fresnel effect
  43587. * of the mirror.
  43588. * 1 by default.
  43589. */
  43590. groundMirrorFresnelWeight: number;
  43591. /**
  43592. * Specifies the ground mirror Falloff distance.
  43593. * This can helps reducing the size of the reflection.
  43594. * 0 by Default.
  43595. */
  43596. groundMirrorFallOffDistance: number;
  43597. /**
  43598. * Specifies the ground mirror texture type.
  43599. * Unsigned Int by Default.
  43600. */
  43601. groundMirrorTextureType: number;
  43602. /**
  43603. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43604. * the shown objects.
  43605. */
  43606. groundYBias: number;
  43607. /**
  43608. * Specifies wether or not to create a skybox.
  43609. * True by default.
  43610. */
  43611. createSkybox: boolean;
  43612. /**
  43613. * Specifies the skybox size.
  43614. * 20 by default.
  43615. */
  43616. skyboxSize: number;
  43617. /**
  43618. * The texture used on the skybox for the main color.
  43619. * Comes from the BabylonJS CDN by default.
  43620. *
  43621. * Remarks: Can be either a texture or a url.
  43622. */
  43623. skyboxTexture: string | BaseTexture;
  43624. /**
  43625. * The color mixed in the skybox texture by default.
  43626. * BabylonJS clearColor by default.
  43627. */
  43628. skyboxColor: Color3;
  43629. /**
  43630. * The background rotation around the Y axis of the scene.
  43631. * This helps aligning the key lights of your scene with the background.
  43632. * 0 by default.
  43633. */
  43634. backgroundYRotation: number;
  43635. /**
  43636. * Compute automatically the size of the elements to best fit with the scene.
  43637. */
  43638. sizeAuto: boolean;
  43639. /**
  43640. * Default position of the rootMesh if autoSize is not true.
  43641. */
  43642. rootPosition: Vector3;
  43643. /**
  43644. * Sets up the image processing in the scene.
  43645. * true by default.
  43646. */
  43647. setupImageProcessing: boolean;
  43648. /**
  43649. * The texture used as your environment texture in the scene.
  43650. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43651. *
  43652. * Remarks: Can be either a texture or a url.
  43653. */
  43654. environmentTexture: string | BaseTexture;
  43655. /**
  43656. * The value of the exposure to apply to the scene.
  43657. * 0.6 by default if setupImageProcessing is true.
  43658. */
  43659. cameraExposure: number;
  43660. /**
  43661. * The value of the contrast to apply to the scene.
  43662. * 1.6 by default if setupImageProcessing is true.
  43663. */
  43664. cameraContrast: number;
  43665. /**
  43666. * Specifies wether or not tonemapping should be enabled in the scene.
  43667. * true by default if setupImageProcessing is true.
  43668. */
  43669. toneMappingEnabled: boolean;
  43670. }
  43671. /**
  43672. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43673. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43674. * It also helps with the default setup of your imageProcessing configuration.
  43675. */
  43676. export class EnvironmentHelper {
  43677. /**
  43678. * Default ground texture URL.
  43679. */
  43680. private static _groundTextureCDNUrl;
  43681. /**
  43682. * Default skybox texture URL.
  43683. */
  43684. private static _skyboxTextureCDNUrl;
  43685. /**
  43686. * Default environment texture URL.
  43687. */
  43688. private static _environmentTextureCDNUrl;
  43689. /**
  43690. * Creates the default options for the helper.
  43691. */
  43692. private static _getDefaultOptions;
  43693. private _rootMesh;
  43694. /**
  43695. * Gets the root mesh created by the helper.
  43696. */
  43697. readonly rootMesh: Mesh;
  43698. private _skybox;
  43699. /**
  43700. * Gets the skybox created by the helper.
  43701. */
  43702. readonly skybox: Nullable<Mesh>;
  43703. private _skyboxTexture;
  43704. /**
  43705. * Gets the skybox texture created by the helper.
  43706. */
  43707. readonly skyboxTexture: Nullable<BaseTexture>;
  43708. private _skyboxMaterial;
  43709. /**
  43710. * Gets the skybox material created by the helper.
  43711. */
  43712. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43713. private _ground;
  43714. /**
  43715. * Gets the ground mesh created by the helper.
  43716. */
  43717. readonly ground: Nullable<Mesh>;
  43718. private _groundTexture;
  43719. /**
  43720. * Gets the ground texture created by the helper.
  43721. */
  43722. readonly groundTexture: Nullable<BaseTexture>;
  43723. private _groundMirror;
  43724. /**
  43725. * Gets the ground mirror created by the helper.
  43726. */
  43727. readonly groundMirror: Nullable<MirrorTexture>;
  43728. /**
  43729. * Gets the ground mirror render list to helps pushing the meshes
  43730. * you wish in the ground reflection.
  43731. */
  43732. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43733. private _groundMaterial;
  43734. /**
  43735. * Gets the ground material created by the helper.
  43736. */
  43737. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43738. /**
  43739. * Stores the creation options.
  43740. */
  43741. private readonly _scene;
  43742. private _options;
  43743. /**
  43744. * This observable will be notified with any error during the creation of the environment,
  43745. * mainly texture creation errors.
  43746. */
  43747. onErrorObservable: Observable<{
  43748. message?: string;
  43749. exception?: any;
  43750. }>;
  43751. /**
  43752. * constructor
  43753. * @param options Defines the options we want to customize the helper
  43754. * @param scene The scene to add the material to
  43755. */
  43756. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43757. /**
  43758. * Updates the background according to the new options
  43759. * @param options
  43760. */
  43761. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43762. /**
  43763. * Sets the primary color of all the available elements.
  43764. * @param color the main color to affect to the ground and the background
  43765. */
  43766. setMainColor(color: Color3): void;
  43767. /**
  43768. * Setup the image processing according to the specified options.
  43769. */
  43770. private _setupImageProcessing;
  43771. /**
  43772. * Setup the environment texture according to the specified options.
  43773. */
  43774. private _setupEnvironmentTexture;
  43775. /**
  43776. * Setup the background according to the specified options.
  43777. */
  43778. private _setupBackground;
  43779. /**
  43780. * Get the scene sizes according to the setup.
  43781. */
  43782. private _getSceneSize;
  43783. /**
  43784. * Setup the ground according to the specified options.
  43785. */
  43786. private _setupGround;
  43787. /**
  43788. * Setup the ground material according to the specified options.
  43789. */
  43790. private _setupGroundMaterial;
  43791. /**
  43792. * Setup the ground diffuse texture according to the specified options.
  43793. */
  43794. private _setupGroundDiffuseTexture;
  43795. /**
  43796. * Setup the ground mirror texture according to the specified options.
  43797. */
  43798. private _setupGroundMirrorTexture;
  43799. /**
  43800. * Setup the ground to receive the mirror texture.
  43801. */
  43802. private _setupMirrorInGroundMaterial;
  43803. /**
  43804. * Setup the skybox according to the specified options.
  43805. */
  43806. private _setupSkybox;
  43807. /**
  43808. * Setup the skybox material according to the specified options.
  43809. */
  43810. private _setupSkyboxMaterial;
  43811. /**
  43812. * Setup the skybox reflection texture according to the specified options.
  43813. */
  43814. private _setupSkyboxReflectionTexture;
  43815. private _errorHandler;
  43816. /**
  43817. * Dispose all the elements created by the Helper.
  43818. */
  43819. dispose(): void;
  43820. }
  43821. }
  43822. declare module "babylonjs/Helpers/photoDome" {
  43823. import { Observable } from "babylonjs/Misc/observable";
  43824. import { Nullable } from "babylonjs/types";
  43825. import { Scene } from "babylonjs/scene";
  43826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43827. import { Mesh } from "babylonjs/Meshes/mesh";
  43828. import { Texture } from "babylonjs/Materials/Textures/texture";
  43829. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43830. import "babylonjs/Meshes/Builders/sphereBuilder";
  43831. /**
  43832. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43833. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43834. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43835. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43836. */
  43837. export class PhotoDome extends TransformNode {
  43838. private _useDirectMapping;
  43839. /**
  43840. * The texture being displayed on the sphere
  43841. */
  43842. protected _photoTexture: Texture;
  43843. /**
  43844. * Gets or sets the texture being displayed on the sphere
  43845. */
  43846. photoTexture: Texture;
  43847. /**
  43848. * Observable raised when an error occured while loading the 360 image
  43849. */
  43850. onLoadErrorObservable: Observable<string>;
  43851. /**
  43852. * The skybox material
  43853. */
  43854. protected _material: BackgroundMaterial;
  43855. /**
  43856. * The surface used for the skybox
  43857. */
  43858. protected _mesh: Mesh;
  43859. /**
  43860. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43861. * Also see the options.resolution property.
  43862. */
  43863. fovMultiplier: number;
  43864. /**
  43865. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43866. * @param name Element's name, child elements will append suffixes for their own names.
  43867. * @param urlsOfPhoto defines the url of the photo to display
  43868. * @param options defines an object containing optional or exposed sub element properties
  43869. * @param onError defines a callback called when an error occured while loading the texture
  43870. */
  43871. constructor(name: string, urlOfPhoto: string, options: {
  43872. resolution?: number;
  43873. size?: number;
  43874. useDirectMapping?: boolean;
  43875. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43876. /**
  43877. * Releases resources associated with this node.
  43878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43880. */
  43881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43882. }
  43883. }
  43884. declare module "babylonjs/Misc/textureTools" {
  43885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43886. import { Texture } from "babylonjs/Materials/Textures/texture";
  43887. import { Scene } from "babylonjs/scene";
  43888. /**
  43889. * Class used to host texture specific utilities
  43890. */
  43891. export class TextureTools {
  43892. /**
  43893. * Uses the GPU to create a copy texture rescaled at a given size
  43894. * @param texture Texture to copy from
  43895. * @param width defines the desired width
  43896. * @param height defines the desired height
  43897. * @param useBilinearMode defines if bilinear mode has to be used
  43898. * @return the generated texture
  43899. */
  43900. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43901. /**
  43902. * Gets an environment BRDF texture for a given scene
  43903. * @param scene defines the hosting scene
  43904. * @returns the environment BRDF texture
  43905. */
  43906. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43907. private static _environmentBRDFBase64Texture;
  43908. }
  43909. }
  43910. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  43911. import { Nullable } from "babylonjs/types";
  43912. import { IAnimatable } from "babylonjs/Misc/tools";
  43913. import { Color3 } from "babylonjs/Maths/math";
  43914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43915. import { EffectFallbacks } from "babylonjs/Materials/effect";
  43916. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43917. import { Engine } from "babylonjs/Engines/engine";
  43918. import { Scene } from "babylonjs/scene";
  43919. /**
  43920. * @hidden
  43921. */
  43922. export interface IMaterialClearCoatDefines {
  43923. CLEARCOAT: boolean;
  43924. CLEARCOAT_DEFAULTIOR: boolean;
  43925. CLEARCOAT_TEXTURE: boolean;
  43926. CLEARCOAT_TEXTUREDIRECTUV: number;
  43927. CLEARCOAT_BUMP: boolean;
  43928. CLEARCOAT_BUMPDIRECTUV: number;
  43929. CLEARCOAT_TINT: boolean;
  43930. CLEARCOAT_TINT_TEXTURE: boolean;
  43931. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43932. /** @hidden */
  43933. _areTexturesDirty: boolean;
  43934. }
  43935. /**
  43936. * Define the code related to the clear coat parameters of the pbr material.
  43937. */
  43938. export class PBRClearCoatConfiguration {
  43939. /**
  43940. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43941. * The default fits with a polyurethane material.
  43942. */
  43943. private static readonly _DefaultIndiceOfRefraction;
  43944. private _isEnabled;
  43945. /**
  43946. * Defines if the clear coat is enabled in the material.
  43947. */
  43948. isEnabled: boolean;
  43949. /**
  43950. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43951. */
  43952. intensity: number;
  43953. /**
  43954. * Defines the clear coat layer roughness.
  43955. */
  43956. roughness: number;
  43957. private _indiceOfRefraction;
  43958. /**
  43959. * Defines the indice of refraction of the clear coat.
  43960. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43961. * The default fits with a polyurethane material.
  43962. * Changing the default value is more performance intensive.
  43963. */
  43964. indiceOfRefraction: number;
  43965. private _texture;
  43966. /**
  43967. * Stores the clear coat values in a texture.
  43968. */
  43969. texture: Nullable<BaseTexture>;
  43970. private _bumpTexture;
  43971. /**
  43972. * Define the clear coat specific bump texture.
  43973. */
  43974. bumpTexture: Nullable<BaseTexture>;
  43975. private _isTintEnabled;
  43976. /**
  43977. * Defines if the clear coat tint is enabled in the material.
  43978. */
  43979. isTintEnabled: boolean;
  43980. /**
  43981. * Defines if the clear coat tint is enabled in the material.
  43982. * This is only use if tint is enabled
  43983. */
  43984. tintColor: Color3;
  43985. /**
  43986. * Defines if the distance at which the tint color should be found in the
  43987. * clear coat media.
  43988. * This is only use if tint is enabled
  43989. */
  43990. tintColorAtDistance: number;
  43991. /**
  43992. * Defines the clear coat layer thickness.
  43993. * This is only use if tint is enabled
  43994. */
  43995. tintThickness: number;
  43996. private _tintTexture;
  43997. /**
  43998. * Stores the clear tint values in a texture.
  43999. * rgb is tint
  44000. * a is a thickness factor
  44001. */
  44002. tintTexture: Nullable<BaseTexture>;
  44003. /** @hidden */
  44004. private _internalMarkAllSubMeshesAsTexturesDirty;
  44005. /** @hidden */
  44006. _markAllSubMeshesAsTexturesDirty(): void;
  44007. /**
  44008. * Instantiate a new istance of clear coat configuration.
  44009. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44010. */
  44011. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44012. /**
  44013. * Specifies that the submesh is ready to be used.
  44014. * @param defines the list of "defines" to update.
  44015. * @param scene defines the scene the material belongs to.
  44016. * @param engine defines the engine the material belongs to.
  44017. * @param disableBumpMap defines wether the material disables bump or not.
  44018. * @returns - boolean indicating that the submesh is ready or not.
  44019. */
  44020. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44021. /**
  44022. * Checks to see if a texture is used in the material.
  44023. * @param defines the list of "defines" to update.
  44024. * @param scene defines the scene to the material belongs to.
  44025. */
  44026. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44027. /**
  44028. * Binds the material data.
  44029. * @param uniformBuffer defines the Uniform buffer to fill in.
  44030. * @param scene defines the scene the material belongs to.
  44031. * @param engine defines the engine the material belongs to.
  44032. * @param disableBumpMap defines wether the material disables bump or not.
  44033. * @param isFrozen defines wether the material is frozen or not.
  44034. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44035. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44036. */
  44037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44038. /**
  44039. * Checks to see if a texture is used in the material.
  44040. * @param texture - Base texture to use.
  44041. * @returns - Boolean specifying if a texture is used in the material.
  44042. */
  44043. hasTexture(texture: BaseTexture): boolean;
  44044. /**
  44045. * Returns an array of the actively used textures.
  44046. * @param activeTextures Array of BaseTextures
  44047. */
  44048. getActiveTextures(activeTextures: BaseTexture[]): void;
  44049. /**
  44050. * Returns the animatable textures.
  44051. * @param animatables Array of animatable textures.
  44052. */
  44053. getAnimatables(animatables: IAnimatable[]): void;
  44054. /**
  44055. * Disposes the resources of the material.
  44056. * @param forceDisposeTextures - Forces the disposal of all textures.
  44057. */
  44058. dispose(forceDisposeTextures?: boolean): void;
  44059. /**
  44060. * Get the current class name of the texture useful for serialization or dynamic coding.
  44061. * @returns "PBRClearCoatConfiguration"
  44062. */
  44063. getClassName(): string;
  44064. /**
  44065. * Makes a duplicate of the current configuration into another one.
  44066. * @param clearCoatConfiguration define the config where to copy the info
  44067. */
  44068. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44069. /**
  44070. * Serializes this clear coat configuration.
  44071. * @returns - An object with the serialized config.
  44072. */
  44073. serialize(): any;
  44074. /**
  44075. * Parses a Clear Coat Configuration from a serialized object.
  44076. * @param source - Serialized object.
  44077. */
  44078. parse(source: any): void;
  44079. /**
  44080. * Add fallbacks to the effect fallbacks list.
  44081. * @param defines defines the Base texture to use.
  44082. * @param fallbacks defines the current fallback list.
  44083. * @param currentRank defines the current fallback rank.
  44084. * @returns the new fallback rank.
  44085. */
  44086. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44087. /**
  44088. * Add the required uniforms to the current list.
  44089. * @param uniforms defines the current uniform list.
  44090. */
  44091. static AddUniforms(uniforms: string[]): void;
  44092. /**
  44093. * Add the required samplers to the current list.
  44094. * @param samplers defines the current sampler list.
  44095. */
  44096. static AddSamplers(samplers: string[]): void;
  44097. /**
  44098. * Add the required uniforms to the current buffer.
  44099. * @param uniformBuffer defines the current uniform buffer.
  44100. */
  44101. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44102. }
  44103. }
  44104. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44105. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44108. /**
  44109. * @hidden
  44110. */
  44111. export interface IMaterialAnisotropicDefines {
  44112. ANISOTROPIC: boolean;
  44113. MAINUV1: boolean;
  44114. _areMiscDirty: boolean;
  44115. _needUVs: boolean;
  44116. }
  44117. /**
  44118. * Define the code related to the anisotropic parameters of the pbr material.
  44119. */
  44120. export class PBRAnisotropicConfiguration {
  44121. private _isEnabled;
  44122. /**
  44123. * Defines if the anisotropy is enabled in the material.
  44124. */
  44125. isEnabled: boolean;
  44126. /**
  44127. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44128. */
  44129. intensity: number;
  44130. /**
  44131. * Defines if the effect is along the tangents or bitangents.
  44132. * By default, the effect is "strectching" the highlights along the tangents.
  44133. */
  44134. followTangents: boolean;
  44135. /** @hidden */
  44136. private _internalMarkAllSubMeshesAsMiscDirty;
  44137. /** @hidden */
  44138. _markAllSubMeshesAsMiscDirty(): void;
  44139. /**
  44140. * Instantiate a new istance of clear coat configuration.
  44141. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44142. */
  44143. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44144. /**
  44145. * Checks to see if a texture is used in the material.
  44146. * @param defines the list of "defines" to update.
  44147. * @param mesh the mesh we are preparing the defines for.
  44148. */
  44149. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44150. /**
  44151. * Binds the material data.
  44152. * @param uniformBuffer defines the Uniform buffer to fill in.
  44153. * @param isFrozen defines wether the material is frozen or not.
  44154. */
  44155. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44156. /**
  44157. * Get the current class name of the texture useful for serialization or dynamic coding.
  44158. * @returns "PBRAnisotropicConfiguration"
  44159. */
  44160. getClassName(): string;
  44161. /**
  44162. * Makes a duplicate of the current configuration into another one.
  44163. * @param anisotropicConfiguration define the config where to copy the info
  44164. */
  44165. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44166. /**
  44167. * Serializes this clear coat configuration.
  44168. * @returns - An object with the serialized config.
  44169. */
  44170. serialize(): any;
  44171. /**
  44172. * Parses a Clear Coat Configuration from a serialized object.
  44173. * @param source - Serialized object.
  44174. */
  44175. parse(source: any): void;
  44176. /**
  44177. * Add fallbacks to the effect fallbacks list.
  44178. * @param defines defines the Base texture to use.
  44179. * @param fallbacks defines the current fallback list.
  44180. * @param currentRank defines the current fallback rank.
  44181. * @returns the new fallback rank.
  44182. */
  44183. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44184. /**
  44185. * Add the required uniforms to the current list.
  44186. * @param uniforms defines the current uniform list.
  44187. */
  44188. static AddUniforms(uniforms: string[]): void;
  44189. /**
  44190. * Add the required uniforms to the current buffer.
  44191. * @param uniformBuffer defines the current uniform buffer.
  44192. */
  44193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44194. }
  44195. }
  44196. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44197. /** @hidden */
  44198. export var pbrFragmentDeclaration: {
  44199. name: string;
  44200. shader: string;
  44201. };
  44202. }
  44203. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44204. /** @hidden */
  44205. export var pbrUboDeclaration: {
  44206. name: string;
  44207. shader: string;
  44208. };
  44209. }
  44210. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44211. /** @hidden */
  44212. export var pbrFunctions: {
  44213. name: string;
  44214. shader: string;
  44215. };
  44216. }
  44217. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44218. /** @hidden */
  44219. export var harmonicsFunctions: {
  44220. name: string;
  44221. shader: string;
  44222. };
  44223. }
  44224. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44225. /** @hidden */
  44226. export var pbrPreLightingFunctions: {
  44227. name: string;
  44228. shader: string;
  44229. };
  44230. }
  44231. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44232. /** @hidden */
  44233. export var pbrFalloffLightingFunctions: {
  44234. name: string;
  44235. shader: string;
  44236. };
  44237. }
  44238. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44239. /** @hidden */
  44240. export var pbrLightingFunctions: {
  44241. name: string;
  44242. shader: string;
  44243. };
  44244. }
  44245. declare module "babylonjs/Shaders/pbr.fragment" {
  44246. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44247. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44248. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44249. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44250. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44251. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44252. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44253. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44254. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44255. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44256. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44257. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44258. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44259. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44260. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44261. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44262. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44263. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44264. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44265. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44266. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44267. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44268. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44269. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44270. /** @hidden */
  44271. export var pbrPixelShader: {
  44272. name: string;
  44273. shader: string;
  44274. };
  44275. }
  44276. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44277. /** @hidden */
  44278. export var pbrVertexDeclaration: {
  44279. name: string;
  44280. shader: string;
  44281. };
  44282. }
  44283. declare module "babylonjs/Shaders/pbr.vertex" {
  44284. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44285. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44286. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44287. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44288. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44289. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44290. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44291. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44292. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44293. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44294. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44295. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44297. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44299. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44300. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44301. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44302. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44303. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44304. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44305. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44306. /** @hidden */
  44307. export var pbrVertexShader: {
  44308. name: string;
  44309. shader: string;
  44310. };
  44311. }
  44312. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44313. import { IAnimatable } from "babylonjs/Misc/tools";
  44314. import { Nullable } from "babylonjs/types";
  44315. import { Scene } from "babylonjs/scene";
  44316. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44317. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44319. import { Mesh } from "babylonjs/Meshes/mesh";
  44320. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44321. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44322. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44323. import { Material } from "babylonjs/Materials/material";
  44324. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44326. import "babylonjs/Shaders/pbr.fragment";
  44327. import "babylonjs/Shaders/pbr.vertex";
  44328. /**
  44329. * The Physically based material base class of BJS.
  44330. *
  44331. * This offers the main features of a standard PBR material.
  44332. * For more information, please refer to the documentation :
  44333. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44334. */
  44335. export abstract class PBRBaseMaterial extends PushMaterial {
  44336. /**
  44337. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44338. */
  44339. static readonly PBRMATERIAL_OPAQUE: number;
  44340. /**
  44341. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44342. */
  44343. static readonly PBRMATERIAL_ALPHATEST: number;
  44344. /**
  44345. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44346. */
  44347. static readonly PBRMATERIAL_ALPHABLEND: number;
  44348. /**
  44349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44350. * They are also discarded below the alpha cutoff threshold to improve performances.
  44351. */
  44352. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44353. /**
  44354. * Defines the default value of how much AO map is occluding the analytical lights
  44355. * (point spot...).
  44356. */
  44357. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44358. /**
  44359. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44360. */
  44361. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44362. /**
  44363. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44364. * to enhance interoperability with other engines.
  44365. */
  44366. static readonly LIGHTFALLOFF_GLTF: number;
  44367. /**
  44368. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44369. * to enhance interoperability with other materials.
  44370. */
  44371. static readonly LIGHTFALLOFF_STANDARD: number;
  44372. /**
  44373. * Intensity of the direct lights e.g. the four lights available in your scene.
  44374. * This impacts both the direct diffuse and specular highlights.
  44375. */
  44376. protected _directIntensity: number;
  44377. /**
  44378. * Intensity of the emissive part of the material.
  44379. * This helps controlling the emissive effect without modifying the emissive color.
  44380. */
  44381. protected _emissiveIntensity: number;
  44382. /**
  44383. * Intensity of the environment e.g. how much the environment will light the object
  44384. * either through harmonics for rough material or through the refelction for shiny ones.
  44385. */
  44386. protected _environmentIntensity: number;
  44387. /**
  44388. * This is a special control allowing the reduction of the specular highlights coming from the
  44389. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44390. */
  44391. protected _specularIntensity: number;
  44392. /**
  44393. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44394. */
  44395. private _lightingInfos;
  44396. /**
  44397. * Debug Control allowing disabling the bump map on this material.
  44398. */
  44399. protected _disableBumpMap: boolean;
  44400. /**
  44401. * AKA Diffuse Texture in standard nomenclature.
  44402. */
  44403. protected _albedoTexture: BaseTexture;
  44404. /**
  44405. * AKA Occlusion Texture in other nomenclature.
  44406. */
  44407. protected _ambientTexture: BaseTexture;
  44408. /**
  44409. * AKA Occlusion Texture Intensity in other nomenclature.
  44410. */
  44411. protected _ambientTextureStrength: number;
  44412. /**
  44413. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44414. * 1 means it completely occludes it
  44415. * 0 mean it has no impact
  44416. */
  44417. protected _ambientTextureImpactOnAnalyticalLights: number;
  44418. /**
  44419. * Stores the alpha values in a texture.
  44420. */
  44421. protected _opacityTexture: BaseTexture;
  44422. /**
  44423. * Stores the reflection values in a texture.
  44424. */
  44425. protected _reflectionTexture: BaseTexture;
  44426. /**
  44427. * Stores the refraction values in a texture.
  44428. */
  44429. protected _refractionTexture: BaseTexture;
  44430. /**
  44431. * Stores the emissive values in a texture.
  44432. */
  44433. protected _emissiveTexture: BaseTexture;
  44434. /**
  44435. * AKA Specular texture in other nomenclature.
  44436. */
  44437. protected _reflectivityTexture: BaseTexture;
  44438. /**
  44439. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44440. */
  44441. protected _metallicTexture: BaseTexture;
  44442. /**
  44443. * Specifies the metallic scalar of the metallic/roughness workflow.
  44444. * Can also be used to scale the metalness values of the metallic texture.
  44445. */
  44446. protected _metallic: Nullable<number>;
  44447. /**
  44448. * Specifies the roughness scalar of the metallic/roughness workflow.
  44449. * Can also be used to scale the roughness values of the metallic texture.
  44450. */
  44451. protected _roughness: Nullable<number>;
  44452. /**
  44453. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44454. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44455. */
  44456. protected _microSurfaceTexture: BaseTexture;
  44457. /**
  44458. * Stores surface normal data used to displace a mesh in a texture.
  44459. */
  44460. protected _bumpTexture: BaseTexture;
  44461. /**
  44462. * Stores the pre-calculated light information of a mesh in a texture.
  44463. */
  44464. protected _lightmapTexture: BaseTexture;
  44465. /**
  44466. * The color of a material in ambient lighting.
  44467. */
  44468. protected _ambientColor: Color3;
  44469. /**
  44470. * AKA Diffuse Color in other nomenclature.
  44471. */
  44472. protected _albedoColor: Color3;
  44473. /**
  44474. * AKA Specular Color in other nomenclature.
  44475. */
  44476. protected _reflectivityColor: Color3;
  44477. /**
  44478. * The color applied when light is reflected from a material.
  44479. */
  44480. protected _reflectionColor: Color3;
  44481. /**
  44482. * The color applied when light is emitted from a material.
  44483. */
  44484. protected _emissiveColor: Color3;
  44485. /**
  44486. * AKA Glossiness in other nomenclature.
  44487. */
  44488. protected _microSurface: number;
  44489. /**
  44490. * source material index of refraction (IOR)' / 'destination material IOR.
  44491. */
  44492. protected _indexOfRefraction: number;
  44493. /**
  44494. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44495. */
  44496. protected _invertRefractionY: boolean;
  44497. /**
  44498. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44499. * Materials half opaque for instance using refraction could benefit from this control.
  44500. */
  44501. protected _linkRefractionWithTransparency: boolean;
  44502. /**
  44503. * Specifies that the material will use the light map as a show map.
  44504. */
  44505. protected _useLightmapAsShadowmap: boolean;
  44506. /**
  44507. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44508. * makes the reflect vector face the model (under horizon).
  44509. */
  44510. protected _useHorizonOcclusion: boolean;
  44511. /**
  44512. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44513. * too much the area relying on ambient texture to define their ambient occlusion.
  44514. */
  44515. protected _useRadianceOcclusion: boolean;
  44516. /**
  44517. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44518. */
  44519. protected _useAlphaFromAlbedoTexture: boolean;
  44520. /**
  44521. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44522. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44523. */
  44524. protected _useSpecularOverAlpha: boolean;
  44525. /**
  44526. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44527. */
  44528. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44529. /**
  44530. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44531. */
  44532. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44533. /**
  44534. * Specifies if the metallic texture contains the roughness information in its green channel.
  44535. */
  44536. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44537. /**
  44538. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44539. */
  44540. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44541. /**
  44542. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44543. */
  44544. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44545. /**
  44546. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44547. */
  44548. protected _useAmbientInGrayScale: boolean;
  44549. /**
  44550. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44551. * The material will try to infer what glossiness each pixel should be.
  44552. */
  44553. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44554. /**
  44555. * Defines the falloff type used in this material.
  44556. * It by default is Physical.
  44557. */
  44558. protected _lightFalloff: number;
  44559. /**
  44560. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44561. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44562. */
  44563. protected _useRadianceOverAlpha: boolean;
  44564. /**
  44565. * Allows using an object space normal map (instead of tangent space).
  44566. */
  44567. protected _useObjectSpaceNormalMap: boolean;
  44568. /**
  44569. * Allows using the bump map in parallax mode.
  44570. */
  44571. protected _useParallax: boolean;
  44572. /**
  44573. * Allows using the bump map in parallax occlusion mode.
  44574. */
  44575. protected _useParallaxOcclusion: boolean;
  44576. /**
  44577. * Controls the scale bias of the parallax mode.
  44578. */
  44579. protected _parallaxScaleBias: number;
  44580. /**
  44581. * If sets to true, disables all the lights affecting the material.
  44582. */
  44583. protected _disableLighting: boolean;
  44584. /**
  44585. * Number of Simultaneous lights allowed on the material.
  44586. */
  44587. protected _maxSimultaneousLights: number;
  44588. /**
  44589. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44590. */
  44591. protected _invertNormalMapX: boolean;
  44592. /**
  44593. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44594. */
  44595. protected _invertNormalMapY: boolean;
  44596. /**
  44597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44598. */
  44599. protected _twoSidedLighting: boolean;
  44600. /**
  44601. * Defines the alpha limits in alpha test mode.
  44602. */
  44603. protected _alphaCutOff: number;
  44604. /**
  44605. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44606. */
  44607. protected _forceAlphaTest: boolean;
  44608. /**
  44609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44610. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44611. */
  44612. protected _useAlphaFresnel: boolean;
  44613. /**
  44614. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44615. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44616. */
  44617. protected _useLinearAlphaFresnel: boolean;
  44618. /**
  44619. * The transparency mode of the material.
  44620. */
  44621. protected _transparencyMode: Nullable<number>;
  44622. /**
  44623. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44624. * from cos thetav and roughness:
  44625. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44626. */
  44627. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44628. /**
  44629. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44630. */
  44631. protected _forceIrradianceInFragment: boolean;
  44632. /**
  44633. * Force normal to face away from face.
  44634. */
  44635. protected _forceNormalForward: boolean;
  44636. /**
  44637. * Enables specular anti aliasing in the PBR shader.
  44638. * It will both interacts on the Geometry for analytical and IBL lighting.
  44639. * It also prefilter the roughness map based on the bump values.
  44640. */
  44641. protected _enableSpecularAntiAliasing: boolean;
  44642. /**
  44643. * Default configuration related to image processing available in the PBR Material.
  44644. */
  44645. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44646. /**
  44647. * Keep track of the image processing observer to allow dispose and replace.
  44648. */
  44649. private _imageProcessingObserver;
  44650. /**
  44651. * Attaches a new image processing configuration to the PBR Material.
  44652. * @param configuration
  44653. */
  44654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44655. /**
  44656. * Stores the available render targets.
  44657. */
  44658. private _renderTargets;
  44659. /**
  44660. * Sets the global ambient color for the material used in lighting calculations.
  44661. */
  44662. private _globalAmbientColor;
  44663. /**
  44664. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44665. */
  44666. private _useLogarithmicDepth;
  44667. /**
  44668. * If set to true, no lighting calculations will be applied.
  44669. */
  44670. private _unlit;
  44671. /**
  44672. * Defines the clear coat layer parameters for the material.
  44673. */
  44674. readonly clearCoat: PBRClearCoatConfiguration;
  44675. /**
  44676. * Defines the anisotropic parameters for the material.
  44677. */
  44678. readonly anisotropy: PBRAnisotropicConfiguration;
  44679. /**
  44680. * Instantiates a new PBRMaterial instance.
  44681. *
  44682. * @param name The material name
  44683. * @param scene The scene the material will be use in.
  44684. */
  44685. constructor(name: string, scene: Scene);
  44686. /**
  44687. * Gets a boolean indicating that current material needs to register RTT
  44688. */
  44689. readonly hasRenderTargetTextures: boolean;
  44690. /**
  44691. * Gets the name of the material class.
  44692. */
  44693. getClassName(): string;
  44694. /**
  44695. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44696. */
  44697. /**
  44698. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44699. */
  44700. useLogarithmicDepth: boolean;
  44701. /**
  44702. * Gets the current transparency mode.
  44703. */
  44704. /**
  44705. * Sets the transparency mode of the material.
  44706. *
  44707. * | Value | Type | Description |
  44708. * | ----- | ----------------------------------- | ----------- |
  44709. * | 0 | OPAQUE | |
  44710. * | 1 | ALPHATEST | |
  44711. * | 2 | ALPHABLEND | |
  44712. * | 3 | ALPHATESTANDBLEND | |
  44713. *
  44714. */
  44715. transparencyMode: Nullable<number>;
  44716. /**
  44717. * Returns true if alpha blending should be disabled.
  44718. */
  44719. private readonly _disableAlphaBlending;
  44720. /**
  44721. * Specifies whether or not this material should be rendered in alpha blend mode.
  44722. */
  44723. needAlphaBlending(): boolean;
  44724. /**
  44725. * Specifies if the mesh will require alpha blending.
  44726. * @param mesh - BJS mesh.
  44727. */
  44728. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44729. /**
  44730. * Specifies whether or not this material should be rendered in alpha test mode.
  44731. */
  44732. needAlphaTesting(): boolean;
  44733. /**
  44734. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44735. */
  44736. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44737. /**
  44738. * Gets the texture used for the alpha test.
  44739. */
  44740. getAlphaTestTexture(): BaseTexture;
  44741. /**
  44742. * Specifies that the submesh is ready to be used.
  44743. * @param mesh - BJS mesh.
  44744. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44745. * @param useInstances - Specifies that instances should be used.
  44746. * @returns - boolean indicating that the submesh is ready or not.
  44747. */
  44748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44749. /**
  44750. * Specifies if the material uses metallic roughness workflow.
  44751. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44752. */
  44753. isMetallicWorkflow(): boolean;
  44754. private _prepareEffect;
  44755. private _prepareDefines;
  44756. /**
  44757. * Force shader compilation
  44758. */
  44759. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44760. clipPlane: boolean;
  44761. }>): void;
  44762. /**
  44763. * Initializes the uniform buffer layout for the shader.
  44764. */
  44765. buildUniformLayout(): void;
  44766. /**
  44767. * Unbinds the textures.
  44768. */
  44769. unbind(): void;
  44770. /**
  44771. * Binds the submesh data.
  44772. * @param world - The world matrix.
  44773. * @param mesh - The BJS mesh.
  44774. * @param subMesh - A submesh of the BJS mesh.
  44775. */
  44776. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44777. /**
  44778. * Returns the animatable textures.
  44779. * @returns - Array of animatable textures.
  44780. */
  44781. getAnimatables(): IAnimatable[];
  44782. /**
  44783. * Returns the texture used for reflections.
  44784. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44785. */
  44786. private _getReflectionTexture;
  44787. /**
  44788. * Returns the texture used for refraction or null if none is used.
  44789. * @returns - Refection texture if present. If no refraction texture and refraction
  44790. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44791. */
  44792. private _getRefractionTexture;
  44793. /**
  44794. * Returns an array of the actively used textures.
  44795. * @returns - Array of BaseTextures
  44796. */
  44797. getActiveTextures(): BaseTexture[];
  44798. /**
  44799. * Checks to see if a texture is used in the material.
  44800. * @param texture - Base texture to use.
  44801. * @returns - Boolean specifying if a texture is used in the material.
  44802. */
  44803. hasTexture(texture: BaseTexture): boolean;
  44804. /**
  44805. * Disposes the resources of the material.
  44806. * @param forceDisposeEffect - Forces the disposal of effects.
  44807. * @param forceDisposeTextures - Forces the disposal of all textures.
  44808. */
  44809. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44810. }
  44811. }
  44812. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44813. import { Nullable } from "babylonjs/types";
  44814. import { Scene } from "babylonjs/scene";
  44815. import { Color3 } from "babylonjs/Maths/math";
  44816. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44817. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44819. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44820. /**
  44821. * The Physically based material of BJS.
  44822. *
  44823. * This offers the main features of a standard PBR material.
  44824. * For more information, please refer to the documentation :
  44825. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44826. */
  44827. export class PBRMaterial extends PBRBaseMaterial {
  44828. /**
  44829. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44830. */
  44831. static readonly PBRMATERIAL_OPAQUE: number;
  44832. /**
  44833. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44834. */
  44835. static readonly PBRMATERIAL_ALPHATEST: number;
  44836. /**
  44837. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44838. */
  44839. static readonly PBRMATERIAL_ALPHABLEND: number;
  44840. /**
  44841. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44842. * They are also discarded below the alpha cutoff threshold to improve performances.
  44843. */
  44844. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44845. /**
  44846. * Defines the default value of how much AO map is occluding the analytical lights
  44847. * (point spot...).
  44848. */
  44849. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44850. /**
  44851. * Intensity of the direct lights e.g. the four lights available in your scene.
  44852. * This impacts both the direct diffuse and specular highlights.
  44853. */
  44854. directIntensity: number;
  44855. /**
  44856. * Intensity of the emissive part of the material.
  44857. * This helps controlling the emissive effect without modifying the emissive color.
  44858. */
  44859. emissiveIntensity: number;
  44860. /**
  44861. * Intensity of the environment e.g. how much the environment will light the object
  44862. * either through harmonics for rough material or through the refelction for shiny ones.
  44863. */
  44864. environmentIntensity: number;
  44865. /**
  44866. * This is a special control allowing the reduction of the specular highlights coming from the
  44867. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44868. */
  44869. specularIntensity: number;
  44870. /**
  44871. * Debug Control allowing disabling the bump map on this material.
  44872. */
  44873. disableBumpMap: boolean;
  44874. /**
  44875. * AKA Diffuse Texture in standard nomenclature.
  44876. */
  44877. albedoTexture: BaseTexture;
  44878. /**
  44879. * AKA Occlusion Texture in other nomenclature.
  44880. */
  44881. ambientTexture: BaseTexture;
  44882. /**
  44883. * AKA Occlusion Texture Intensity in other nomenclature.
  44884. */
  44885. ambientTextureStrength: number;
  44886. /**
  44887. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44888. * 1 means it completely occludes it
  44889. * 0 mean it has no impact
  44890. */
  44891. ambientTextureImpactOnAnalyticalLights: number;
  44892. /**
  44893. * Stores the alpha values in a texture.
  44894. */
  44895. opacityTexture: BaseTexture;
  44896. /**
  44897. * Stores the reflection values in a texture.
  44898. */
  44899. reflectionTexture: Nullable<BaseTexture>;
  44900. /**
  44901. * Stores the emissive values in a texture.
  44902. */
  44903. emissiveTexture: BaseTexture;
  44904. /**
  44905. * AKA Specular texture in other nomenclature.
  44906. */
  44907. reflectivityTexture: BaseTexture;
  44908. /**
  44909. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44910. */
  44911. metallicTexture: BaseTexture;
  44912. /**
  44913. * Specifies the metallic scalar of the metallic/roughness workflow.
  44914. * Can also be used to scale the metalness values of the metallic texture.
  44915. */
  44916. metallic: Nullable<number>;
  44917. /**
  44918. * Specifies the roughness scalar of the metallic/roughness workflow.
  44919. * Can also be used to scale the roughness values of the metallic texture.
  44920. */
  44921. roughness: Nullable<number>;
  44922. /**
  44923. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44924. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44925. */
  44926. microSurfaceTexture: BaseTexture;
  44927. /**
  44928. * Stores surface normal data used to displace a mesh in a texture.
  44929. */
  44930. bumpTexture: BaseTexture;
  44931. /**
  44932. * Stores the pre-calculated light information of a mesh in a texture.
  44933. */
  44934. lightmapTexture: BaseTexture;
  44935. /**
  44936. * Stores the refracted light information in a texture.
  44937. */
  44938. refractionTexture: BaseTexture;
  44939. /**
  44940. * The color of a material in ambient lighting.
  44941. */
  44942. ambientColor: Color3;
  44943. /**
  44944. * AKA Diffuse Color in other nomenclature.
  44945. */
  44946. albedoColor: Color3;
  44947. /**
  44948. * AKA Specular Color in other nomenclature.
  44949. */
  44950. reflectivityColor: Color3;
  44951. /**
  44952. * The color reflected from the material.
  44953. */
  44954. reflectionColor: Color3;
  44955. /**
  44956. * The color emitted from the material.
  44957. */
  44958. emissiveColor: Color3;
  44959. /**
  44960. * AKA Glossiness in other nomenclature.
  44961. */
  44962. microSurface: number;
  44963. /**
  44964. * source material index of refraction (IOR)' / 'destination material IOR.
  44965. */
  44966. indexOfRefraction: number;
  44967. /**
  44968. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44969. */
  44970. invertRefractionY: boolean;
  44971. /**
  44972. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44973. * Materials half opaque for instance using refraction could benefit from this control.
  44974. */
  44975. linkRefractionWithTransparency: boolean;
  44976. /**
  44977. * If true, the light map contains occlusion information instead of lighting info.
  44978. */
  44979. useLightmapAsShadowmap: boolean;
  44980. /**
  44981. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44982. */
  44983. useAlphaFromAlbedoTexture: boolean;
  44984. /**
  44985. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44986. */
  44987. forceAlphaTest: boolean;
  44988. /**
  44989. * Defines the alpha limits in alpha test mode.
  44990. */
  44991. alphaCutOff: number;
  44992. /**
  44993. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44994. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44995. */
  44996. useSpecularOverAlpha: boolean;
  44997. /**
  44998. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44999. */
  45000. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45001. /**
  45002. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45003. */
  45004. useRoughnessFromMetallicTextureAlpha: boolean;
  45005. /**
  45006. * Specifies if the metallic texture contains the roughness information in its green channel.
  45007. */
  45008. useRoughnessFromMetallicTextureGreen: boolean;
  45009. /**
  45010. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45011. */
  45012. useMetallnessFromMetallicTextureBlue: boolean;
  45013. /**
  45014. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45015. */
  45016. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45017. /**
  45018. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45019. */
  45020. useAmbientInGrayScale: boolean;
  45021. /**
  45022. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45023. * The material will try to infer what glossiness each pixel should be.
  45024. */
  45025. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45026. /**
  45027. * BJS is using an harcoded light falloff based on a manually sets up range.
  45028. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45029. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45030. */
  45031. /**
  45032. * BJS is using an harcoded light falloff based on a manually sets up range.
  45033. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45034. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45035. */
  45036. usePhysicalLightFalloff: boolean;
  45037. /**
  45038. * In order to support the falloff compatibility with gltf, a special mode has been added
  45039. * to reproduce the gltf light falloff.
  45040. */
  45041. /**
  45042. * In order to support the falloff compatibility with gltf, a special mode has been added
  45043. * to reproduce the gltf light falloff.
  45044. */
  45045. useGLTFLightFalloff: boolean;
  45046. /**
  45047. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45048. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45049. */
  45050. useRadianceOverAlpha: boolean;
  45051. /**
  45052. * Allows using an object space normal map (instead of tangent space).
  45053. */
  45054. useObjectSpaceNormalMap: boolean;
  45055. /**
  45056. * Allows using the bump map in parallax mode.
  45057. */
  45058. useParallax: boolean;
  45059. /**
  45060. * Allows using the bump map in parallax occlusion mode.
  45061. */
  45062. useParallaxOcclusion: boolean;
  45063. /**
  45064. * Controls the scale bias of the parallax mode.
  45065. */
  45066. parallaxScaleBias: number;
  45067. /**
  45068. * If sets to true, disables all the lights affecting the material.
  45069. */
  45070. disableLighting: boolean;
  45071. /**
  45072. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45073. */
  45074. forceIrradianceInFragment: boolean;
  45075. /**
  45076. * Number of Simultaneous lights allowed on the material.
  45077. */
  45078. maxSimultaneousLights: number;
  45079. /**
  45080. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45081. */
  45082. invertNormalMapX: boolean;
  45083. /**
  45084. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45085. */
  45086. invertNormalMapY: boolean;
  45087. /**
  45088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45089. */
  45090. twoSidedLighting: boolean;
  45091. /**
  45092. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45093. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45094. */
  45095. useAlphaFresnel: boolean;
  45096. /**
  45097. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45098. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45099. */
  45100. useLinearAlphaFresnel: boolean;
  45101. /**
  45102. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45103. * And/Or occlude the blended part.
  45104. */
  45105. environmentBRDFTexture: Nullable<BaseTexture>;
  45106. /**
  45107. * Force normal to face away from face.
  45108. */
  45109. forceNormalForward: boolean;
  45110. /**
  45111. * Enables specular anti aliasing in the PBR shader.
  45112. * It will both interacts on the Geometry for analytical and IBL lighting.
  45113. * It also prefilter the roughness map based on the bump values.
  45114. */
  45115. enableSpecularAntiAliasing: boolean;
  45116. /**
  45117. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45118. * makes the reflect vector face the model (under horizon).
  45119. */
  45120. useHorizonOcclusion: boolean;
  45121. /**
  45122. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45123. * too much the area relying on ambient texture to define their ambient occlusion.
  45124. */
  45125. useRadianceOcclusion: boolean;
  45126. /**
  45127. * If set to true, no lighting calculations will be applied.
  45128. */
  45129. unlit: boolean;
  45130. /**
  45131. * Gets the image processing configuration used either in this material.
  45132. */
  45133. /**
  45134. * Sets the Default image processing configuration used either in the this material.
  45135. *
  45136. * If sets to null, the scene one is in use.
  45137. */
  45138. imageProcessingConfiguration: ImageProcessingConfiguration;
  45139. /**
  45140. * Gets wether the color curves effect is enabled.
  45141. */
  45142. /**
  45143. * Sets wether the color curves effect is enabled.
  45144. */
  45145. cameraColorCurvesEnabled: boolean;
  45146. /**
  45147. * Gets wether the color grading effect is enabled.
  45148. */
  45149. /**
  45150. * Gets wether the color grading effect is enabled.
  45151. */
  45152. cameraColorGradingEnabled: boolean;
  45153. /**
  45154. * Gets wether tonemapping is enabled or not.
  45155. */
  45156. /**
  45157. * Sets wether tonemapping is enabled or not
  45158. */
  45159. cameraToneMappingEnabled: boolean;
  45160. /**
  45161. * The camera exposure used on this material.
  45162. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45163. * This corresponds to a photographic exposure.
  45164. */
  45165. /**
  45166. * The camera exposure used on this material.
  45167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45168. * This corresponds to a photographic exposure.
  45169. */
  45170. cameraExposure: number;
  45171. /**
  45172. * Gets The camera contrast used on this material.
  45173. */
  45174. /**
  45175. * Sets The camera contrast used on this material.
  45176. */
  45177. cameraContrast: number;
  45178. /**
  45179. * Gets the Color Grading 2D Lookup Texture.
  45180. */
  45181. /**
  45182. * Sets the Color Grading 2D Lookup Texture.
  45183. */
  45184. cameraColorGradingTexture: Nullable<BaseTexture>;
  45185. /**
  45186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45188. * 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;
  45189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45190. */
  45191. /**
  45192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45194. * 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;
  45195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45196. */
  45197. cameraColorCurves: Nullable<ColorCurves>;
  45198. /**
  45199. * Instantiates a new PBRMaterial instance.
  45200. *
  45201. * @param name The material name
  45202. * @param scene The scene the material will be use in.
  45203. */
  45204. constructor(name: string, scene: Scene);
  45205. /**
  45206. * Returns the name of this material class.
  45207. */
  45208. getClassName(): string;
  45209. /**
  45210. * Makes a duplicate of the current material.
  45211. * @param name - name to use for the new material.
  45212. */
  45213. clone(name: string): PBRMaterial;
  45214. /**
  45215. * Serializes this PBR Material.
  45216. * @returns - An object with the serialized material.
  45217. */
  45218. serialize(): any;
  45219. /**
  45220. * Parses a PBR Material from a serialized object.
  45221. * @param source - Serialized object.
  45222. * @param scene - BJS scene instance.
  45223. * @param rootUrl - url for the scene object
  45224. * @returns - PBRMaterial
  45225. */
  45226. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45227. }
  45228. }
  45229. declare module "babylonjs/Helpers/sceneHelpers" {
  45230. import { Nullable } from "babylonjs/types";
  45231. import { Mesh } from "babylonjs/Meshes/mesh";
  45232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45233. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45234. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45235. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45236. import "babylonjs/Meshes/Builders/boxBuilder";
  45237. /** @hidden */
  45238. export var _forceSceneHelpersToBundle: boolean;
  45239. module "babylonjs/scene" {
  45240. interface Scene {
  45241. /**
  45242. * Creates a default light for the scene.
  45243. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45244. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45245. */
  45246. createDefaultLight(replace?: boolean): void;
  45247. /**
  45248. * Creates a default camera for the scene.
  45249. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45250. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45251. * @param replace has default false, when true replaces the active camera in the scene
  45252. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45253. */
  45254. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45255. /**
  45256. * Creates a default camera and a default light.
  45257. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45258. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45259. * @param replace has the default false, when true replaces the active camera/light in the scene
  45260. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45261. */
  45262. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45263. /**
  45264. * Creates a new sky box
  45265. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45266. * @param environmentTexture defines the texture to use as environment texture
  45267. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45268. * @param scale defines the overall scale of the skybox
  45269. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45270. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45271. * @returns a new mesh holding the sky box
  45272. */
  45273. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45274. /**
  45275. * Creates a new environment
  45276. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45277. * @param options defines the options you can use to configure the environment
  45278. * @returns the new EnvironmentHelper
  45279. */
  45280. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45281. /**
  45282. * Creates a new VREXperienceHelper
  45283. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45284. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45285. * @returns a new VREXperienceHelper
  45286. */
  45287. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45288. /**
  45289. * Creates a new XREXperienceHelper
  45290. * @see http://doc.babylonjs.com/how_to/webxr
  45291. * @returns a promise for a new XREXperienceHelper
  45292. */
  45293. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45294. }
  45295. }
  45296. }
  45297. declare module "babylonjs/Helpers/videoDome" {
  45298. import { Scene } from "babylonjs/scene";
  45299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45300. import { Mesh } from "babylonjs/Meshes/mesh";
  45301. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45302. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45303. import "babylonjs/Meshes/Builders/sphereBuilder";
  45304. /**
  45305. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45306. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45307. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45308. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45309. */
  45310. export class VideoDome extends TransformNode {
  45311. private _useDirectMapping;
  45312. /**
  45313. * The video texture being displayed on the sphere
  45314. */
  45315. protected _videoTexture: VideoTexture;
  45316. /**
  45317. * Gets the video texture being displayed on the sphere
  45318. */
  45319. readonly videoTexture: VideoTexture;
  45320. /**
  45321. * The skybox material
  45322. */
  45323. protected _material: BackgroundMaterial;
  45324. /**
  45325. * The surface used for the skybox
  45326. */
  45327. protected _mesh: Mesh;
  45328. /**
  45329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45330. * Also see the options.resolution property.
  45331. */
  45332. fovMultiplier: number;
  45333. /**
  45334. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45335. * @param name Element's name, child elements will append suffixes for their own names.
  45336. * @param urlsOrVideo defines the url(s) or the video element to use
  45337. * @param options An object containing optional or exposed sub element properties
  45338. */
  45339. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45340. resolution?: number;
  45341. clickToPlay?: boolean;
  45342. autoPlay?: boolean;
  45343. loop?: boolean;
  45344. size?: number;
  45345. poster?: string;
  45346. useDirectMapping?: boolean;
  45347. }, scene: Scene);
  45348. /**
  45349. * Releases resources associated with this node.
  45350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45352. */
  45353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45354. }
  45355. }
  45356. declare module "babylonjs/Helpers/index" {
  45357. export * from "babylonjs/Helpers/environmentHelper";
  45358. export * from "babylonjs/Helpers/photoDome";
  45359. export * from "babylonjs/Helpers/sceneHelpers";
  45360. export * from "babylonjs/Helpers/videoDome";
  45361. }
  45362. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45363. import { PerfCounter } from "babylonjs/Misc/tools";
  45364. import { IDisposable } from "babylonjs/scene";
  45365. import { Engine } from "babylonjs/Engines/engine";
  45366. /**
  45367. * This class can be used to get instrumentation data from a Babylon engine
  45368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45369. */
  45370. export class EngineInstrumentation implements IDisposable {
  45371. /**
  45372. * Define the instrumented engine.
  45373. */
  45374. engine: Engine;
  45375. private _captureGPUFrameTime;
  45376. private _gpuFrameTimeToken;
  45377. private _gpuFrameTime;
  45378. private _captureShaderCompilationTime;
  45379. private _shaderCompilationTime;
  45380. private _onBeginFrameObserver;
  45381. private _onEndFrameObserver;
  45382. private _onBeforeShaderCompilationObserver;
  45383. private _onAfterShaderCompilationObserver;
  45384. /**
  45385. * Gets the perf counter used for GPU frame time
  45386. */
  45387. readonly gpuFrameTimeCounter: PerfCounter;
  45388. /**
  45389. * Gets the GPU frame time capture status
  45390. */
  45391. /**
  45392. * Enable or disable the GPU frame time capture
  45393. */
  45394. captureGPUFrameTime: boolean;
  45395. /**
  45396. * Gets the perf counter used for shader compilation time
  45397. */
  45398. readonly shaderCompilationTimeCounter: PerfCounter;
  45399. /**
  45400. * Gets the shader compilation time capture status
  45401. */
  45402. /**
  45403. * Enable or disable the shader compilation time capture
  45404. */
  45405. captureShaderCompilationTime: boolean;
  45406. /**
  45407. * Instantiates a new engine instrumentation.
  45408. * This class can be used to get instrumentation data from a Babylon engine
  45409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45410. * @param engine Defines the engine to instrument
  45411. */
  45412. constructor(
  45413. /**
  45414. * Define the instrumented engine.
  45415. */
  45416. engine: Engine);
  45417. /**
  45418. * Dispose and release associated resources.
  45419. */
  45420. dispose(): void;
  45421. }
  45422. }
  45423. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45424. import { PerfCounter } from "babylonjs/Misc/tools";
  45425. import { Scene, IDisposable } from "babylonjs/scene";
  45426. /**
  45427. * This class can be used to get instrumentation data from a Babylon engine
  45428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45429. */
  45430. export class SceneInstrumentation implements IDisposable {
  45431. /**
  45432. * Defines the scene to instrument
  45433. */
  45434. scene: Scene;
  45435. private _captureActiveMeshesEvaluationTime;
  45436. private _activeMeshesEvaluationTime;
  45437. private _captureRenderTargetsRenderTime;
  45438. private _renderTargetsRenderTime;
  45439. private _captureFrameTime;
  45440. private _frameTime;
  45441. private _captureRenderTime;
  45442. private _renderTime;
  45443. private _captureInterFrameTime;
  45444. private _interFrameTime;
  45445. private _captureParticlesRenderTime;
  45446. private _particlesRenderTime;
  45447. private _captureSpritesRenderTime;
  45448. private _spritesRenderTime;
  45449. private _capturePhysicsTime;
  45450. private _physicsTime;
  45451. private _captureAnimationsTime;
  45452. private _animationsTime;
  45453. private _captureCameraRenderTime;
  45454. private _cameraRenderTime;
  45455. private _onBeforeActiveMeshesEvaluationObserver;
  45456. private _onAfterActiveMeshesEvaluationObserver;
  45457. private _onBeforeRenderTargetsRenderObserver;
  45458. private _onAfterRenderTargetsRenderObserver;
  45459. private _onAfterRenderObserver;
  45460. private _onBeforeDrawPhaseObserver;
  45461. private _onAfterDrawPhaseObserver;
  45462. private _onBeforeAnimationsObserver;
  45463. private _onBeforeParticlesRenderingObserver;
  45464. private _onAfterParticlesRenderingObserver;
  45465. private _onBeforeSpritesRenderingObserver;
  45466. private _onAfterSpritesRenderingObserver;
  45467. private _onBeforePhysicsObserver;
  45468. private _onAfterPhysicsObserver;
  45469. private _onAfterAnimationsObserver;
  45470. private _onBeforeCameraRenderObserver;
  45471. private _onAfterCameraRenderObserver;
  45472. /**
  45473. * Gets the perf counter used for active meshes evaluation time
  45474. */
  45475. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45476. /**
  45477. * Gets the active meshes evaluation time capture status
  45478. */
  45479. /**
  45480. * Enable or disable the active meshes evaluation time capture
  45481. */
  45482. captureActiveMeshesEvaluationTime: boolean;
  45483. /**
  45484. * Gets the perf counter used for render targets render time
  45485. */
  45486. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45487. /**
  45488. * Gets the render targets render time capture status
  45489. */
  45490. /**
  45491. * Enable or disable the render targets render time capture
  45492. */
  45493. captureRenderTargetsRenderTime: boolean;
  45494. /**
  45495. * Gets the perf counter used for particles render time
  45496. */
  45497. readonly particlesRenderTimeCounter: PerfCounter;
  45498. /**
  45499. * Gets the particles render time capture status
  45500. */
  45501. /**
  45502. * Enable or disable the particles render time capture
  45503. */
  45504. captureParticlesRenderTime: boolean;
  45505. /**
  45506. * Gets the perf counter used for sprites render time
  45507. */
  45508. readonly spritesRenderTimeCounter: PerfCounter;
  45509. /**
  45510. * Gets the sprites render time capture status
  45511. */
  45512. /**
  45513. * Enable or disable the sprites render time capture
  45514. */
  45515. captureSpritesRenderTime: boolean;
  45516. /**
  45517. * Gets the perf counter used for physics time
  45518. */
  45519. readonly physicsTimeCounter: PerfCounter;
  45520. /**
  45521. * Gets the physics time capture status
  45522. */
  45523. /**
  45524. * Enable or disable the physics time capture
  45525. */
  45526. capturePhysicsTime: boolean;
  45527. /**
  45528. * Gets the perf counter used for animations time
  45529. */
  45530. readonly animationsTimeCounter: PerfCounter;
  45531. /**
  45532. * Gets the animations time capture status
  45533. */
  45534. /**
  45535. * Enable or disable the animations time capture
  45536. */
  45537. captureAnimationsTime: boolean;
  45538. /**
  45539. * Gets the perf counter used for frame time capture
  45540. */
  45541. readonly frameTimeCounter: PerfCounter;
  45542. /**
  45543. * Gets the frame time capture status
  45544. */
  45545. /**
  45546. * Enable or disable the frame time capture
  45547. */
  45548. captureFrameTime: boolean;
  45549. /**
  45550. * Gets the perf counter used for inter-frames time capture
  45551. */
  45552. readonly interFrameTimeCounter: PerfCounter;
  45553. /**
  45554. * Gets the inter-frames time capture status
  45555. */
  45556. /**
  45557. * Enable or disable the inter-frames time capture
  45558. */
  45559. captureInterFrameTime: boolean;
  45560. /**
  45561. * Gets the perf counter used for render time capture
  45562. */
  45563. readonly renderTimeCounter: PerfCounter;
  45564. /**
  45565. * Gets the render time capture status
  45566. */
  45567. /**
  45568. * Enable or disable the render time capture
  45569. */
  45570. captureRenderTime: boolean;
  45571. /**
  45572. * Gets the perf counter used for camera render time capture
  45573. */
  45574. readonly cameraRenderTimeCounter: PerfCounter;
  45575. /**
  45576. * Gets the camera render time capture status
  45577. */
  45578. /**
  45579. * Enable or disable the camera render time capture
  45580. */
  45581. captureCameraRenderTime: boolean;
  45582. /**
  45583. * Gets the perf counter used for draw calls
  45584. */
  45585. readonly drawCallsCounter: PerfCounter;
  45586. /**
  45587. * Gets the perf counter used for texture collisions
  45588. */
  45589. readonly textureCollisionsCounter: PerfCounter;
  45590. /**
  45591. * Instantiates a new scene instrumentation.
  45592. * This class can be used to get instrumentation data from a Babylon engine
  45593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45594. * @param scene Defines the scene to instrument
  45595. */
  45596. constructor(
  45597. /**
  45598. * Defines the scene to instrument
  45599. */
  45600. scene: Scene);
  45601. /**
  45602. * Dispose and release associated resources.
  45603. */
  45604. dispose(): void;
  45605. }
  45606. }
  45607. declare module "babylonjs/Instrumentation/index" {
  45608. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45609. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45610. export * from "babylonjs/Instrumentation/timeToken";
  45611. }
  45612. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45613. /** @hidden */
  45614. export var glowMapGenerationPixelShader: {
  45615. name: string;
  45616. shader: string;
  45617. };
  45618. }
  45619. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45622. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45623. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45624. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45625. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45626. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45627. /** @hidden */
  45628. export var glowMapGenerationVertexShader: {
  45629. name: string;
  45630. shader: string;
  45631. };
  45632. }
  45633. declare module "babylonjs/Layers/effectLayer" {
  45634. import { Observable } from "babylonjs/Misc/observable";
  45635. import { Nullable } from "babylonjs/types";
  45636. import { Camera } from "babylonjs/Cameras/camera";
  45637. import { Scene } from "babylonjs/scene";
  45638. import { Color4, ISize } from "babylonjs/Maths/math";
  45639. import { Engine } from "babylonjs/Engines/engine";
  45640. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45642. import { Mesh } from "babylonjs/Meshes/mesh";
  45643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45645. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45646. import { Effect } from "babylonjs/Materials/effect";
  45647. import { Material } from "babylonjs/Materials/material";
  45648. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45649. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45650. /**
  45651. * Effect layer options. This helps customizing the behaviour
  45652. * of the effect layer.
  45653. */
  45654. export interface IEffectLayerOptions {
  45655. /**
  45656. * Multiplication factor apply to the canvas size to compute the render target size
  45657. * used to generated the objects (the smaller the faster).
  45658. */
  45659. mainTextureRatio: number;
  45660. /**
  45661. * Enforces a fixed size texture to ensure effect stability across devices.
  45662. */
  45663. mainTextureFixedSize?: number;
  45664. /**
  45665. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45666. */
  45667. alphaBlendingMode: number;
  45668. /**
  45669. * The camera attached to the layer.
  45670. */
  45671. camera: Nullable<Camera>;
  45672. /**
  45673. * The rendering group to draw the layer in.
  45674. */
  45675. renderingGroupId: number;
  45676. }
  45677. /**
  45678. * The effect layer Helps adding post process effect blended with the main pass.
  45679. *
  45680. * This can be for instance use to generate glow or higlight effects on the scene.
  45681. *
  45682. * The effect layer class can not be used directly and is intented to inherited from to be
  45683. * customized per effects.
  45684. */
  45685. export abstract class EffectLayer {
  45686. private _vertexBuffers;
  45687. private _indexBuffer;
  45688. private _cachedDefines;
  45689. private _effectLayerMapGenerationEffect;
  45690. private _effectLayerOptions;
  45691. private _mergeEffect;
  45692. protected _scene: Scene;
  45693. protected _engine: Engine;
  45694. protected _maxSize: number;
  45695. protected _mainTextureDesiredSize: ISize;
  45696. protected _mainTexture: RenderTargetTexture;
  45697. protected _shouldRender: boolean;
  45698. protected _postProcesses: PostProcess[];
  45699. protected _textures: BaseTexture[];
  45700. protected _emissiveTextureAndColor: {
  45701. texture: Nullable<BaseTexture>;
  45702. color: Color4;
  45703. };
  45704. /**
  45705. * The name of the layer
  45706. */
  45707. name: string;
  45708. /**
  45709. * The clear color of the texture used to generate the glow map.
  45710. */
  45711. neutralColor: Color4;
  45712. /**
  45713. * Specifies wether the highlight layer is enabled or not.
  45714. */
  45715. isEnabled: boolean;
  45716. /**
  45717. * Gets the camera attached to the layer.
  45718. */
  45719. readonly camera: Nullable<Camera>;
  45720. /**
  45721. * Gets the rendering group id the layer should render in.
  45722. */
  45723. readonly renderingGroupId: number;
  45724. /**
  45725. * An event triggered when the effect layer has been disposed.
  45726. */
  45727. onDisposeObservable: Observable<EffectLayer>;
  45728. /**
  45729. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45730. */
  45731. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45732. /**
  45733. * An event triggered when the generated texture is being merged in the scene.
  45734. */
  45735. onBeforeComposeObservable: Observable<EffectLayer>;
  45736. /**
  45737. * An event triggered when the generated texture has been merged in the scene.
  45738. */
  45739. onAfterComposeObservable: Observable<EffectLayer>;
  45740. /**
  45741. * An event triggered when the efffect layer changes its size.
  45742. */
  45743. onSizeChangedObservable: Observable<EffectLayer>;
  45744. /** @hidden */
  45745. static _SceneComponentInitialization: (scene: Scene) => void;
  45746. /**
  45747. * Instantiates a new effect Layer and references it in the scene.
  45748. * @param name The name of the layer
  45749. * @param scene The scene to use the layer in
  45750. */
  45751. constructor(
  45752. /** The Friendly of the effect in the scene */
  45753. name: string, scene: Scene);
  45754. /**
  45755. * Get the effect name of the layer.
  45756. * @return The effect name
  45757. */
  45758. abstract getEffectName(): string;
  45759. /**
  45760. * Checks for the readiness of the element composing the layer.
  45761. * @param subMesh the mesh to check for
  45762. * @param useInstances specify wether or not to use instances to render the mesh
  45763. * @return true if ready otherwise, false
  45764. */
  45765. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45766. /**
  45767. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45768. * @returns true if the effect requires stencil during the main canvas render pass.
  45769. */
  45770. abstract needStencil(): boolean;
  45771. /**
  45772. * Create the merge effect. This is the shader use to blit the information back
  45773. * to the main canvas at the end of the scene rendering.
  45774. * @returns The effect containing the shader used to merge the effect on the main canvas
  45775. */
  45776. protected abstract _createMergeEffect(): Effect;
  45777. /**
  45778. * Creates the render target textures and post processes used in the effect layer.
  45779. */
  45780. protected abstract _createTextureAndPostProcesses(): void;
  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 abstract _internalRender(effect: Effect): void;
  45786. /**
  45787. * Sets the required values for both the emissive texture and and the main color.
  45788. */
  45789. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45790. /**
  45791. * Free any resources and references associated to a mesh.
  45792. * Internal use
  45793. * @param mesh The mesh to free.
  45794. */
  45795. abstract _disposeMesh(mesh: Mesh): void;
  45796. /**
  45797. * Serializes this layer (Glow or Highlight for example)
  45798. * @returns a serialized layer object
  45799. */
  45800. abstract serialize?(): any;
  45801. /**
  45802. * Initializes the effect layer with the required options.
  45803. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45804. */
  45805. protected _init(options: Partial<IEffectLayerOptions>): void;
  45806. /**
  45807. * Generates the index buffer of the full screen quad blending to the main canvas.
  45808. */
  45809. private _generateIndexBuffer;
  45810. /**
  45811. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45812. */
  45813. private _genrateVertexBuffer;
  45814. /**
  45815. * Sets the main texture desired size which is the closest power of two
  45816. * of the engine canvas size.
  45817. */
  45818. private _setMainTextureSize;
  45819. /**
  45820. * Creates the main texture for the effect layer.
  45821. */
  45822. protected _createMainTexture(): void;
  45823. /**
  45824. * Adds specific effects defines.
  45825. * @param defines The defines to add specifics to.
  45826. */
  45827. protected _addCustomEffectDefines(defines: string[]): void;
  45828. /**
  45829. * Checks for the readiness of the element composing the layer.
  45830. * @param subMesh the mesh to check for
  45831. * @param useInstances specify wether or not to use instances to render the mesh
  45832. * @param emissiveTexture the associated emissive texture used to generate the glow
  45833. * @return true if ready otherwise, false
  45834. */
  45835. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45836. /**
  45837. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45838. */
  45839. render(): void;
  45840. /**
  45841. * Determine if a given mesh will be used in the current effect.
  45842. * @param mesh mesh to test
  45843. * @returns true if the mesh will be used
  45844. */
  45845. hasMesh(mesh: AbstractMesh): boolean;
  45846. /**
  45847. * Returns true if the layer contains information to display, otherwise false.
  45848. * @returns true if the glow layer should be rendered
  45849. */
  45850. shouldRender(): boolean;
  45851. /**
  45852. * Returns true if the mesh should render, otherwise false.
  45853. * @param mesh The mesh to render
  45854. * @returns true if it should render otherwise false
  45855. */
  45856. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45857. /**
  45858. * Returns true if the mesh can be rendered, otherwise false.
  45859. * @param mesh The mesh to render
  45860. * @param material The material used on the mesh
  45861. * @returns true if it can be rendered otherwise false
  45862. */
  45863. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45864. /**
  45865. * Returns true if the mesh should render, otherwise false.
  45866. * @param mesh The mesh to render
  45867. * @returns true if it should render otherwise false
  45868. */
  45869. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45870. /**
  45871. * Renders the submesh passed in parameter to the generation map.
  45872. */
  45873. protected _renderSubMesh(subMesh: SubMesh): void;
  45874. /**
  45875. * Rebuild the required buffers.
  45876. * @hidden Internal use only.
  45877. */
  45878. _rebuild(): void;
  45879. /**
  45880. * Dispose only the render target textures and post process.
  45881. */
  45882. private _disposeTextureAndPostProcesses;
  45883. /**
  45884. * Dispose the highlight layer and free resources.
  45885. */
  45886. dispose(): void;
  45887. /**
  45888. * Gets the class name of the effect layer
  45889. * @returns the string with the class name of the effect layer
  45890. */
  45891. getClassName(): string;
  45892. /**
  45893. * Creates an effect layer from parsed effect layer data
  45894. * @param parsedEffectLayer defines effect layer data
  45895. * @param scene defines the current scene
  45896. * @param rootUrl defines the root URL containing the effect layer information
  45897. * @returns a parsed effect Layer
  45898. */
  45899. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45900. }
  45901. }
  45902. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45903. import { Scene } from "babylonjs/scene";
  45904. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45905. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45906. import { AbstractScene } from "babylonjs/abstractScene";
  45907. module "babylonjs/abstractScene" {
  45908. interface AbstractScene {
  45909. /**
  45910. * The list of effect layers (highlights/glow) added to the scene
  45911. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45912. * @see http://doc.babylonjs.com/how_to/glow_layer
  45913. */
  45914. effectLayers: Array<EffectLayer>;
  45915. /**
  45916. * Removes the given effect layer from this scene.
  45917. * @param toRemove defines the effect layer to remove
  45918. * @returns the index of the removed effect layer
  45919. */
  45920. removeEffectLayer(toRemove: EffectLayer): number;
  45921. /**
  45922. * Adds the given effect layer to this scene
  45923. * @param newEffectLayer defines the effect layer to add
  45924. */
  45925. addEffectLayer(newEffectLayer: EffectLayer): void;
  45926. }
  45927. }
  45928. /**
  45929. * Defines the layer scene component responsible to manage any effect layers
  45930. * in a given scene.
  45931. */
  45932. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45933. /**
  45934. * The component name helpfull to identify the component in the list of scene components.
  45935. */
  45936. readonly name: string;
  45937. /**
  45938. * The scene the component belongs to.
  45939. */
  45940. scene: Scene;
  45941. private _engine;
  45942. private _renderEffects;
  45943. private _needStencil;
  45944. private _previousStencilState;
  45945. /**
  45946. * Creates a new instance of the component for the given scene
  45947. * @param scene Defines the scene to register the component in
  45948. */
  45949. constructor(scene: Scene);
  45950. /**
  45951. * Registers the component in a given scene
  45952. */
  45953. register(): void;
  45954. /**
  45955. * Rebuilds the elements related to this component in case of
  45956. * context lost for instance.
  45957. */
  45958. rebuild(): void;
  45959. /**
  45960. * Serializes the component data to the specified json object
  45961. * @param serializationObject The object to serialize to
  45962. */
  45963. serialize(serializationObject: any): void;
  45964. /**
  45965. * Adds all the element from the container to the scene
  45966. * @param container the container holding the elements
  45967. */
  45968. addFromContainer(container: AbstractScene): void;
  45969. /**
  45970. * Removes all the elements in the container from the scene
  45971. * @param container contains the elements to remove
  45972. */
  45973. removeFromContainer(container: AbstractScene): void;
  45974. /**
  45975. * Disposes the component and the associated ressources.
  45976. */
  45977. dispose(): void;
  45978. private _isReadyForMesh;
  45979. private _renderMainTexture;
  45980. private _setStencil;
  45981. private _setStencilBack;
  45982. private _draw;
  45983. private _drawCamera;
  45984. private _drawRenderingGroup;
  45985. }
  45986. }
  45987. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45988. /** @hidden */
  45989. export var glowMapMergePixelShader: {
  45990. name: string;
  45991. shader: string;
  45992. };
  45993. }
  45994. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45995. /** @hidden */
  45996. export var glowMapMergeVertexShader: {
  45997. name: string;
  45998. shader: string;
  45999. };
  46000. }
  46001. declare module "babylonjs/Layers/glowLayer" {
  46002. import { Nullable } from "babylonjs/types";
  46003. import { Camera } from "babylonjs/Cameras/camera";
  46004. import { Scene } from "babylonjs/scene";
  46005. import { Color4 } from "babylonjs/Maths/math";
  46006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46008. import { Mesh } from "babylonjs/Meshes/mesh";
  46009. import { Texture } from "babylonjs/Materials/Textures/texture";
  46010. import { Effect } from "babylonjs/Materials/effect";
  46011. import { Material } from "babylonjs/Materials/material";
  46012. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46013. import "babylonjs/Shaders/glowMapMerge.fragment";
  46014. import "babylonjs/Shaders/glowMapMerge.vertex";
  46015. module "babylonjs/abstractScene" {
  46016. interface AbstractScene {
  46017. /**
  46018. * Return a the first highlight layer of the scene with a given name.
  46019. * @param name The name of the highlight layer to look for.
  46020. * @return The highlight layer if found otherwise null.
  46021. */
  46022. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46023. }
  46024. }
  46025. /**
  46026. * Glow layer options. This helps customizing the behaviour
  46027. * of the glow layer.
  46028. */
  46029. export interface IGlowLayerOptions {
  46030. /**
  46031. * Multiplication factor apply to the canvas size to compute the render target size
  46032. * used to generated the glowing objects (the smaller the faster).
  46033. */
  46034. mainTextureRatio: number;
  46035. /**
  46036. * Enforces a fixed size texture to ensure resize independant blur.
  46037. */
  46038. mainTextureFixedSize?: number;
  46039. /**
  46040. * How big is the kernel of the blur texture.
  46041. */
  46042. blurKernelSize: number;
  46043. /**
  46044. * The camera attached to the layer.
  46045. */
  46046. camera: Nullable<Camera>;
  46047. /**
  46048. * Enable MSAA by chosing the number of samples.
  46049. */
  46050. mainTextureSamples?: number;
  46051. /**
  46052. * The rendering group to draw the layer in.
  46053. */
  46054. renderingGroupId: number;
  46055. }
  46056. /**
  46057. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46058. *
  46059. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46060. * glowy meshes to your scene.
  46061. *
  46062. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46063. */
  46064. export class GlowLayer extends EffectLayer {
  46065. /**
  46066. * Effect Name of the layer.
  46067. */
  46068. static readonly EffectName: string;
  46069. /**
  46070. * The default blur kernel size used for the glow.
  46071. */
  46072. static DefaultBlurKernelSize: number;
  46073. /**
  46074. * The default texture size ratio used for the glow.
  46075. */
  46076. static DefaultTextureRatio: number;
  46077. /**
  46078. * Sets the kernel size of the blur.
  46079. */
  46080. /**
  46081. * Gets the kernel size of the blur.
  46082. */
  46083. blurKernelSize: number;
  46084. /**
  46085. * Sets the glow intensity.
  46086. */
  46087. /**
  46088. * Gets the glow intensity.
  46089. */
  46090. intensity: number;
  46091. private _options;
  46092. private _intensity;
  46093. private _horizontalBlurPostprocess1;
  46094. private _verticalBlurPostprocess1;
  46095. private _horizontalBlurPostprocess2;
  46096. private _verticalBlurPostprocess2;
  46097. private _blurTexture1;
  46098. private _blurTexture2;
  46099. private _postProcesses1;
  46100. private _postProcesses2;
  46101. private _includedOnlyMeshes;
  46102. private _excludedMeshes;
  46103. /**
  46104. * Callback used to let the user override the color selection on a per mesh basis
  46105. */
  46106. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46107. /**
  46108. * Callback used to let the user override the texture selection on a per mesh basis
  46109. */
  46110. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46111. /**
  46112. * Instantiates a new glow Layer and references it to the scene.
  46113. * @param name The name of the layer
  46114. * @param scene The scene to use the layer in
  46115. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46116. */
  46117. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46118. /**
  46119. * Get the effect name of the layer.
  46120. * @return The effect name
  46121. */
  46122. getEffectName(): string;
  46123. /**
  46124. * Create the merge effect. This is the shader use to blit the information back
  46125. * to the main canvas at the end of the scene rendering.
  46126. */
  46127. protected _createMergeEffect(): Effect;
  46128. /**
  46129. * Creates the render target textures and post processes used in the glow layer.
  46130. */
  46131. protected _createTextureAndPostProcesses(): void;
  46132. /**
  46133. * Checks for the readiness of the element composing the layer.
  46134. * @param subMesh the mesh to check for
  46135. * @param useInstances specify wether or not to use instances to render the mesh
  46136. * @param emissiveTexture the associated emissive texture used to generate the glow
  46137. * @return true if ready otherwise, false
  46138. */
  46139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46140. /**
  46141. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46142. */
  46143. needStencil(): boolean;
  46144. /**
  46145. * Returns true if the mesh can be rendered, otherwise false.
  46146. * @param mesh The mesh to render
  46147. * @param material The material used on the mesh
  46148. * @returns true if it can be rendered otherwise false
  46149. */
  46150. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46151. /**
  46152. * Implementation specific of rendering the generating effect on the main canvas.
  46153. * @param effect The effect used to render through
  46154. */
  46155. protected _internalRender(effect: Effect): void;
  46156. /**
  46157. * Sets the required values for both the emissive texture and and the main color.
  46158. */
  46159. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46160. /**
  46161. * Returns true if the mesh should render, otherwise false.
  46162. * @param mesh The mesh to render
  46163. * @returns true if it should render otherwise false
  46164. */
  46165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46166. /**
  46167. * Adds specific effects defines.
  46168. * @param defines The defines to add specifics to.
  46169. */
  46170. protected _addCustomEffectDefines(defines: string[]): void;
  46171. /**
  46172. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46173. * @param mesh The mesh to exclude from the glow layer
  46174. */
  46175. addExcludedMesh(mesh: Mesh): void;
  46176. /**
  46177. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46178. * @param mesh The mesh to remove
  46179. */
  46180. removeExcludedMesh(mesh: Mesh): void;
  46181. /**
  46182. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46183. * @param mesh The mesh to include in the glow layer
  46184. */
  46185. addIncludedOnlyMesh(mesh: Mesh): void;
  46186. /**
  46187. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46188. * @param mesh The mesh to remove
  46189. */
  46190. removeIncludedOnlyMesh(mesh: Mesh): void;
  46191. /**
  46192. * Determine if a given mesh will be used in the glow layer
  46193. * @param mesh The mesh to test
  46194. * @returns true if the mesh will be highlighted by the current glow layer
  46195. */
  46196. hasMesh(mesh: AbstractMesh): boolean;
  46197. /**
  46198. * Free any resources and references associated to a mesh.
  46199. * Internal use
  46200. * @param mesh The mesh to free.
  46201. * @hidden
  46202. */
  46203. _disposeMesh(mesh: Mesh): void;
  46204. /**
  46205. * Gets the class name of the effect layer
  46206. * @returns the string with the class name of the effect layer
  46207. */
  46208. getClassName(): string;
  46209. /**
  46210. * Serializes this glow layer
  46211. * @returns a serialized glow layer object
  46212. */
  46213. serialize(): any;
  46214. /**
  46215. * Creates a Glow Layer from parsed glow layer data
  46216. * @param parsedGlowLayer defines glow layer data
  46217. * @param scene defines the current scene
  46218. * @param rootUrl defines the root URL containing the glow layer information
  46219. * @returns a parsed Glow Layer
  46220. */
  46221. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46222. }
  46223. }
  46224. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46225. /** @hidden */
  46226. export var glowBlurPostProcessPixelShader: {
  46227. name: string;
  46228. shader: string;
  46229. };
  46230. }
  46231. declare module "babylonjs/Layers/highlightLayer" {
  46232. import { Observable } from "babylonjs/Misc/observable";
  46233. import { Nullable } from "babylonjs/types";
  46234. import { Camera } from "babylonjs/Cameras/camera";
  46235. import { Scene } from "babylonjs/scene";
  46236. import { Color3, Color4 } from "babylonjs/Maths/math";
  46237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46239. import { Mesh } from "babylonjs/Meshes/mesh";
  46240. import { Effect } from "babylonjs/Materials/effect";
  46241. import { Material } from "babylonjs/Materials/material";
  46242. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46243. import "babylonjs/Shaders/glowMapMerge.fragment";
  46244. import "babylonjs/Shaders/glowMapMerge.vertex";
  46245. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46246. module "babylonjs/abstractScene" {
  46247. interface AbstractScene {
  46248. /**
  46249. * Return a the first highlight layer of the scene with a given name.
  46250. * @param name The name of the highlight layer to look for.
  46251. * @return The highlight layer if found otherwise null.
  46252. */
  46253. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46254. }
  46255. }
  46256. /**
  46257. * Highlight layer options. This helps customizing the behaviour
  46258. * of the highlight layer.
  46259. */
  46260. export interface IHighlightLayerOptions {
  46261. /**
  46262. * Multiplication factor apply to the canvas size to compute the render target size
  46263. * used to generated the glowing objects (the smaller the faster).
  46264. */
  46265. mainTextureRatio: number;
  46266. /**
  46267. * Enforces a fixed size texture to ensure resize independant blur.
  46268. */
  46269. mainTextureFixedSize?: number;
  46270. /**
  46271. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46272. * of the picture to blur (the smaller the faster).
  46273. */
  46274. blurTextureSizeRatio: number;
  46275. /**
  46276. * How big in texel of the blur texture is the vertical blur.
  46277. */
  46278. blurVerticalSize: number;
  46279. /**
  46280. * How big in texel of the blur texture is the horizontal blur.
  46281. */
  46282. blurHorizontalSize: number;
  46283. /**
  46284. * Alpha blending mode used to apply the blur. Default is combine.
  46285. */
  46286. alphaBlendingMode: number;
  46287. /**
  46288. * The camera attached to the layer.
  46289. */
  46290. camera: Nullable<Camera>;
  46291. /**
  46292. * Should we display highlight as a solid stroke?
  46293. */
  46294. isStroke?: boolean;
  46295. /**
  46296. * The rendering group to draw the layer in.
  46297. */
  46298. renderingGroupId: number;
  46299. }
  46300. /**
  46301. * The highlight layer Helps adding a glow effect around a mesh.
  46302. *
  46303. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46304. * glowy meshes to your scene.
  46305. *
  46306. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46307. */
  46308. export class HighlightLayer extends EffectLayer {
  46309. name: string;
  46310. /**
  46311. * Effect Name of the highlight layer.
  46312. */
  46313. static readonly EffectName: string;
  46314. /**
  46315. * The neutral color used during the preparation of the glow effect.
  46316. * This is black by default as the blend operation is a blend operation.
  46317. */
  46318. static NeutralColor: Color4;
  46319. /**
  46320. * Stencil value used for glowing meshes.
  46321. */
  46322. static GlowingMeshStencilReference: number;
  46323. /**
  46324. * Stencil value used for the other meshes in the scene.
  46325. */
  46326. static NormalMeshStencilReference: number;
  46327. /**
  46328. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46329. */
  46330. innerGlow: boolean;
  46331. /**
  46332. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46333. */
  46334. outerGlow: boolean;
  46335. /**
  46336. * Specifies the horizontal size of the blur.
  46337. */
  46338. /**
  46339. * Gets the horizontal size of the blur.
  46340. */
  46341. blurHorizontalSize: number;
  46342. /**
  46343. * Specifies the vertical size of the blur.
  46344. */
  46345. /**
  46346. * Gets the vertical size of the blur.
  46347. */
  46348. blurVerticalSize: number;
  46349. /**
  46350. * An event triggered when the highlight layer is being blurred.
  46351. */
  46352. onBeforeBlurObservable: Observable<HighlightLayer>;
  46353. /**
  46354. * An event triggered when the highlight layer has been blurred.
  46355. */
  46356. onAfterBlurObservable: Observable<HighlightLayer>;
  46357. private _instanceGlowingMeshStencilReference;
  46358. private _options;
  46359. private _downSamplePostprocess;
  46360. private _horizontalBlurPostprocess;
  46361. private _verticalBlurPostprocess;
  46362. private _blurTexture;
  46363. private _meshes;
  46364. private _excludedMeshes;
  46365. /**
  46366. * Instantiates a new highlight Layer and references it to the scene..
  46367. * @param name The name of the layer
  46368. * @param scene The scene to use the layer in
  46369. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46370. */
  46371. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46372. /**
  46373. * Get the effect name of the layer.
  46374. * @return The effect name
  46375. */
  46376. getEffectName(): string;
  46377. /**
  46378. * Create the merge effect. This is the shader use to blit the information back
  46379. * to the main canvas at the end of the scene rendering.
  46380. */
  46381. protected _createMergeEffect(): Effect;
  46382. /**
  46383. * Creates the render target textures and post processes used in the highlight layer.
  46384. */
  46385. protected _createTextureAndPostProcesses(): void;
  46386. /**
  46387. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46388. */
  46389. needStencil(): boolean;
  46390. /**
  46391. * Checks for the readiness of the element composing the layer.
  46392. * @param subMesh the mesh to check for
  46393. * @param useInstances specify wether or not to use instances to render the mesh
  46394. * @param emissiveTexture the associated emissive texture used to generate the glow
  46395. * @return true if ready otherwise, false
  46396. */
  46397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46398. /**
  46399. * Implementation specific of rendering the generating effect on the main canvas.
  46400. * @param effect The effect used to render through
  46401. */
  46402. protected _internalRender(effect: Effect): void;
  46403. /**
  46404. * Returns true if the layer contains information to display, otherwise false.
  46405. */
  46406. shouldRender(): boolean;
  46407. /**
  46408. * Returns true if the mesh should render, otherwise false.
  46409. * @param mesh The mesh to render
  46410. * @returns true if it should render otherwise false
  46411. */
  46412. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46413. /**
  46414. * Sets the required values for both the emissive texture and and the main color.
  46415. */
  46416. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46417. /**
  46418. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46419. * @param mesh The mesh to exclude from the highlight layer
  46420. */
  46421. addExcludedMesh(mesh: Mesh): void;
  46422. /**
  46423. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46424. * @param mesh The mesh to highlight
  46425. */
  46426. removeExcludedMesh(mesh: Mesh): void;
  46427. /**
  46428. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46429. * @param mesh mesh to test
  46430. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46431. */
  46432. hasMesh(mesh: AbstractMesh): boolean;
  46433. /**
  46434. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46435. * @param mesh The mesh to highlight
  46436. * @param color The color of the highlight
  46437. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46438. */
  46439. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46440. /**
  46441. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46442. * @param mesh The mesh to highlight
  46443. */
  46444. removeMesh(mesh: Mesh): void;
  46445. /**
  46446. * Force the stencil to the normal expected value for none glowing parts
  46447. */
  46448. private _defaultStencilReference;
  46449. /**
  46450. * Free any resources and references associated to a mesh.
  46451. * Internal use
  46452. * @param mesh The mesh to free.
  46453. * @hidden
  46454. */
  46455. _disposeMesh(mesh: Mesh): void;
  46456. /**
  46457. * Dispose the highlight layer and free resources.
  46458. */
  46459. dispose(): void;
  46460. /**
  46461. * Gets the class name of the effect layer
  46462. * @returns the string with the class name of the effect layer
  46463. */
  46464. getClassName(): string;
  46465. /**
  46466. * Serializes this Highlight layer
  46467. * @returns a serialized Highlight layer object
  46468. */
  46469. serialize(): any;
  46470. /**
  46471. * Creates a Highlight layer from parsed Highlight layer data
  46472. * @param parsedHightlightLayer defines the Highlight layer data
  46473. * @param scene defines the current scene
  46474. * @param rootUrl defines the root URL containing the Highlight layer information
  46475. * @returns a parsed Highlight layer
  46476. */
  46477. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46478. }
  46479. }
  46480. declare module "babylonjs/Layers/index" {
  46481. export * from "babylonjs/Layers/effectLayer";
  46482. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46483. export * from "babylonjs/Layers/glowLayer";
  46484. export * from "babylonjs/Layers/highlightLayer";
  46485. export * from "babylonjs/Layers/layer";
  46486. export * from "babylonjs/Layers/layerSceneComponent";
  46487. }
  46488. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46489. /** @hidden */
  46490. export var lensFlarePixelShader: {
  46491. name: string;
  46492. shader: string;
  46493. };
  46494. }
  46495. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46496. /** @hidden */
  46497. export var lensFlareVertexShader: {
  46498. name: string;
  46499. shader: string;
  46500. };
  46501. }
  46502. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46503. import { Scene } from "babylonjs/scene";
  46504. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46506. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46507. import "babylonjs/Shaders/lensFlare.fragment";
  46508. import "babylonjs/Shaders/lensFlare.vertex";
  46509. /**
  46510. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46511. * It is usually composed of several `lensFlare`.
  46512. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46513. */
  46514. export class LensFlareSystem {
  46515. /**
  46516. * Define the name of the lens flare system
  46517. */
  46518. name: string;
  46519. /**
  46520. * List of lens flares used in this system.
  46521. */
  46522. lensFlares: LensFlare[];
  46523. /**
  46524. * Define a limit from the border the lens flare can be visible.
  46525. */
  46526. borderLimit: number;
  46527. /**
  46528. * Define a viewport border we do not want to see the lens flare in.
  46529. */
  46530. viewportBorder: number;
  46531. /**
  46532. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46533. */
  46534. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46535. /**
  46536. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46537. */
  46538. layerMask: number;
  46539. /**
  46540. * Define the id of the lens flare system in the scene.
  46541. * (equal to name by default)
  46542. */
  46543. id: string;
  46544. private _scene;
  46545. private _emitter;
  46546. private _vertexBuffers;
  46547. private _indexBuffer;
  46548. private _effect;
  46549. private _positionX;
  46550. private _positionY;
  46551. private _isEnabled;
  46552. /** @hidden */
  46553. static _SceneComponentInitialization: (scene: Scene) => void;
  46554. /**
  46555. * Instantiates a lens flare system.
  46556. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46557. * It is usually composed of several `lensFlare`.
  46558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46559. * @param name Define the name of the lens flare system in the scene
  46560. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46561. * @param scene Define the scene the lens flare system belongs to
  46562. */
  46563. constructor(
  46564. /**
  46565. * Define the name of the lens flare system
  46566. */
  46567. name: string, emitter: any, scene: Scene);
  46568. /**
  46569. * Define if the lens flare system is enabled.
  46570. */
  46571. isEnabled: boolean;
  46572. /**
  46573. * Get the scene the effects belongs to.
  46574. * @returns the scene holding the lens flare system
  46575. */
  46576. getScene(): Scene;
  46577. /**
  46578. * Get the emitter of the lens flare system.
  46579. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46580. * @returns the emitter of the lens flare system
  46581. */
  46582. getEmitter(): any;
  46583. /**
  46584. * Set the emitter of the lens flare system.
  46585. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46586. * @param newEmitter Define the new emitter of the system
  46587. */
  46588. setEmitter(newEmitter: any): void;
  46589. /**
  46590. * Get the lens flare system emitter position.
  46591. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46592. * @returns the position
  46593. */
  46594. getEmitterPosition(): Vector3;
  46595. /**
  46596. * @hidden
  46597. */
  46598. computeEffectivePosition(globalViewport: Viewport): boolean;
  46599. /** @hidden */
  46600. _isVisible(): boolean;
  46601. /**
  46602. * @hidden
  46603. */
  46604. render(): boolean;
  46605. /**
  46606. * Dispose and release the lens flare with its associated resources.
  46607. */
  46608. dispose(): void;
  46609. /**
  46610. * Parse a lens flare system from a JSON repressentation
  46611. * @param parsedLensFlareSystem Define the JSON to parse
  46612. * @param scene Define the scene the parsed system should be instantiated in
  46613. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46614. * @returns the parsed system
  46615. */
  46616. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46617. /**
  46618. * Serialize the current Lens Flare System into a JSON representation.
  46619. * @returns the serialized JSON
  46620. */
  46621. serialize(): any;
  46622. }
  46623. }
  46624. declare module "babylonjs/LensFlares/lensFlare" {
  46625. import { Nullable } from "babylonjs/types";
  46626. import { Color3 } from "babylonjs/Maths/math";
  46627. import { Texture } from "babylonjs/Materials/Textures/texture";
  46628. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46629. /**
  46630. * This represents one of the lens effect in a `lensFlareSystem`.
  46631. * It controls one of the indiviual texture used in the effect.
  46632. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46633. */
  46634. export class LensFlare {
  46635. /**
  46636. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46637. */
  46638. size: number;
  46639. /**
  46640. * 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.
  46641. */
  46642. position: number;
  46643. /**
  46644. * Define the lens color.
  46645. */
  46646. color: Color3;
  46647. /**
  46648. * Define the lens texture.
  46649. */
  46650. texture: Nullable<Texture>;
  46651. /**
  46652. * Define the alpha mode to render this particular lens.
  46653. */
  46654. alphaMode: number;
  46655. private _system;
  46656. /**
  46657. * Creates a new Lens Flare.
  46658. * This represents one of the lens effect in a `lensFlareSystem`.
  46659. * It controls one of the indiviual texture used in the effect.
  46660. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46661. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46662. * @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.
  46663. * @param color Define the lens color
  46664. * @param imgUrl Define the lens texture url
  46665. * @param system Define the `lensFlareSystem` this flare is part of
  46666. * @returns The newly created Lens Flare
  46667. */
  46668. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46669. /**
  46670. * Instantiates a new Lens Flare.
  46671. * This represents one of the lens effect in a `lensFlareSystem`.
  46672. * It controls one of the indiviual texture used in the effect.
  46673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46674. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46675. * @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.
  46676. * @param color Define the lens color
  46677. * @param imgUrl Define the lens texture url
  46678. * @param system Define the `lensFlareSystem` this flare is part of
  46679. */
  46680. constructor(
  46681. /**
  46682. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46683. */
  46684. size: number,
  46685. /**
  46686. * 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.
  46687. */
  46688. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46689. /**
  46690. * Dispose and release the lens flare with its associated resources.
  46691. */
  46692. dispose(): void;
  46693. }
  46694. }
  46695. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46696. import { Nullable } from "babylonjs/types";
  46697. import { Scene } from "babylonjs/scene";
  46698. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46699. import { AbstractScene } from "babylonjs/abstractScene";
  46700. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46701. module "babylonjs/abstractScene" {
  46702. interface AbstractScene {
  46703. /**
  46704. * The list of lens flare system added to the scene
  46705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46706. */
  46707. lensFlareSystems: Array<LensFlareSystem>;
  46708. /**
  46709. * Removes the given lens flare system from this scene.
  46710. * @param toRemove The lens flare system to remove
  46711. * @returns The index of the removed lens flare system
  46712. */
  46713. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46714. /**
  46715. * Adds the given lens flare system to this scene
  46716. * @param newLensFlareSystem The lens flare system to add
  46717. */
  46718. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46719. /**
  46720. * Gets a lens flare system using its name
  46721. * @param name defines the name to look for
  46722. * @returns the lens flare system or null if not found
  46723. */
  46724. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46725. /**
  46726. * Gets a lens flare system using its id
  46727. * @param id defines the id to look for
  46728. * @returns the lens flare system or null if not found
  46729. */
  46730. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46731. }
  46732. }
  46733. /**
  46734. * Defines the lens flare scene component responsible to manage any lens flares
  46735. * in a given scene.
  46736. */
  46737. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46738. /**
  46739. * The component name helpfull to identify the component in the list of scene components.
  46740. */
  46741. readonly name: string;
  46742. /**
  46743. * The scene the component belongs to.
  46744. */
  46745. scene: Scene;
  46746. /**
  46747. * Creates a new instance of the component for the given scene
  46748. * @param scene Defines the scene to register the component in
  46749. */
  46750. constructor(scene: Scene);
  46751. /**
  46752. * Registers the component in a given scene
  46753. */
  46754. register(): void;
  46755. /**
  46756. * Rebuilds the elements related to this component in case of
  46757. * context lost for instance.
  46758. */
  46759. rebuild(): void;
  46760. /**
  46761. * Adds all the element from the container to the scene
  46762. * @param container the container holding the elements
  46763. */
  46764. addFromContainer(container: AbstractScene): void;
  46765. /**
  46766. * Removes all the elements in the container from the scene
  46767. * @param container contains the elements to remove
  46768. */
  46769. removeFromContainer(container: AbstractScene): void;
  46770. /**
  46771. * Serializes the component data to the specified json object
  46772. * @param serializationObject The object to serialize to
  46773. */
  46774. serialize(serializationObject: any): void;
  46775. /**
  46776. * Disposes the component and the associated ressources.
  46777. */
  46778. dispose(): void;
  46779. private _draw;
  46780. }
  46781. }
  46782. declare module "babylonjs/LensFlares/index" {
  46783. export * from "babylonjs/LensFlares/lensFlare";
  46784. export * from "babylonjs/LensFlares/lensFlareSystem";
  46785. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46786. }
  46787. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46788. import { Scene } from "babylonjs/scene";
  46789. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46790. import { AbstractScene } from "babylonjs/abstractScene";
  46791. /**
  46792. * Defines the shadow generator component responsible to manage any shadow generators
  46793. * in a given scene.
  46794. */
  46795. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46796. /**
  46797. * The component name helpfull to identify the component in the list of scene components.
  46798. */
  46799. readonly name: string;
  46800. /**
  46801. * The scene the component belongs to.
  46802. */
  46803. scene: Scene;
  46804. /**
  46805. * Creates a new instance of the component for the given scene
  46806. * @param scene Defines the scene to register the component in
  46807. */
  46808. constructor(scene: Scene);
  46809. /**
  46810. * Registers the component in a given scene
  46811. */
  46812. register(): void;
  46813. /**
  46814. * Rebuilds the elements related to this component in case of
  46815. * context lost for instance.
  46816. */
  46817. rebuild(): void;
  46818. /**
  46819. * Serializes the component data to the specified json object
  46820. * @param serializationObject The object to serialize to
  46821. */
  46822. serialize(serializationObject: any): void;
  46823. /**
  46824. * Adds all the element from the container to the scene
  46825. * @param container the container holding the elements
  46826. */
  46827. addFromContainer(container: AbstractScene): void;
  46828. /**
  46829. * Removes all the elements in the container from the scene
  46830. * @param container contains the elements to remove
  46831. */
  46832. removeFromContainer(container: AbstractScene): void;
  46833. /**
  46834. * Rebuilds the elements related to this component in case of
  46835. * context lost for instance.
  46836. */
  46837. dispose(): void;
  46838. private _gatherRenderTargets;
  46839. }
  46840. }
  46841. declare module "babylonjs/Lights/Shadows/index" {
  46842. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46843. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46844. }
  46845. declare module "babylonjs/Lights/directionalLight" {
  46846. import { Camera } from "babylonjs/Cameras/camera";
  46847. import { Scene } from "babylonjs/scene";
  46848. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46850. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46851. import { Effect } from "babylonjs/Materials/effect";
  46852. /**
  46853. * A directional light is defined by a direction (what a surprise!).
  46854. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46855. * 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.
  46856. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46857. */
  46858. export class DirectionalLight extends ShadowLight {
  46859. private _shadowFrustumSize;
  46860. /**
  46861. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46862. */
  46863. /**
  46864. * Specifies a fix frustum size for the shadow generation.
  46865. */
  46866. shadowFrustumSize: number;
  46867. private _shadowOrthoScale;
  46868. /**
  46869. * Gets the shadow projection scale against the optimal computed one.
  46870. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46871. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46872. */
  46873. /**
  46874. * Sets the shadow projection scale against the optimal computed one.
  46875. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46876. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46877. */
  46878. shadowOrthoScale: number;
  46879. /**
  46880. * Automatically compute the projection matrix to best fit (including all the casters)
  46881. * on each frame.
  46882. */
  46883. autoUpdateExtends: boolean;
  46884. private _orthoLeft;
  46885. private _orthoRight;
  46886. private _orthoTop;
  46887. private _orthoBottom;
  46888. /**
  46889. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46890. * The directional light is emitted from everywhere in the given direction.
  46891. * It can cast shadows.
  46892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46893. * @param name The friendly name of the light
  46894. * @param direction The direction of the light
  46895. * @param scene The scene the light belongs to
  46896. */
  46897. constructor(name: string, direction: Vector3, scene: Scene);
  46898. /**
  46899. * Returns the string "DirectionalLight".
  46900. * @return The class name
  46901. */
  46902. getClassName(): string;
  46903. /**
  46904. * Returns the integer 1.
  46905. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46906. */
  46907. getTypeID(): number;
  46908. /**
  46909. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46910. * Returns the DirectionalLight Shadow projection matrix.
  46911. */
  46912. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46913. /**
  46914. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46915. * Returns the DirectionalLight Shadow projection matrix.
  46916. */
  46917. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46918. /**
  46919. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46920. * Returns the DirectionalLight Shadow projection matrix.
  46921. */
  46922. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46923. protected _buildUniformLayout(): void;
  46924. /**
  46925. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46926. * @param effect The effect to update
  46927. * @param lightIndex The index of the light in the effect to update
  46928. * @returns The directional light
  46929. */
  46930. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46931. /**
  46932. * Gets the minZ used for shadow according to both the scene and the light.
  46933. *
  46934. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46935. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46936. * @param activeCamera The camera we are returning the min for
  46937. * @returns the depth min z
  46938. */
  46939. getDepthMinZ(activeCamera: Camera): number;
  46940. /**
  46941. * Gets the maxZ used for shadow according to both the scene and the light.
  46942. *
  46943. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46944. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46945. * @param activeCamera The camera we are returning the max for
  46946. * @returns the depth max z
  46947. */
  46948. getDepthMaxZ(activeCamera: Camera): number;
  46949. /**
  46950. * Prepares the list of defines specific to the light type.
  46951. * @param defines the list of defines
  46952. * @param lightIndex defines the index of the light for the effect
  46953. */
  46954. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46955. }
  46956. }
  46957. declare module "babylonjs/Lights/pointLight" {
  46958. import { Scene } from "babylonjs/scene";
  46959. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46961. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46962. import { Effect } from "babylonjs/Materials/effect";
  46963. /**
  46964. * A point light is a light defined by an unique point in world space.
  46965. * The light is emitted in every direction from this point.
  46966. * A good example of a point light is a standard light bulb.
  46967. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46968. */
  46969. export class PointLight extends ShadowLight {
  46970. private _shadowAngle;
  46971. /**
  46972. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46973. * This specifies what angle the shadow will use to be created.
  46974. *
  46975. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46976. */
  46977. /**
  46978. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46979. * This specifies what angle the shadow will use to be created.
  46980. *
  46981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46982. */
  46983. shadowAngle: number;
  46984. /**
  46985. * Gets the direction if it has been set.
  46986. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46987. */
  46988. /**
  46989. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46990. */
  46991. direction: Vector3;
  46992. /**
  46993. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46994. * A PointLight emits the light in every direction.
  46995. * It can cast shadows.
  46996. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46997. * ```javascript
  46998. * var pointLight = new PointLight("pl", camera.position, scene);
  46999. * ```
  47000. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47001. * @param name The light friendly name
  47002. * @param position The position of the point light in the scene
  47003. * @param scene The scene the lights belongs to
  47004. */
  47005. constructor(name: string, position: Vector3, scene: Scene);
  47006. /**
  47007. * Returns the string "PointLight"
  47008. * @returns the class name
  47009. */
  47010. getClassName(): string;
  47011. /**
  47012. * Returns the integer 0.
  47013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47014. */
  47015. getTypeID(): number;
  47016. /**
  47017. * Specifies wether or not the shadowmap should be a cube texture.
  47018. * @returns true if the shadowmap needs to be a cube texture.
  47019. */
  47020. needCube(): boolean;
  47021. /**
  47022. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47023. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47024. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47025. */
  47026. getShadowDirection(faceIndex?: number): Vector3;
  47027. /**
  47028. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47029. * - fov = PI / 2
  47030. * - aspect ratio : 1.0
  47031. * - z-near and far equal to the active camera minZ and maxZ.
  47032. * Returns the PointLight.
  47033. */
  47034. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47035. protected _buildUniformLayout(): void;
  47036. /**
  47037. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47038. * @param effect The effect to update
  47039. * @param lightIndex The index of the light in the effect to update
  47040. * @returns The point light
  47041. */
  47042. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47043. /**
  47044. * Prepares the list of defines specific to the light type.
  47045. * @param defines the list of defines
  47046. * @param lightIndex defines the index of the light for the effect
  47047. */
  47048. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47049. }
  47050. }
  47051. declare module "babylonjs/Lights/spotLight" {
  47052. import { Nullable } from "babylonjs/types";
  47053. import { Scene } from "babylonjs/scene";
  47054. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47056. import { Effect } from "babylonjs/Materials/effect";
  47057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47058. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47059. /**
  47060. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47061. * These values define a cone of light starting from the position, emitting toward the direction.
  47062. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47063. * and the exponent defines the speed of the decay of the light with distance (reach).
  47064. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47065. */
  47066. export class SpotLight extends ShadowLight {
  47067. private _angle;
  47068. private _innerAngle;
  47069. private _cosHalfAngle;
  47070. private _lightAngleScale;
  47071. private _lightAngleOffset;
  47072. /**
  47073. * Gets the cone angle of the spot light in Radians.
  47074. */
  47075. /**
  47076. * Sets the cone angle of the spot light in Radians.
  47077. */
  47078. angle: number;
  47079. /**
  47080. * Only used in gltf falloff mode, this defines the angle where
  47081. * the directional falloff will start before cutting at angle which could be seen
  47082. * as outer angle.
  47083. */
  47084. /**
  47085. * Only used in gltf falloff mode, this defines the angle where
  47086. * the directional falloff will start before cutting at angle which could be seen
  47087. * as outer angle.
  47088. */
  47089. innerAngle: number;
  47090. private _shadowAngleScale;
  47091. /**
  47092. * Allows scaling the angle of the light for shadow generation only.
  47093. */
  47094. /**
  47095. * Allows scaling the angle of the light for shadow generation only.
  47096. */
  47097. shadowAngleScale: number;
  47098. /**
  47099. * The light decay speed with the distance from the emission spot.
  47100. */
  47101. exponent: number;
  47102. private _projectionTextureMatrix;
  47103. /**
  47104. * Allows reading the projecton texture
  47105. */
  47106. readonly projectionTextureMatrix: Matrix;
  47107. protected _projectionTextureLightNear: number;
  47108. /**
  47109. * Gets the near clip of the Spotlight for texture projection.
  47110. */
  47111. /**
  47112. * Sets the near clip of the Spotlight for texture projection.
  47113. */
  47114. projectionTextureLightNear: number;
  47115. protected _projectionTextureLightFar: number;
  47116. /**
  47117. * Gets the far clip of the Spotlight for texture projection.
  47118. */
  47119. /**
  47120. * Sets the far clip of the Spotlight for texture projection.
  47121. */
  47122. projectionTextureLightFar: number;
  47123. protected _projectionTextureUpDirection: Vector3;
  47124. /**
  47125. * Gets the Up vector of the Spotlight for texture projection.
  47126. */
  47127. /**
  47128. * Sets the Up vector of the Spotlight for texture projection.
  47129. */
  47130. projectionTextureUpDirection: Vector3;
  47131. private _projectionTexture;
  47132. /**
  47133. * Gets the projection texture of the light.
  47134. */
  47135. /**
  47136. * Sets the projection texture of the light.
  47137. */
  47138. projectionTexture: Nullable<BaseTexture>;
  47139. private _projectionTextureViewLightDirty;
  47140. private _projectionTextureProjectionLightDirty;
  47141. private _projectionTextureDirty;
  47142. private _projectionTextureViewTargetVector;
  47143. private _projectionTextureViewLightMatrix;
  47144. private _projectionTextureProjectionLightMatrix;
  47145. private _projectionTextureScalingMatrix;
  47146. /**
  47147. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47148. * It can cast shadows.
  47149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47150. * @param name The light friendly name
  47151. * @param position The position of the spot light in the scene
  47152. * @param direction The direction of the light in the scene
  47153. * @param angle The cone angle of the light in Radians
  47154. * @param exponent The light decay speed with the distance from the emission spot
  47155. * @param scene The scene the lights belongs to
  47156. */
  47157. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47158. /**
  47159. * Returns the string "SpotLight".
  47160. * @returns the class name
  47161. */
  47162. getClassName(): string;
  47163. /**
  47164. * Returns the integer 2.
  47165. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47166. */
  47167. getTypeID(): number;
  47168. /**
  47169. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47170. */
  47171. protected _setDirection(value: Vector3): void;
  47172. /**
  47173. * Overrides the position setter to recompute the projection texture view light Matrix.
  47174. */
  47175. protected _setPosition(value: Vector3): void;
  47176. /**
  47177. * 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.
  47178. * Returns the SpotLight.
  47179. */
  47180. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47181. protected _computeProjectionTextureViewLightMatrix(): void;
  47182. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47183. /**
  47184. * Main function for light texture projection matrix computing.
  47185. */
  47186. protected _computeProjectionTextureMatrix(): void;
  47187. protected _buildUniformLayout(): void;
  47188. private _computeAngleValues;
  47189. /**
  47190. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47191. * @param effect The effect to update
  47192. * @param lightIndex The index of the light in the effect to update
  47193. * @returns The spot light
  47194. */
  47195. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47196. /**
  47197. * Disposes the light and the associated resources.
  47198. */
  47199. dispose(): void;
  47200. /**
  47201. * Prepares the list of defines specific to the light type.
  47202. * @param defines the list of defines
  47203. * @param lightIndex defines the index of the light for the effect
  47204. */
  47205. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47206. }
  47207. }
  47208. declare module "babylonjs/Lights/index" {
  47209. export * from "babylonjs/Lights/light";
  47210. export * from "babylonjs/Lights/shadowLight";
  47211. export * from "babylonjs/Lights/Shadows/index";
  47212. export * from "babylonjs/Lights/directionalLight";
  47213. export * from "babylonjs/Lights/hemisphericLight";
  47214. export * from "babylonjs/Lights/pointLight";
  47215. export * from "babylonjs/Lights/spotLight";
  47216. }
  47217. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47218. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47219. /**
  47220. * Header information of HDR texture files.
  47221. */
  47222. export interface HDRInfo {
  47223. /**
  47224. * The height of the texture in pixels.
  47225. */
  47226. height: number;
  47227. /**
  47228. * The width of the texture in pixels.
  47229. */
  47230. width: number;
  47231. /**
  47232. * The index of the beginning of the data in the binary file.
  47233. */
  47234. dataPosition: number;
  47235. }
  47236. /**
  47237. * This groups tools to convert HDR texture to native colors array.
  47238. */
  47239. export class HDRTools {
  47240. private static Ldexp;
  47241. private static Rgbe2float;
  47242. private static readStringLine;
  47243. /**
  47244. * Reads header information from an RGBE texture stored in a native array.
  47245. * More information on this format are available here:
  47246. * https://en.wikipedia.org/wiki/RGBE_image_format
  47247. *
  47248. * @param uint8array The binary file stored in native array.
  47249. * @return The header information.
  47250. */
  47251. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47252. /**
  47253. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47254. * This RGBE texture needs to store the information as a panorama.
  47255. *
  47256. * More information on this format are available here:
  47257. * https://en.wikipedia.org/wiki/RGBE_image_format
  47258. *
  47259. * @param buffer The binary file stored in an array buffer.
  47260. * @param size The expected size of the extracted cubemap.
  47261. * @return The Cube Map information.
  47262. */
  47263. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47264. /**
  47265. * Returns the pixels data extracted from an RGBE texture.
  47266. * This pixels will be stored left to right up to down in the R G B order in one array.
  47267. *
  47268. * More information on this format are available here:
  47269. * https://en.wikipedia.org/wiki/RGBE_image_format
  47270. *
  47271. * @param uint8array The binary file stored in an array buffer.
  47272. * @param hdrInfo The header information of the file.
  47273. * @return The pixels data in RGB right to left up to down order.
  47274. */
  47275. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47276. private static RGBE_ReadPixels_RLE;
  47277. }
  47278. }
  47279. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47280. import { Nullable } from "babylonjs/types";
  47281. import { Scene } from "babylonjs/scene";
  47282. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47284. /**
  47285. * This represents a texture coming from an HDR input.
  47286. *
  47287. * The only supported format is currently panorama picture stored in RGBE format.
  47288. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47289. */
  47290. export class HDRCubeTexture extends BaseTexture {
  47291. private static _facesMapping;
  47292. private _generateHarmonics;
  47293. private _noMipmap;
  47294. private _textureMatrix;
  47295. private _size;
  47296. private _onLoad;
  47297. private _onError;
  47298. /**
  47299. * The texture URL.
  47300. */
  47301. url: string;
  47302. /**
  47303. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47304. */
  47305. coordinatesMode: number;
  47306. protected _isBlocking: boolean;
  47307. /**
  47308. * Sets wether or not the texture is blocking during loading.
  47309. */
  47310. /**
  47311. * Gets wether or not the texture is blocking during loading.
  47312. */
  47313. isBlocking: boolean;
  47314. protected _rotationY: number;
  47315. /**
  47316. * Sets texture matrix rotation angle around Y axis in radians.
  47317. */
  47318. /**
  47319. * Gets texture matrix rotation angle around Y axis radians.
  47320. */
  47321. rotationY: number;
  47322. /**
  47323. * Gets or sets the center of the bounding box associated with the cube texture
  47324. * It must define where the camera used to render the texture was set
  47325. */
  47326. boundingBoxPosition: Vector3;
  47327. private _boundingBoxSize;
  47328. /**
  47329. * Gets or sets the size of the bounding box associated with the cube texture
  47330. * When defined, the cubemap will switch to local mode
  47331. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47332. * @example https://www.babylonjs-playground.com/#RNASML
  47333. */
  47334. boundingBoxSize: Vector3;
  47335. /**
  47336. * Instantiates an HDRTexture from the following parameters.
  47337. *
  47338. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47339. * @param scene The scene the texture will be used in
  47340. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47341. * @param noMipmap Forces to not generate the mipmap if true
  47342. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47343. * @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)
  47344. * @param reserved Reserved flag for internal use.
  47345. */
  47346. 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>);
  47347. /**
  47348. * Get the current class name of the texture useful for serialization or dynamic coding.
  47349. * @returns "HDRCubeTexture"
  47350. */
  47351. getClassName(): string;
  47352. /**
  47353. * Occurs when the file is raw .hdr file.
  47354. */
  47355. private loadTexture;
  47356. clone(): HDRCubeTexture;
  47357. delayLoad(): void;
  47358. /**
  47359. * Get the texture reflection matrix used to rotate/transform the reflection.
  47360. * @returns the reflection matrix
  47361. */
  47362. getReflectionTextureMatrix(): Matrix;
  47363. /**
  47364. * Set the texture reflection matrix used to rotate/transform the reflection.
  47365. * @param value Define the reflection matrix to set
  47366. */
  47367. setReflectionTextureMatrix(value: Matrix): void;
  47368. /**
  47369. * Parses a JSON representation of an HDR Texture in order to create the texture
  47370. * @param parsedTexture Define the JSON representation
  47371. * @param scene Define the scene the texture should be created in
  47372. * @param rootUrl Define the root url in case we need to load relative dependencies
  47373. * @returns the newly created texture after parsing
  47374. */
  47375. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47376. serialize(): any;
  47377. }
  47378. }
  47379. declare module "babylonjs/Physics/physicsEngine" {
  47380. import { Nullable } from "babylonjs/types";
  47381. import { Vector3 } from "babylonjs/Maths/math";
  47382. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47383. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47384. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47385. /**
  47386. * Class used to control physics engine
  47387. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47388. */
  47389. export class PhysicsEngine implements IPhysicsEngine {
  47390. private _physicsPlugin;
  47391. /**
  47392. * Global value used to control the smallest number supported by the simulation
  47393. */
  47394. static Epsilon: number;
  47395. private _impostors;
  47396. private _joints;
  47397. /**
  47398. * Gets the gravity vector used by the simulation
  47399. */
  47400. gravity: Vector3;
  47401. /**
  47402. * Factory used to create the default physics plugin.
  47403. * @returns The default physics plugin
  47404. */
  47405. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47406. /**
  47407. * Creates a new Physics Engine
  47408. * @param gravity defines the gravity vector used by the simulation
  47409. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47410. */
  47411. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47412. /**
  47413. * Sets the gravity vector used by the simulation
  47414. * @param gravity defines the gravity vector to use
  47415. */
  47416. setGravity(gravity: Vector3): void;
  47417. /**
  47418. * Set the time step of the physics engine.
  47419. * Default is 1/60.
  47420. * To slow it down, enter 1/600 for example.
  47421. * To speed it up, 1/30
  47422. * @param newTimeStep defines the new timestep to apply to this world.
  47423. */
  47424. setTimeStep(newTimeStep?: number): void;
  47425. /**
  47426. * Get the time step of the physics engine.
  47427. * @returns the current time step
  47428. */
  47429. getTimeStep(): number;
  47430. /**
  47431. * Release all resources
  47432. */
  47433. dispose(): void;
  47434. /**
  47435. * Gets the name of the current physics plugin
  47436. * @returns the name of the plugin
  47437. */
  47438. getPhysicsPluginName(): string;
  47439. /**
  47440. * Adding a new impostor for the impostor tracking.
  47441. * This will be done by the impostor itself.
  47442. * @param impostor the impostor to add
  47443. */
  47444. addImpostor(impostor: PhysicsImpostor): void;
  47445. /**
  47446. * Remove an impostor from the engine.
  47447. * This impostor and its mesh will not longer be updated by the physics engine.
  47448. * @param impostor the impostor to remove
  47449. */
  47450. removeImpostor(impostor: PhysicsImpostor): void;
  47451. /**
  47452. * Add a joint to the physics engine
  47453. * @param mainImpostor defines the main impostor to which the joint is added.
  47454. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47455. * @param joint defines the joint that will connect both impostors.
  47456. */
  47457. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47458. /**
  47459. * Removes a joint from the simulation
  47460. * @param mainImpostor defines the impostor used with the joint
  47461. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47462. * @param joint defines the joint to remove
  47463. */
  47464. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47465. /**
  47466. * Called by the scene. No need to call it.
  47467. * @param delta defines the timespam between frames
  47468. */
  47469. _step(delta: number): void;
  47470. /**
  47471. * Gets the current plugin used to run the simulation
  47472. * @returns current plugin
  47473. */
  47474. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47475. /**
  47476. * Gets the list of physic impostors
  47477. * @returns an array of PhysicsImpostor
  47478. */
  47479. getImpostors(): Array<PhysicsImpostor>;
  47480. /**
  47481. * Gets the impostor for a physics enabled object
  47482. * @param object defines the object impersonated by the impostor
  47483. * @returns the PhysicsImpostor or null if not found
  47484. */
  47485. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47486. /**
  47487. * Gets the impostor for a physics body object
  47488. * @param body defines physics body used by the impostor
  47489. * @returns the PhysicsImpostor or null if not found
  47490. */
  47491. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47492. }
  47493. }
  47494. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47495. import { Nullable } from "babylonjs/types";
  47496. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47498. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47499. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47500. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47501. /** @hidden */
  47502. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47503. private _useDeltaForWorldStep;
  47504. world: any;
  47505. name: string;
  47506. private _physicsMaterials;
  47507. private _fixedTimeStep;
  47508. BJSCANNON: any;
  47509. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47510. setGravity(gravity: Vector3): void;
  47511. setTimeStep(timeStep: number): void;
  47512. getTimeStep(): number;
  47513. executeStep(delta: number): void;
  47514. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47515. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47516. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47517. private _processChildMeshes;
  47518. removePhysicsBody(impostor: PhysicsImpostor): void;
  47519. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47520. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47521. private _addMaterial;
  47522. private _checkWithEpsilon;
  47523. private _createShape;
  47524. private _createHeightmap;
  47525. private _minus90X;
  47526. private _plus90X;
  47527. private _tmpPosition;
  47528. private _tmpDeltaPosition;
  47529. private _tmpUnityRotation;
  47530. private _updatePhysicsBodyTransformation;
  47531. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47532. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47533. isSupported(): boolean;
  47534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47535. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47536. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47537. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47538. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47539. getBodyMass(impostor: PhysicsImpostor): number;
  47540. getBodyFriction(impostor: PhysicsImpostor): number;
  47541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47542. getBodyRestitution(impostor: PhysicsImpostor): number;
  47543. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47544. sleepBody(impostor: PhysicsImpostor): void;
  47545. wakeUpBody(impostor: PhysicsImpostor): void;
  47546. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47547. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47548. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47550. getRadius(impostor: PhysicsImpostor): number;
  47551. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47552. dispose(): void;
  47553. private _extendNamespace;
  47554. }
  47555. }
  47556. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47557. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47558. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47559. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47561. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47562. import { Nullable } from "babylonjs/types";
  47563. /** @hidden */
  47564. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47565. world: any;
  47566. name: string;
  47567. BJSOIMO: any;
  47568. constructor(iterations?: number, oimoInjection?: any);
  47569. setGravity(gravity: Vector3): void;
  47570. setTimeStep(timeStep: number): void;
  47571. getTimeStep(): number;
  47572. private _tmpImpostorsArray;
  47573. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47574. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47576. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47577. private _tmpPositionVector;
  47578. removePhysicsBody(impostor: PhysicsImpostor): void;
  47579. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47581. isSupported(): boolean;
  47582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47583. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47589. getBodyMass(impostor: PhysicsImpostor): number;
  47590. getBodyFriction(impostor: PhysicsImpostor): number;
  47591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47592. getBodyRestitution(impostor: PhysicsImpostor): number;
  47593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47594. sleepBody(impostor: PhysicsImpostor): void;
  47595. wakeUpBody(impostor: PhysicsImpostor): void;
  47596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47597. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47600. getRadius(impostor: PhysicsImpostor): number;
  47601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47602. dispose(): void;
  47603. }
  47604. }
  47605. declare module "babylonjs/Probes/reflectionProbe" {
  47606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47607. import { Vector3 } from "babylonjs/Maths/math";
  47608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47609. import { Nullable } from "babylonjs/types";
  47610. import { Scene } from "babylonjs/scene";
  47611. module "babylonjs/abstractScene" {
  47612. interface AbstractScene {
  47613. /**
  47614. * The list of reflection probes added to the scene
  47615. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47616. */
  47617. reflectionProbes: Array<ReflectionProbe>;
  47618. /**
  47619. * Removes the given reflection probe from this scene.
  47620. * @param toRemove The reflection probe to remove
  47621. * @returns The index of the removed reflection probe
  47622. */
  47623. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47624. /**
  47625. * Adds the given reflection probe to this scene.
  47626. * @param newReflectionProbe The reflection probe to add
  47627. */
  47628. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47629. }
  47630. }
  47631. /**
  47632. * Class used to generate realtime reflection / refraction cube textures
  47633. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47634. */
  47635. export class ReflectionProbe {
  47636. /** defines the name of the probe */
  47637. name: string;
  47638. private _scene;
  47639. private _renderTargetTexture;
  47640. private _projectionMatrix;
  47641. private _viewMatrix;
  47642. private _target;
  47643. private _add;
  47644. private _attachedMesh;
  47645. private _invertYAxis;
  47646. /** Gets or sets probe position (center of the cube map) */
  47647. position: Vector3;
  47648. /**
  47649. * Creates a new reflection probe
  47650. * @param name defines the name of the probe
  47651. * @param size defines the texture resolution (for each face)
  47652. * @param scene defines the hosting scene
  47653. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47654. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47655. */
  47656. constructor(
  47657. /** defines the name of the probe */
  47658. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47659. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47660. samples: number;
  47661. /** Gets or sets the refresh rate to use (on every frame by default) */
  47662. refreshRate: number;
  47663. /**
  47664. * Gets the hosting scene
  47665. * @returns a Scene
  47666. */
  47667. getScene(): Scene;
  47668. /** Gets the internal CubeTexture used to render to */
  47669. readonly cubeTexture: RenderTargetTexture;
  47670. /** Gets the list of meshes to render */
  47671. readonly renderList: Nullable<AbstractMesh[]>;
  47672. /**
  47673. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47674. * @param mesh defines the mesh to attach to
  47675. */
  47676. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47677. /**
  47678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47679. * @param renderingGroupId The rendering group id corresponding to its index
  47680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47681. */
  47682. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47683. /**
  47684. * Clean all associated resources
  47685. */
  47686. dispose(): void;
  47687. /**
  47688. * Converts the reflection probe information to a readable string for debug purpose.
  47689. * @param fullDetails Supports for multiple levels of logging within scene loading
  47690. * @returns the human readable reflection probe info
  47691. */
  47692. toString(fullDetails?: boolean): string;
  47693. /**
  47694. * Get the class name of the relfection probe.
  47695. * @returns "ReflectionProbe"
  47696. */
  47697. getClassName(): string;
  47698. /**
  47699. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47700. * @returns The JSON representation of the texture
  47701. */
  47702. serialize(): any;
  47703. /**
  47704. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47705. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47706. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47708. * @returns The parsed reflection probe if successful
  47709. */
  47710. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47711. }
  47712. }
  47713. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47714. /** @hidden */
  47715. export var _BabylonLoaderRegistered: boolean;
  47716. }
  47717. declare module "babylonjs/Loading/Plugins/index" {
  47718. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47719. }
  47720. declare module "babylonjs/Loading/index" {
  47721. export * from "babylonjs/Loading/loadingScreen";
  47722. export * from "babylonjs/Loading/Plugins/index";
  47723. export * from "babylonjs/Loading/sceneLoader";
  47724. export * from "babylonjs/Loading/sceneLoaderFlags";
  47725. }
  47726. declare module "babylonjs/Materials/Background/index" {
  47727. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47728. }
  47729. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47730. import { Scene } from "babylonjs/scene";
  47731. import { Color3 } from "babylonjs/Maths/math";
  47732. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47734. /**
  47735. * The Physically based simple base material of BJS.
  47736. *
  47737. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47738. * It is used as the base class for both the specGloss and metalRough conventions.
  47739. */
  47740. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47741. /**
  47742. * Number of Simultaneous lights allowed on the material.
  47743. */
  47744. maxSimultaneousLights: number;
  47745. /**
  47746. * If sets to true, disables all the lights affecting the material.
  47747. */
  47748. disableLighting: boolean;
  47749. /**
  47750. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47751. */
  47752. environmentTexture: BaseTexture;
  47753. /**
  47754. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47755. */
  47756. invertNormalMapX: boolean;
  47757. /**
  47758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47759. */
  47760. invertNormalMapY: boolean;
  47761. /**
  47762. * Normal map used in the model.
  47763. */
  47764. normalTexture: BaseTexture;
  47765. /**
  47766. * Emissivie color used to self-illuminate the model.
  47767. */
  47768. emissiveColor: Color3;
  47769. /**
  47770. * Emissivie texture used to self-illuminate the model.
  47771. */
  47772. emissiveTexture: BaseTexture;
  47773. /**
  47774. * Occlusion Channel Strenght.
  47775. */
  47776. occlusionStrength: number;
  47777. /**
  47778. * Occlusion Texture of the material (adding extra occlusion effects).
  47779. */
  47780. occlusionTexture: BaseTexture;
  47781. /**
  47782. * Defines the alpha limits in alpha test mode.
  47783. */
  47784. alphaCutOff: number;
  47785. /**
  47786. * Gets the current double sided mode.
  47787. */
  47788. /**
  47789. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47790. */
  47791. doubleSided: boolean;
  47792. /**
  47793. * Stores the pre-calculated light information of a mesh in a texture.
  47794. */
  47795. lightmapTexture: BaseTexture;
  47796. /**
  47797. * If true, the light map contains occlusion information instead of lighting info.
  47798. */
  47799. useLightmapAsShadowmap: boolean;
  47800. /**
  47801. * Instantiates a new PBRMaterial instance.
  47802. *
  47803. * @param name The material name
  47804. * @param scene The scene the material will be use in.
  47805. */
  47806. constructor(name: string, scene: Scene);
  47807. getClassName(): string;
  47808. }
  47809. }
  47810. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47811. import { Scene } from "babylonjs/scene";
  47812. import { Color3 } from "babylonjs/Maths/math";
  47813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47814. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47815. /**
  47816. * The PBR material of BJS following the metal roughness convention.
  47817. *
  47818. * This fits to the PBR convention in the GLTF definition:
  47819. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47820. */
  47821. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47822. /**
  47823. * The base color has two different interpretations depending on the value of metalness.
  47824. * When the material is a metal, the base color is the specific measured reflectance value
  47825. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47826. * of the material.
  47827. */
  47828. baseColor: Color3;
  47829. /**
  47830. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47831. * well as opacity information in the alpha channel.
  47832. */
  47833. baseTexture: BaseTexture;
  47834. /**
  47835. * Specifies the metallic scalar value of the material.
  47836. * Can also be used to scale the metalness values of the metallic texture.
  47837. */
  47838. metallic: number;
  47839. /**
  47840. * Specifies the roughness scalar value of the material.
  47841. * Can also be used to scale the roughness values of the metallic texture.
  47842. */
  47843. roughness: number;
  47844. /**
  47845. * Texture containing both the metallic value in the B channel and the
  47846. * roughness value in the G channel to keep better precision.
  47847. */
  47848. metallicRoughnessTexture: BaseTexture;
  47849. /**
  47850. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47851. *
  47852. * @param name The material name
  47853. * @param scene The scene the material will be use in.
  47854. */
  47855. constructor(name: string, scene: Scene);
  47856. /**
  47857. * Return the currrent class name of the material.
  47858. */
  47859. getClassName(): string;
  47860. /**
  47861. * Makes a duplicate of the current material.
  47862. * @param name - name to use for the new material.
  47863. */
  47864. clone(name: string): PBRMetallicRoughnessMaterial;
  47865. /**
  47866. * Serialize the material to a parsable JSON object.
  47867. */
  47868. serialize(): any;
  47869. /**
  47870. * Parses a JSON object correponding to the serialize function.
  47871. */
  47872. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47873. }
  47874. }
  47875. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47876. import { Scene } from "babylonjs/scene";
  47877. import { Color3 } from "babylonjs/Maths/math";
  47878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47879. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47880. /**
  47881. * The PBR material of BJS following the specular glossiness convention.
  47882. *
  47883. * This fits to the PBR convention in the GLTF definition:
  47884. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47885. */
  47886. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47887. /**
  47888. * Specifies the diffuse color of the material.
  47889. */
  47890. diffuseColor: Color3;
  47891. /**
  47892. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47893. * channel.
  47894. */
  47895. diffuseTexture: BaseTexture;
  47896. /**
  47897. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47898. */
  47899. specularColor: Color3;
  47900. /**
  47901. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47902. */
  47903. glossiness: number;
  47904. /**
  47905. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47906. */
  47907. specularGlossinessTexture: BaseTexture;
  47908. /**
  47909. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47910. *
  47911. * @param name The material name
  47912. * @param scene The scene the material will be use in.
  47913. */
  47914. constructor(name: string, scene: Scene);
  47915. /**
  47916. * Return the currrent class name of the material.
  47917. */
  47918. getClassName(): string;
  47919. /**
  47920. * Makes a duplicate of the current material.
  47921. * @param name - name to use for the new material.
  47922. */
  47923. clone(name: string): PBRSpecularGlossinessMaterial;
  47924. /**
  47925. * Serialize the material to a parsable JSON object.
  47926. */
  47927. serialize(): any;
  47928. /**
  47929. * Parses a JSON object correponding to the serialize function.
  47930. */
  47931. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47932. }
  47933. }
  47934. declare module "babylonjs/Materials/PBR/index" {
  47935. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47936. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47937. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47938. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47939. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47940. }
  47941. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47942. import { Nullable } from "babylonjs/types";
  47943. import { Scene } from "babylonjs/scene";
  47944. import { Matrix } from "babylonjs/Maths/math";
  47945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47946. /**
  47947. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47948. * It can help converting any input color in a desired output one. This can then be used to create effects
  47949. * from sepia, black and white to sixties or futuristic rendering...
  47950. *
  47951. * The only supported format is currently 3dl.
  47952. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47953. */
  47954. export class ColorGradingTexture extends BaseTexture {
  47955. /**
  47956. * The current texture matrix. (will always be identity in color grading texture)
  47957. */
  47958. private _textureMatrix;
  47959. /**
  47960. * The texture URL.
  47961. */
  47962. url: string;
  47963. /**
  47964. * Empty line regex stored for GC.
  47965. */
  47966. private static _noneEmptyLineRegex;
  47967. private _engine;
  47968. /**
  47969. * Instantiates a ColorGradingTexture from the following parameters.
  47970. *
  47971. * @param url The location of the color gradind data (currently only supporting 3dl)
  47972. * @param scene The scene the texture will be used in
  47973. */
  47974. constructor(url: string, scene: Scene);
  47975. /**
  47976. * Returns the texture matrix used in most of the material.
  47977. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47978. */
  47979. getTextureMatrix(): Matrix;
  47980. /**
  47981. * Occurs when the file being loaded is a .3dl LUT file.
  47982. */
  47983. private load3dlTexture;
  47984. /**
  47985. * Starts the loading process of the texture.
  47986. */
  47987. private loadTexture;
  47988. /**
  47989. * Clones the color gradind texture.
  47990. */
  47991. clone(): ColorGradingTexture;
  47992. /**
  47993. * Called during delayed load for textures.
  47994. */
  47995. delayLoad(): void;
  47996. /**
  47997. * Parses a color grading texture serialized by Babylon.
  47998. * @param parsedTexture The texture information being parsedTexture
  47999. * @param scene The scene to load the texture in
  48000. * @param rootUrl The root url of the data assets to load
  48001. * @return A color gradind texture
  48002. */
  48003. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48004. /**
  48005. * Serializes the LUT texture to json format.
  48006. */
  48007. serialize(): any;
  48008. }
  48009. }
  48010. declare module "babylonjs/Misc/dds" {
  48011. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48012. import { Engine } from "babylonjs/Engines/engine";
  48013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48014. import { Nullable } from "babylonjs/types";
  48015. import { Scene } from "babylonjs/scene";
  48016. /**
  48017. * Direct draw surface info
  48018. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48019. */
  48020. export interface DDSInfo {
  48021. /**
  48022. * Width of the texture
  48023. */
  48024. width: number;
  48025. /**
  48026. * Width of the texture
  48027. */
  48028. height: number;
  48029. /**
  48030. * Number of Mipmaps for the texture
  48031. * @see https://en.wikipedia.org/wiki/Mipmap
  48032. */
  48033. mipmapCount: number;
  48034. /**
  48035. * If the textures format is a known fourCC format
  48036. * @see https://www.fourcc.org/
  48037. */
  48038. isFourCC: boolean;
  48039. /**
  48040. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48041. */
  48042. isRGB: boolean;
  48043. /**
  48044. * If the texture is a lumincance format
  48045. */
  48046. isLuminance: boolean;
  48047. /**
  48048. * If this is a cube texture
  48049. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48050. */
  48051. isCube: boolean;
  48052. /**
  48053. * If the texture is a compressed format eg. FOURCC_DXT1
  48054. */
  48055. isCompressed: boolean;
  48056. /**
  48057. * The dxgiFormat of the texture
  48058. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48059. */
  48060. dxgiFormat: number;
  48061. /**
  48062. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48063. */
  48064. textureType: number;
  48065. /**
  48066. * Sphericle polynomial created for the dds texture
  48067. */
  48068. sphericalPolynomial?: SphericalPolynomial;
  48069. }
  48070. /**
  48071. * Class used to provide DDS decompression tools
  48072. */
  48073. export class DDSTools {
  48074. /**
  48075. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48076. */
  48077. static StoreLODInAlphaChannel: boolean;
  48078. /**
  48079. * Gets DDS information from an array buffer
  48080. * @param arrayBuffer defines the array buffer to read data from
  48081. * @returns the DDS information
  48082. */
  48083. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48084. private static _FloatView;
  48085. private static _Int32View;
  48086. private static _ToHalfFloat;
  48087. private static _FromHalfFloat;
  48088. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48089. private static _GetHalfFloatRGBAArrayBuffer;
  48090. private static _GetFloatRGBAArrayBuffer;
  48091. private static _GetFloatAsUIntRGBAArrayBuffer;
  48092. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48093. private static _GetRGBAArrayBuffer;
  48094. private static _ExtractLongWordOrder;
  48095. private static _GetRGBArrayBuffer;
  48096. private static _GetLuminanceArrayBuffer;
  48097. /**
  48098. * Uploads DDS Levels to a Babylon Texture
  48099. * @hidden
  48100. */
  48101. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48102. }
  48103. module "babylonjs/Engines/engine" {
  48104. interface Engine {
  48105. /**
  48106. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48107. * @param rootUrl defines the url where the file to load is located
  48108. * @param scene defines the current scene
  48109. * @param lodScale defines scale to apply to the mip map selection
  48110. * @param lodOffset defines offset to apply to the mip map selection
  48111. * @param onLoad defines an optional callback raised when the texture is loaded
  48112. * @param onError defines an optional callback raised if there is an issue to load the texture
  48113. * @param format defines the format of the data
  48114. * @param forcedExtension defines the extension to use to pick the right loader
  48115. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48116. * @returns the cube texture as an InternalTexture
  48117. */
  48118. 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;
  48119. }
  48120. }
  48121. }
  48122. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48123. import { Nullable } from "babylonjs/types";
  48124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48125. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48126. /**
  48127. * Implementation of the DDS Texture Loader.
  48128. * @hidden
  48129. */
  48130. export class _DDSTextureLoader implements IInternalTextureLoader {
  48131. /**
  48132. * Defines wether the loader supports cascade loading the different faces.
  48133. */
  48134. readonly supportCascades: boolean;
  48135. /**
  48136. * This returns if the loader support the current file information.
  48137. * @param extension defines the file extension of the file being loaded
  48138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48139. * @param fallback defines the fallback internal texture if any
  48140. * @param isBase64 defines whether the texture is encoded as a base64
  48141. * @param isBuffer defines whether the texture data are stored as a buffer
  48142. * @returns true if the loader can load the specified file
  48143. */
  48144. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48145. /**
  48146. * Transform the url before loading if required.
  48147. * @param rootUrl the url of the texture
  48148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48149. * @returns the transformed texture
  48150. */
  48151. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48152. /**
  48153. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48154. * @param rootUrl the url of the texture
  48155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48156. * @returns the fallback texture
  48157. */
  48158. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48159. /**
  48160. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48161. * @param data contains the texture data
  48162. * @param texture defines the BabylonJS internal texture
  48163. * @param createPolynomials will be true if polynomials have been requested
  48164. * @param onLoad defines the callback to trigger once the texture is ready
  48165. * @param onError defines the callback to trigger in case of error
  48166. */
  48167. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48168. /**
  48169. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48170. * @param data contains the texture data
  48171. * @param texture defines the BabylonJS internal texture
  48172. * @param callback defines the method to call once ready to upload
  48173. */
  48174. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48175. }
  48176. }
  48177. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48178. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48179. /** @hidden */
  48180. export var rgbdEncodePixelShader: {
  48181. name: string;
  48182. shader: string;
  48183. };
  48184. }
  48185. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48187. /** @hidden */
  48188. export var rgbdDecodePixelShader: {
  48189. name: string;
  48190. shader: string;
  48191. };
  48192. }
  48193. declare module "babylonjs/Misc/environmentTextureTools" {
  48194. import { Nullable } from "babylonjs/types";
  48195. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48197. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48198. import "babylonjs/Shaders/rgbdEncode.fragment";
  48199. import "babylonjs/Shaders/rgbdDecode.fragment";
  48200. /**
  48201. * Raw texture data and descriptor sufficient for WebGL texture upload
  48202. */
  48203. export interface EnvironmentTextureInfo {
  48204. /**
  48205. * Version of the environment map
  48206. */
  48207. version: number;
  48208. /**
  48209. * Width of image
  48210. */
  48211. width: number;
  48212. /**
  48213. * Irradiance information stored in the file.
  48214. */
  48215. irradiance: any;
  48216. /**
  48217. * Specular information stored in the file.
  48218. */
  48219. specular: any;
  48220. }
  48221. /**
  48222. * Sets of helpers addressing the serialization and deserialization of environment texture
  48223. * stored in a BabylonJS env file.
  48224. * Those files are usually stored as .env files.
  48225. */
  48226. export class EnvironmentTextureTools {
  48227. /**
  48228. * Magic number identifying the env file.
  48229. */
  48230. private static _MagicBytes;
  48231. /**
  48232. * Gets the environment info from an env file.
  48233. * @param data The array buffer containing the .env bytes.
  48234. * @returns the environment file info (the json header) if successfully parsed.
  48235. */
  48236. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48237. /**
  48238. * Creates an environment texture from a loaded cube texture.
  48239. * @param texture defines the cube texture to convert in env file
  48240. * @return a promise containing the environment data if succesfull.
  48241. */
  48242. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48243. /**
  48244. * Creates a JSON representation of the spherical data.
  48245. * @param texture defines the texture containing the polynomials
  48246. * @return the JSON representation of the spherical info
  48247. */
  48248. private static _CreateEnvTextureIrradiance;
  48249. /**
  48250. * Uploads the texture info contained in the env file to the GPU.
  48251. * @param texture defines the internal texture to upload to
  48252. * @param arrayBuffer defines the buffer cotaining the data to load
  48253. * @param info defines the texture info retrieved through the GetEnvInfo method
  48254. * @returns a promise
  48255. */
  48256. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48257. /**
  48258. * Uploads the levels of image data to the GPU.
  48259. * @param texture defines the internal texture to upload to
  48260. * @param imageData defines the array buffer views of image data [mipmap][face]
  48261. * @returns a promise
  48262. */
  48263. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48264. /**
  48265. * Uploads spherical polynomials information to the texture.
  48266. * @param texture defines the texture we are trying to upload the information to
  48267. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48268. */
  48269. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48270. /** @hidden */
  48271. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48272. }
  48273. }
  48274. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48275. import { Nullable } from "babylonjs/types";
  48276. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48277. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48278. /**
  48279. * Implementation of the ENV Texture Loader.
  48280. * @hidden
  48281. */
  48282. export class _ENVTextureLoader implements IInternalTextureLoader {
  48283. /**
  48284. * Defines wether the loader supports cascade loading the different faces.
  48285. */
  48286. readonly supportCascades: boolean;
  48287. /**
  48288. * This returns if the loader support the current file information.
  48289. * @param extension defines the file extension of the file being loaded
  48290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48291. * @param fallback defines the fallback internal texture if any
  48292. * @param isBase64 defines whether the texture is encoded as a base64
  48293. * @param isBuffer defines whether the texture data are stored as a buffer
  48294. * @returns true if the loader can load the specified file
  48295. */
  48296. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48297. /**
  48298. * Transform the url before loading if required.
  48299. * @param rootUrl the url of the texture
  48300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48301. * @returns the transformed texture
  48302. */
  48303. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48304. /**
  48305. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48306. * @param rootUrl the url of the texture
  48307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48308. * @returns the fallback texture
  48309. */
  48310. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48311. /**
  48312. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48313. * @param data contains the texture data
  48314. * @param texture defines the BabylonJS internal texture
  48315. * @param createPolynomials will be true if polynomials have been requested
  48316. * @param onLoad defines the callback to trigger once the texture is ready
  48317. * @param onError defines the callback to trigger in case of error
  48318. */
  48319. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48320. /**
  48321. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48322. * @param data contains the texture data
  48323. * @param texture defines the BabylonJS internal texture
  48324. * @param callback defines the method to call once ready to upload
  48325. */
  48326. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48327. }
  48328. }
  48329. declare module "babylonjs/Misc/khronosTextureContainer" {
  48330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48331. /**
  48332. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48333. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48334. */
  48335. export class KhronosTextureContainer {
  48336. /** contents of the KTX container file */
  48337. arrayBuffer: any;
  48338. private static HEADER_LEN;
  48339. private static COMPRESSED_2D;
  48340. private static COMPRESSED_3D;
  48341. private static TEX_2D;
  48342. private static TEX_3D;
  48343. /**
  48344. * Gets the openGL type
  48345. */
  48346. glType: number;
  48347. /**
  48348. * Gets the openGL type size
  48349. */
  48350. glTypeSize: number;
  48351. /**
  48352. * Gets the openGL format
  48353. */
  48354. glFormat: number;
  48355. /**
  48356. * Gets the openGL internal format
  48357. */
  48358. glInternalFormat: number;
  48359. /**
  48360. * Gets the base internal format
  48361. */
  48362. glBaseInternalFormat: number;
  48363. /**
  48364. * Gets image width in pixel
  48365. */
  48366. pixelWidth: number;
  48367. /**
  48368. * Gets image height in pixel
  48369. */
  48370. pixelHeight: number;
  48371. /**
  48372. * Gets image depth in pixels
  48373. */
  48374. pixelDepth: number;
  48375. /**
  48376. * Gets the number of array elements
  48377. */
  48378. numberOfArrayElements: number;
  48379. /**
  48380. * Gets the number of faces
  48381. */
  48382. numberOfFaces: number;
  48383. /**
  48384. * Gets the number of mipmap levels
  48385. */
  48386. numberOfMipmapLevels: number;
  48387. /**
  48388. * Gets the bytes of key value data
  48389. */
  48390. bytesOfKeyValueData: number;
  48391. /**
  48392. * Gets the load type
  48393. */
  48394. loadType: number;
  48395. /**
  48396. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48397. */
  48398. isInvalid: boolean;
  48399. /**
  48400. * Creates a new KhronosTextureContainer
  48401. * @param arrayBuffer contents of the KTX container file
  48402. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48403. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48404. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48405. */
  48406. constructor(
  48407. /** contents of the KTX container file */
  48408. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48409. /**
  48410. * Uploads KTX content to a Babylon Texture.
  48411. * It is assumed that the texture has already been created & is currently bound
  48412. * @hidden
  48413. */
  48414. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48415. private _upload2DCompressedLevels;
  48416. }
  48417. }
  48418. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48419. import { Nullable } from "babylonjs/types";
  48420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48421. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48422. /**
  48423. * Implementation of the KTX Texture Loader.
  48424. * @hidden
  48425. */
  48426. export class _KTXTextureLoader implements IInternalTextureLoader {
  48427. /**
  48428. * Defines wether the loader supports cascade loading the different faces.
  48429. */
  48430. readonly supportCascades: boolean;
  48431. /**
  48432. * This returns if the loader support the current file information.
  48433. * @param extension defines the file extension of the file being loaded
  48434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48435. * @param fallback defines the fallback internal texture if any
  48436. * @param isBase64 defines whether the texture is encoded as a base64
  48437. * @param isBuffer defines whether the texture data are stored as a buffer
  48438. * @returns true if the loader can load the specified file
  48439. */
  48440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48441. /**
  48442. * Transform the url before loading if required.
  48443. * @param rootUrl the url of the texture
  48444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48445. * @returns the transformed texture
  48446. */
  48447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48448. /**
  48449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48450. * @param rootUrl the url of the texture
  48451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48452. * @returns the fallback texture
  48453. */
  48454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48455. /**
  48456. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48457. * @param data contains the texture data
  48458. * @param texture defines the BabylonJS internal texture
  48459. * @param createPolynomials will be true if polynomials have been requested
  48460. * @param onLoad defines the callback to trigger once the texture is ready
  48461. * @param onError defines the callback to trigger in case of error
  48462. */
  48463. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48464. /**
  48465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48466. * @param data contains the texture data
  48467. * @param texture defines the BabylonJS internal texture
  48468. * @param callback defines the method to call once ready to upload
  48469. */
  48470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48471. }
  48472. }
  48473. declare module "babylonjs/Misc/tga" {
  48474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48475. /**
  48476. * Based on jsTGALoader - Javascript loader for TGA file
  48477. * By Vincent Thibault
  48478. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48479. */
  48480. export class TGATools {
  48481. private static _TYPE_INDEXED;
  48482. private static _TYPE_RGB;
  48483. private static _TYPE_GREY;
  48484. private static _TYPE_RLE_INDEXED;
  48485. private static _TYPE_RLE_RGB;
  48486. private static _TYPE_RLE_GREY;
  48487. private static _ORIGIN_MASK;
  48488. private static _ORIGIN_SHIFT;
  48489. private static _ORIGIN_BL;
  48490. private static _ORIGIN_BR;
  48491. private static _ORIGIN_UL;
  48492. private static _ORIGIN_UR;
  48493. /**
  48494. * Gets the header of a TGA file
  48495. * @param data defines the TGA data
  48496. * @returns the header
  48497. */
  48498. static GetTGAHeader(data: Uint8Array): any;
  48499. /**
  48500. * Uploads TGA content to a Babylon Texture
  48501. * @hidden
  48502. */
  48503. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48504. /** @hidden */
  48505. 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;
  48506. /** @hidden */
  48507. 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;
  48508. /** @hidden */
  48509. 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;
  48510. /** @hidden */
  48511. 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;
  48512. /** @hidden */
  48513. 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;
  48514. /** @hidden */
  48515. 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;
  48516. }
  48517. }
  48518. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48519. import { Nullable } from "babylonjs/types";
  48520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48521. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48522. /**
  48523. * Implementation of the TGA Texture Loader.
  48524. * @hidden
  48525. */
  48526. export class _TGATextureLoader implements IInternalTextureLoader {
  48527. /**
  48528. * Defines wether the loader supports cascade loading the different faces.
  48529. */
  48530. readonly supportCascades: boolean;
  48531. /**
  48532. * This returns if the loader support the current file information.
  48533. * @param extension defines the file extension of the file being loaded
  48534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48535. * @param fallback defines the fallback internal texture if any
  48536. * @param isBase64 defines whether the texture is encoded as a base64
  48537. * @param isBuffer defines whether the texture data are stored as a buffer
  48538. * @returns true if the loader can load the specified file
  48539. */
  48540. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48541. /**
  48542. * Transform the url before loading if required.
  48543. * @param rootUrl the url of the texture
  48544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48545. * @returns the transformed texture
  48546. */
  48547. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48548. /**
  48549. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48550. * @param rootUrl the url of the texture
  48551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48552. * @returns the fallback texture
  48553. */
  48554. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48555. /**
  48556. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48557. * @param data contains the texture data
  48558. * @param texture defines the BabylonJS internal texture
  48559. * @param createPolynomials will be true if polynomials have been requested
  48560. * @param onLoad defines the callback to trigger once the texture is ready
  48561. * @param onError defines the callback to trigger in case of error
  48562. */
  48563. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48564. /**
  48565. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48566. * @param data contains the texture data
  48567. * @param texture defines the BabylonJS internal texture
  48568. * @param callback defines the method to call once ready to upload
  48569. */
  48570. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48571. }
  48572. }
  48573. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48574. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48575. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48576. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48577. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48578. }
  48579. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48580. import { Scene } from "babylonjs/scene";
  48581. import { Texture } from "babylonjs/Materials/Textures/texture";
  48582. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48583. /**
  48584. * 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.
  48585. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48587. */
  48588. export class CustomProceduralTexture extends ProceduralTexture {
  48589. private _animate;
  48590. private _time;
  48591. private _config;
  48592. private _texturePath;
  48593. /**
  48594. * Instantiates a new Custom Procedural Texture.
  48595. * 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.
  48596. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48597. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48598. * @param name Define the name of the texture
  48599. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48600. * @param size Define the size of the texture to create
  48601. * @param scene Define the scene the texture belongs to
  48602. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48603. * @param generateMipMaps Define if the texture should creates mip maps or not
  48604. */
  48605. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48606. private _loadJson;
  48607. /**
  48608. * Is the texture ready to be used ? (rendered at least once)
  48609. * @returns true if ready, otherwise, false.
  48610. */
  48611. isReady(): boolean;
  48612. /**
  48613. * Render the texture to its associated render target.
  48614. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48615. */
  48616. render(useCameraPostProcess?: boolean): void;
  48617. /**
  48618. * Update the list of dependant textures samplers in the shader.
  48619. */
  48620. updateTextures(): void;
  48621. /**
  48622. * Update the uniform values of the procedural texture in the shader.
  48623. */
  48624. updateShaderUniforms(): void;
  48625. /**
  48626. * Define if the texture animates or not.
  48627. */
  48628. animate: boolean;
  48629. }
  48630. }
  48631. declare module "babylonjs/Shaders/noise.fragment" {
  48632. /** @hidden */
  48633. export var noisePixelShader: {
  48634. name: string;
  48635. shader: string;
  48636. };
  48637. }
  48638. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48639. import { Nullable } from "babylonjs/types";
  48640. import { Scene } from "babylonjs/scene";
  48641. import { Texture } from "babylonjs/Materials/Textures/texture";
  48642. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48643. import "babylonjs/Shaders/noise.fragment";
  48644. /**
  48645. * Class used to generate noise procedural textures
  48646. */
  48647. export class NoiseProceduralTexture extends ProceduralTexture {
  48648. private _time;
  48649. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48650. brightness: number;
  48651. /** Defines the number of octaves to process */
  48652. octaves: number;
  48653. /** Defines the level of persistence (0.8 by default) */
  48654. persistence: number;
  48655. /** Gets or sets animation speed factor (default is 1) */
  48656. animationSpeedFactor: number;
  48657. /**
  48658. * Creates a new NoiseProceduralTexture
  48659. * @param name defines the name fo the texture
  48660. * @param size defines the size of the texture (default is 256)
  48661. * @param scene defines the hosting scene
  48662. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48663. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48664. */
  48665. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48666. private _updateShaderUniforms;
  48667. protected _getDefines(): string;
  48668. /** Generate the current state of the procedural texture */
  48669. render(useCameraPostProcess?: boolean): void;
  48670. /**
  48671. * Serializes this noise procedural texture
  48672. * @returns a serialized noise procedural texture object
  48673. */
  48674. serialize(): any;
  48675. /**
  48676. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48677. * @param parsedTexture defines parsed texture data
  48678. * @param scene defines the current scene
  48679. * @param rootUrl defines the root URL containing noise procedural texture information
  48680. * @returns a parsed NoiseProceduralTexture
  48681. */
  48682. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48683. }
  48684. }
  48685. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48686. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48687. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48688. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48689. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48690. }
  48691. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48692. import { Nullable } from "babylonjs/types";
  48693. import { Scene } from "babylonjs/scene";
  48694. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48695. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48696. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48697. /**
  48698. * Raw cube texture where the raw buffers are passed in
  48699. */
  48700. export class RawCubeTexture extends CubeTexture {
  48701. /**
  48702. * Creates a cube texture where the raw buffers are passed in.
  48703. * @param scene defines the scene the texture is attached to
  48704. * @param data defines the array of data to use to create each face
  48705. * @param size defines the size of the textures
  48706. * @param format defines the format of the data
  48707. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48708. * @param generateMipMaps defines if the engine should generate the mip levels
  48709. * @param invertY defines if data must be stored with Y axis inverted
  48710. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48711. * @param compression defines the compression used (null by default)
  48712. */
  48713. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48714. /**
  48715. * Updates the raw cube texture.
  48716. * @param data defines the data to store
  48717. * @param format defines the data format
  48718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48719. * @param invertY defines if data must be stored with Y axis inverted
  48720. * @param compression defines the compression used (null by default)
  48721. * @param level defines which level of the texture to update
  48722. */
  48723. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48724. /**
  48725. * Updates a raw cube texture with RGBD encoded data.
  48726. * @param data defines the array of data [mipmap][face] to use to create each face
  48727. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48728. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48729. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48730. * @returns a promsie that resolves when the operation is complete
  48731. */
  48732. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48733. /**
  48734. * Clones the raw cube texture.
  48735. * @return a new cube texture
  48736. */
  48737. clone(): CubeTexture;
  48738. /** @hidden */
  48739. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48740. }
  48741. }
  48742. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48743. import { Scene } from "babylonjs/scene";
  48744. import { Texture } from "babylonjs/Materials/Textures/texture";
  48745. /**
  48746. * Class used to store 3D textures containing user data
  48747. */
  48748. export class RawTexture3D extends Texture {
  48749. /** Gets or sets the texture format to use */
  48750. format: number;
  48751. private _engine;
  48752. /**
  48753. * Create a new RawTexture3D
  48754. * @param data defines the data of the texture
  48755. * @param width defines the width of the texture
  48756. * @param height defines the height of the texture
  48757. * @param depth defines the depth of the texture
  48758. * @param format defines the texture format to use
  48759. * @param scene defines the hosting scene
  48760. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48761. * @param invertY defines if texture must be stored with Y axis inverted
  48762. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48763. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48764. */
  48765. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48766. /** Gets or sets the texture format to use */
  48767. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48768. /**
  48769. * Update the texture with new data
  48770. * @param data defines the data to store in the texture
  48771. */
  48772. update(data: ArrayBufferView): void;
  48773. }
  48774. }
  48775. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48776. import { Scene } from "babylonjs/scene";
  48777. import { Plane } from "babylonjs/Maths/math";
  48778. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48779. /**
  48780. * Creates a refraction texture used by refraction channel of the standard material.
  48781. * It is like a mirror but to see through a material.
  48782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48783. */
  48784. export class RefractionTexture extends RenderTargetTexture {
  48785. /**
  48786. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48787. * 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.
  48788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48789. */
  48790. refractionPlane: Plane;
  48791. /**
  48792. * Define how deep under the surface we should see.
  48793. */
  48794. depth: number;
  48795. /**
  48796. * Creates a refraction texture used by refraction channel of the standard material.
  48797. * It is like a mirror but to see through a material.
  48798. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48799. * @param name Define the texture name
  48800. * @param size Define the size of the underlying texture
  48801. * @param scene Define the scene the refraction belongs to
  48802. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48803. */
  48804. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48805. /**
  48806. * Clone the refraction texture.
  48807. * @returns the cloned texture
  48808. */
  48809. clone(): RefractionTexture;
  48810. /**
  48811. * Serialize the texture to a JSON representation you could use in Parse later on
  48812. * @returns the serialized JSON representation
  48813. */
  48814. serialize(): any;
  48815. }
  48816. }
  48817. declare module "babylonjs/Materials/Textures/index" {
  48818. export * from "babylonjs/Materials/Textures/baseTexture";
  48819. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48820. export * from "babylonjs/Materials/Textures/cubeTexture";
  48821. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48822. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48823. export * from "babylonjs/Materials/Textures/internalTexture";
  48824. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48825. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48826. export * from "babylonjs/Materials/Textures/Loaders/index";
  48827. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48828. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48829. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48830. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48831. export * from "babylonjs/Materials/Textures/rawTexture";
  48832. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48833. export * from "babylonjs/Materials/Textures/refractionTexture";
  48834. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48835. export * from "babylonjs/Materials/Textures/texture";
  48836. export * from "babylonjs/Materials/Textures/videoTexture";
  48837. }
  48838. declare module "babylonjs/Materials/index" {
  48839. export * from "babylonjs/Materials/Background/index";
  48840. export * from "babylonjs/Materials/colorCurves";
  48841. export * from "babylonjs/Materials/effect";
  48842. export * from "babylonjs/Materials/fresnelParameters";
  48843. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48844. export * from "babylonjs/Materials/material";
  48845. export * from "babylonjs/Materials/materialDefines";
  48846. export * from "babylonjs/Materials/materialHelper";
  48847. export * from "babylonjs/Materials/multiMaterial";
  48848. export * from "babylonjs/Materials/PBR/index";
  48849. export * from "babylonjs/Materials/pushMaterial";
  48850. export * from "babylonjs/Materials/shaderMaterial";
  48851. export * from "babylonjs/Materials/standardMaterial";
  48852. export * from "babylonjs/Materials/Textures/index";
  48853. export * from "babylonjs/Materials/uniformBuffer";
  48854. export * from "babylonjs/Materials/materialFlags";
  48855. }
  48856. declare module "babylonjs/Maths/index" {
  48857. export * from "babylonjs/Maths/math.scalar";
  48858. export * from "babylonjs/Maths/math";
  48859. export * from "babylonjs/Maths/sphericalPolynomial";
  48860. }
  48861. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48862. import { IDisposable } from "babylonjs/scene";
  48863. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48864. /**
  48865. * Configuration for Draco compression
  48866. */
  48867. export interface IDracoCompressionConfiguration {
  48868. /**
  48869. * Configuration for the decoder.
  48870. */
  48871. decoder?: {
  48872. /**
  48873. * The url to the WebAssembly module.
  48874. */
  48875. wasmUrl?: string;
  48876. /**
  48877. * The url to the WebAssembly binary.
  48878. */
  48879. wasmBinaryUrl?: string;
  48880. /**
  48881. * The url to the fallback JavaScript module.
  48882. */
  48883. fallbackUrl?: string;
  48884. };
  48885. }
  48886. /**
  48887. * Draco compression (https://google.github.io/draco/)
  48888. *
  48889. * This class wraps the Draco module.
  48890. *
  48891. * **Encoder**
  48892. *
  48893. * The encoder is not currently implemented.
  48894. *
  48895. * **Decoder**
  48896. *
  48897. * 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.
  48898. *
  48899. * To update the configuration, use the following code:
  48900. * ```javascript
  48901. * DracoCompression.Configuration = {
  48902. * decoder: {
  48903. * wasmUrl: "<url to the WebAssembly library>",
  48904. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48905. * fallbackUrl: "<url to the fallback JavaScript library>",
  48906. * }
  48907. * };
  48908. * ```
  48909. *
  48910. * 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.
  48911. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48912. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48913. *
  48914. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48915. * ```javascript
  48916. * var dracoCompression = new DracoCompression();
  48917. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48918. * [VertexBuffer.PositionKind]: 0
  48919. * });
  48920. * ```
  48921. *
  48922. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48923. */
  48924. export class DracoCompression implements IDisposable {
  48925. private static _DecoderModulePromise;
  48926. /**
  48927. * The configuration. Defaults to the following urls:
  48928. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48929. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48930. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48931. */
  48932. static Configuration: IDracoCompressionConfiguration;
  48933. /**
  48934. * Returns true if the decoder is available.
  48935. */
  48936. static readonly DecoderAvailable: boolean;
  48937. /**
  48938. * Constructor
  48939. */
  48940. constructor();
  48941. /**
  48942. * Stop all async operations and release resources.
  48943. */
  48944. dispose(): void;
  48945. /**
  48946. * Decode Draco compressed mesh data to vertex data.
  48947. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48948. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48949. * @returns A promise that resolves with the decoded vertex data
  48950. */
  48951. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48952. [kind: string]: number;
  48953. }): Promise<VertexData>;
  48954. private static _GetDecoderModule;
  48955. private static _LoadScriptAsync;
  48956. private static _LoadFileAsync;
  48957. }
  48958. }
  48959. declare module "babylonjs/Meshes/Compression/index" {
  48960. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48961. }
  48962. declare module "babylonjs/Meshes/csg" {
  48963. import { Nullable } from "babylonjs/types";
  48964. import { Scene } from "babylonjs/scene";
  48965. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48966. import { Mesh } from "babylonjs/Meshes/mesh";
  48967. import { Material } from "babylonjs/Materials/material";
  48968. /**
  48969. * Class for building Constructive Solid Geometry
  48970. */
  48971. export class CSG {
  48972. private polygons;
  48973. /**
  48974. * The world matrix
  48975. */
  48976. matrix: Matrix;
  48977. /**
  48978. * Stores the position
  48979. */
  48980. position: Vector3;
  48981. /**
  48982. * Stores the rotation
  48983. */
  48984. rotation: Vector3;
  48985. /**
  48986. * Stores the rotation quaternion
  48987. */
  48988. rotationQuaternion: Nullable<Quaternion>;
  48989. /**
  48990. * Stores the scaling vector
  48991. */
  48992. scaling: Vector3;
  48993. /**
  48994. * Convert the Mesh to CSG
  48995. * @param mesh The Mesh to convert to CSG
  48996. * @returns A new CSG from the Mesh
  48997. */
  48998. static FromMesh(mesh: Mesh): CSG;
  48999. /**
  49000. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49001. * @param polygons Polygons used to construct a CSG solid
  49002. */
  49003. private static FromPolygons;
  49004. /**
  49005. * Clones, or makes a deep copy, of the CSG
  49006. * @returns A new CSG
  49007. */
  49008. clone(): CSG;
  49009. /**
  49010. * Unions this CSG with another CSG
  49011. * @param csg The CSG to union against this CSG
  49012. * @returns The unioned CSG
  49013. */
  49014. union(csg: CSG): CSG;
  49015. /**
  49016. * Unions this CSG with another CSG in place
  49017. * @param csg The CSG to union against this CSG
  49018. */
  49019. unionInPlace(csg: CSG): void;
  49020. /**
  49021. * Subtracts this CSG with another CSG
  49022. * @param csg The CSG to subtract against this CSG
  49023. * @returns A new CSG
  49024. */
  49025. subtract(csg: CSG): CSG;
  49026. /**
  49027. * Subtracts this CSG with another CSG in place
  49028. * @param csg The CSG to subtact against this CSG
  49029. */
  49030. subtractInPlace(csg: CSG): void;
  49031. /**
  49032. * Intersect this CSG with another CSG
  49033. * @param csg The CSG to intersect against this CSG
  49034. * @returns A new CSG
  49035. */
  49036. intersect(csg: CSG): CSG;
  49037. /**
  49038. * Intersects this CSG with another CSG in place
  49039. * @param csg The CSG to intersect against this CSG
  49040. */
  49041. intersectInPlace(csg: CSG): void;
  49042. /**
  49043. * Return a new CSG solid with solid and empty space switched. This solid is
  49044. * not modified.
  49045. * @returns A new CSG solid with solid and empty space switched
  49046. */
  49047. inverse(): CSG;
  49048. /**
  49049. * Inverses the CSG in place
  49050. */
  49051. inverseInPlace(): void;
  49052. /**
  49053. * This is used to keep meshes transformations so they can be restored
  49054. * when we build back a Babylon Mesh
  49055. * NB : All CSG operations are performed in world coordinates
  49056. * @param csg The CSG to copy the transform attributes from
  49057. * @returns This CSG
  49058. */
  49059. copyTransformAttributes(csg: CSG): CSG;
  49060. /**
  49061. * Build Raw mesh from CSG
  49062. * Coordinates here are in world space
  49063. * @param name The name of the mesh geometry
  49064. * @param scene The Scene
  49065. * @param keepSubMeshes Specifies if the submeshes should be kept
  49066. * @returns A new Mesh
  49067. */
  49068. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49069. /**
  49070. * Build Mesh from CSG taking material and transforms into account
  49071. * @param name The name of the Mesh
  49072. * @param material The material of the Mesh
  49073. * @param scene The Scene
  49074. * @param keepSubMeshes Specifies if submeshes should be kept
  49075. * @returns The new Mesh
  49076. */
  49077. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49078. }
  49079. }
  49080. declare module "babylonjs/Meshes/trailMesh" {
  49081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49082. import { Mesh } from "babylonjs/Meshes/mesh";
  49083. import { Scene } from "babylonjs/scene";
  49084. /**
  49085. * Class used to create a trail following a mesh
  49086. */
  49087. export class TrailMesh extends Mesh {
  49088. private _generator;
  49089. private _autoStart;
  49090. private _running;
  49091. private _diameter;
  49092. private _length;
  49093. private _sectionPolygonPointsCount;
  49094. private _sectionVectors;
  49095. private _sectionNormalVectors;
  49096. private _beforeRenderObserver;
  49097. /**
  49098. * @constructor
  49099. * @param name The value used by scene.getMeshByName() to do a lookup.
  49100. * @param generator The mesh to generate a trail.
  49101. * @param scene The scene to add this mesh to.
  49102. * @param diameter Diameter of trailing mesh. Default is 1.
  49103. * @param length Length of trailing mesh. Default is 60.
  49104. * @param autoStart Automatically start trailing mesh. Default true.
  49105. */
  49106. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49107. /**
  49108. * "TrailMesh"
  49109. * @returns "TrailMesh"
  49110. */
  49111. getClassName(): string;
  49112. private _createMesh;
  49113. /**
  49114. * Start trailing mesh.
  49115. */
  49116. start(): void;
  49117. /**
  49118. * Stop trailing mesh.
  49119. */
  49120. stop(): void;
  49121. /**
  49122. * Update trailing mesh geometry.
  49123. */
  49124. update(): void;
  49125. /**
  49126. * Returns a new TrailMesh object.
  49127. * @param name is a string, the name given to the new mesh
  49128. * @param newGenerator use new generator object for cloned trail mesh
  49129. * @returns a new mesh
  49130. */
  49131. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49132. /**
  49133. * Serializes this trail mesh
  49134. * @param serializationObject object to write serialization to
  49135. */
  49136. serialize(serializationObject: any): void;
  49137. /**
  49138. * Parses a serialized trail mesh
  49139. * @param parsedMesh the serialized mesh
  49140. * @param scene the scene to create the trail mesh in
  49141. * @returns the created trail mesh
  49142. */
  49143. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49144. }
  49145. }
  49146. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49147. import { Nullable } from "babylonjs/types";
  49148. import { Scene } from "babylonjs/scene";
  49149. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49150. import { Mesh } from "babylonjs/Meshes/mesh";
  49151. /**
  49152. * Class containing static functions to help procedurally build meshes
  49153. */
  49154. export class RibbonBuilder {
  49155. /**
  49156. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49157. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49158. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49159. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49160. * * 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
  49161. * * 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
  49162. * * 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
  49163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49166. * * 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
  49167. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49168. * * 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
  49169. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49171. * @param name defines the name of the mesh
  49172. * @param options defines the options used to create the mesh
  49173. * @param scene defines the hosting scene
  49174. * @returns the ribbon mesh
  49175. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49177. */
  49178. static CreateRibbon(name: string, options: {
  49179. pathArray: Vector3[][];
  49180. closeArray?: boolean;
  49181. closePath?: boolean;
  49182. offset?: number;
  49183. updatable?: boolean;
  49184. sideOrientation?: number;
  49185. frontUVs?: Vector4;
  49186. backUVs?: Vector4;
  49187. instance?: Mesh;
  49188. invertUV?: boolean;
  49189. uvs?: Vector2[];
  49190. colors?: Color4[];
  49191. }, scene?: Nullable<Scene>): Mesh;
  49192. }
  49193. }
  49194. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49195. import { Vector4 } from "babylonjs/Maths/math";
  49196. import { Mesh } from "babylonjs/Meshes/mesh";
  49197. /**
  49198. * Class containing static functions to help procedurally build meshes
  49199. */
  49200. export class TorusKnotBuilder {
  49201. /**
  49202. * Creates a torus knot mesh
  49203. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49204. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49205. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49206. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49210. * @param name defines the name of the mesh
  49211. * @param options defines the options used to create the mesh
  49212. * @param scene defines the hosting scene
  49213. * @returns the torus knot mesh
  49214. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49215. */
  49216. static CreateTorusKnot(name: string, options: {
  49217. radius?: number;
  49218. tube?: number;
  49219. radialSegments?: number;
  49220. tubularSegments?: number;
  49221. p?: number;
  49222. q?: number;
  49223. updatable?: boolean;
  49224. sideOrientation?: number;
  49225. frontUVs?: Vector4;
  49226. backUVs?: Vector4;
  49227. }, scene: any): Mesh;
  49228. }
  49229. }
  49230. declare module "babylonjs/Meshes/polygonMesh" {
  49231. import { Scene } from "babylonjs/scene";
  49232. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49233. import { Mesh } from "babylonjs/Meshes/mesh";
  49234. /**
  49235. * Polygon
  49236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49237. */
  49238. export class Polygon {
  49239. /**
  49240. * Creates a rectangle
  49241. * @param xmin bottom X coord
  49242. * @param ymin bottom Y coord
  49243. * @param xmax top X coord
  49244. * @param ymax top Y coord
  49245. * @returns points that make the resulting rectation
  49246. */
  49247. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49248. /**
  49249. * Creates a circle
  49250. * @param radius radius of circle
  49251. * @param cx scale in x
  49252. * @param cy scale in y
  49253. * @param numberOfSides number of sides that make up the circle
  49254. * @returns points that make the resulting circle
  49255. */
  49256. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49257. /**
  49258. * Creates a polygon from input string
  49259. * @param input Input polygon data
  49260. * @returns the parsed points
  49261. */
  49262. static Parse(input: string): Vector2[];
  49263. /**
  49264. * Starts building a polygon from x and y coordinates
  49265. * @param x x coordinate
  49266. * @param y y coordinate
  49267. * @returns the started path2
  49268. */
  49269. static StartingAt(x: number, y: number): Path2;
  49270. }
  49271. /**
  49272. * Builds a polygon
  49273. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49274. */
  49275. export class PolygonMeshBuilder {
  49276. private _points;
  49277. private _outlinepoints;
  49278. private _holes;
  49279. private _name;
  49280. private _scene;
  49281. private _epoints;
  49282. private _eholes;
  49283. private _addToepoint;
  49284. /**
  49285. * Babylon reference to the earcut plugin.
  49286. */
  49287. bjsEarcut: any;
  49288. /**
  49289. * Creates a PolygonMeshBuilder
  49290. * @param name name of the builder
  49291. * @param contours Path of the polygon
  49292. * @param scene scene to add to
  49293. * @param earcutInjection can be used to inject your own earcut reference
  49294. */
  49295. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49296. /**
  49297. * Adds a whole within the polygon
  49298. * @param hole Array of points defining the hole
  49299. * @returns this
  49300. */
  49301. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49302. /**
  49303. * Creates the polygon
  49304. * @param updatable If the mesh should be updatable
  49305. * @param depth The depth of the mesh created
  49306. * @returns the created mesh
  49307. */
  49308. build(updatable?: boolean, depth?: number): Mesh;
  49309. /**
  49310. * Adds a side to the polygon
  49311. * @param positions points that make the polygon
  49312. * @param normals normals of the polygon
  49313. * @param uvs uvs of the polygon
  49314. * @param indices indices of the polygon
  49315. * @param bounds bounds of the polygon
  49316. * @param points points of the polygon
  49317. * @param depth depth of the polygon
  49318. * @param flip flip of the polygon
  49319. */
  49320. private addSide;
  49321. }
  49322. }
  49323. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49324. import { Scene } from "babylonjs/scene";
  49325. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49326. import { Mesh } from "babylonjs/Meshes/mesh";
  49327. /**
  49328. * Class containing static functions to help procedurally build meshes
  49329. */
  49330. export class PolygonBuilder {
  49331. /**
  49332. * Creates a polygon mesh
  49333. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49334. * * 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
  49335. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49338. * * Remember you can only change the shape positions, not their number when updating a polygon
  49339. * @param name defines the name of the mesh
  49340. * @param options defines the options used to create the mesh
  49341. * @param scene defines the hosting scene
  49342. * @param earcutInjection can be used to inject your own earcut reference
  49343. * @returns the polygon mesh
  49344. */
  49345. static CreatePolygon(name: string, options: {
  49346. shape: Vector3[];
  49347. holes?: Vector3[][];
  49348. depth?: number;
  49349. faceUV?: Vector4[];
  49350. faceColors?: Color4[];
  49351. updatable?: boolean;
  49352. sideOrientation?: number;
  49353. frontUVs?: Vector4;
  49354. backUVs?: Vector4;
  49355. }, scene: Scene, earcutInjection?: any): Mesh;
  49356. /**
  49357. * Creates an extruded polygon mesh, with depth in the Y direction.
  49358. * * 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)
  49359. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49360. * @param name defines the name of the mesh
  49361. * @param options defines the options used to create the mesh
  49362. * @param scene defines the hosting scene
  49363. * @param earcutInjection can be used to inject your own earcut reference
  49364. * @returns the polygon mesh
  49365. */
  49366. static ExtrudePolygon(name: string, options: {
  49367. shape: Vector3[];
  49368. holes?: Vector3[][];
  49369. depth?: number;
  49370. faceUV?: Vector4[];
  49371. faceColors?: Color4[];
  49372. updatable?: boolean;
  49373. sideOrientation?: number;
  49374. frontUVs?: Vector4;
  49375. backUVs?: Vector4;
  49376. }, scene: Scene, earcutInjection?: any): Mesh;
  49377. }
  49378. }
  49379. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49380. import { Nullable } from "babylonjs/types";
  49381. import { Scene } from "babylonjs/scene";
  49382. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49383. import { Mesh } from "babylonjs/Meshes/mesh";
  49384. /**
  49385. * Class containing static functions to help procedurally build meshes
  49386. */
  49387. export class ShapeBuilder {
  49388. /**
  49389. * 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.
  49390. * * 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.
  49391. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49392. * * 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.
  49393. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49394. * * 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
  49395. * * 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
  49396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49401. * @param name defines the name of the mesh
  49402. * @param options defines the options used to create the mesh
  49403. * @param scene defines the hosting scene
  49404. * @returns the extruded shape mesh
  49405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49407. */
  49408. static ExtrudeShape(name: string, options: {
  49409. shape: Vector3[];
  49410. path: Vector3[];
  49411. scale?: number;
  49412. rotation?: number;
  49413. cap?: number;
  49414. updatable?: boolean;
  49415. sideOrientation?: number;
  49416. frontUVs?: Vector4;
  49417. backUVs?: Vector4;
  49418. instance?: Mesh;
  49419. invertUV?: boolean;
  49420. }, scene?: Nullable<Scene>): Mesh;
  49421. /**
  49422. * Creates an custom extruded shape mesh.
  49423. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49424. * * 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.
  49425. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49426. * * 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
  49427. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49428. * * 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
  49429. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49430. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49431. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49432. * * 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
  49433. * * 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
  49434. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49439. * @param name defines the name of the mesh
  49440. * @param options defines the options used to create the mesh
  49441. * @param scene defines the hosting scene
  49442. * @returns the custom extruded shape mesh
  49443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49446. */
  49447. static ExtrudeShapeCustom(name: string, options: {
  49448. shape: Vector3[];
  49449. path: Vector3[];
  49450. scaleFunction?: any;
  49451. rotationFunction?: any;
  49452. ribbonCloseArray?: boolean;
  49453. ribbonClosePath?: boolean;
  49454. cap?: number;
  49455. updatable?: boolean;
  49456. sideOrientation?: number;
  49457. frontUVs?: Vector4;
  49458. backUVs?: Vector4;
  49459. instance?: Mesh;
  49460. invertUV?: boolean;
  49461. }, scene: Scene): Mesh;
  49462. private static _ExtrudeShapeGeneric;
  49463. }
  49464. }
  49465. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49466. import { Scene } from "babylonjs/scene";
  49467. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49468. import { Mesh } from "babylonjs/Meshes/mesh";
  49469. /**
  49470. * Class containing static functions to help procedurally build meshes
  49471. */
  49472. export class LatheBuilder {
  49473. /**
  49474. * Creates lathe mesh.
  49475. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49476. * * 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
  49477. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49478. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49479. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49480. * * 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
  49481. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49482. * * 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
  49483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49487. * @param name defines the name of the mesh
  49488. * @param options defines the options used to create the mesh
  49489. * @param scene defines the hosting scene
  49490. * @returns the lathe mesh
  49491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49492. */
  49493. static CreateLathe(name: string, options: {
  49494. shape: Vector3[];
  49495. radius?: number;
  49496. tessellation?: number;
  49497. clip?: number;
  49498. arc?: number;
  49499. closed?: boolean;
  49500. updatable?: boolean;
  49501. sideOrientation?: number;
  49502. frontUVs?: Vector4;
  49503. backUVs?: Vector4;
  49504. cap?: number;
  49505. invertUV?: boolean;
  49506. }, scene: Scene): Mesh;
  49507. }
  49508. }
  49509. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49510. import { Scene } from "babylonjs/scene";
  49511. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49512. import { Mesh } from "babylonjs/Meshes/mesh";
  49513. /**
  49514. * Class containing static functions to help procedurally build meshes
  49515. */
  49516. export class TubeBuilder {
  49517. /**
  49518. * Creates a tube mesh.
  49519. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49520. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49521. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49522. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49523. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49524. * * 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)
  49525. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49526. * * 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
  49527. * * 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
  49528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49532. * @param name defines the name of the mesh
  49533. * @param options defines the options used to create the mesh
  49534. * @param scene defines the hosting scene
  49535. * @returns the tube mesh
  49536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49537. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49538. */
  49539. static CreateTube(name: string, options: {
  49540. path: Vector3[];
  49541. radius?: number;
  49542. tessellation?: number;
  49543. radiusFunction?: {
  49544. (i: number, distance: number): number;
  49545. };
  49546. cap?: number;
  49547. arc?: number;
  49548. updatable?: boolean;
  49549. sideOrientation?: number;
  49550. frontUVs?: Vector4;
  49551. backUVs?: Vector4;
  49552. instance?: Mesh;
  49553. invertUV?: boolean;
  49554. }, scene: Scene): Mesh;
  49555. }
  49556. }
  49557. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49558. import { Scene } from "babylonjs/scene";
  49559. import { Vector4 } from "babylonjs/Maths/math";
  49560. import { Mesh } from "babylonjs/Meshes/mesh";
  49561. /**
  49562. * Class containing static functions to help procedurally build meshes
  49563. */
  49564. export class IcoSphereBuilder {
  49565. /**
  49566. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49567. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49568. * * 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`)
  49569. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49570. * * 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
  49571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49574. * @param name defines the name of the mesh
  49575. * @param options defines the options used to create the mesh
  49576. * @param scene defines the hosting scene
  49577. * @returns the icosahedron mesh
  49578. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49579. */
  49580. static CreateIcoSphere(name: string, options: {
  49581. radius?: number;
  49582. radiusX?: number;
  49583. radiusY?: number;
  49584. radiusZ?: number;
  49585. flat?: boolean;
  49586. subdivisions?: number;
  49587. sideOrientation?: number;
  49588. frontUVs?: Vector4;
  49589. backUVs?: Vector4;
  49590. updatable?: boolean;
  49591. }, scene: Scene): Mesh;
  49592. }
  49593. }
  49594. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49595. import { Vector3 } from "babylonjs/Maths/math";
  49596. import { Mesh } from "babylonjs/Meshes/mesh";
  49597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49598. /**
  49599. * Class containing static functions to help procedurally build meshes
  49600. */
  49601. export class DecalBuilder {
  49602. /**
  49603. * Creates a decal mesh.
  49604. * 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
  49605. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49606. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49607. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49608. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49609. * @param name defines the name of the mesh
  49610. * @param sourceMesh defines the mesh where the decal must be applied
  49611. * @param options defines the options used to create the mesh
  49612. * @param scene defines the hosting scene
  49613. * @returns the decal mesh
  49614. * @see https://doc.babylonjs.com/how_to/decals
  49615. */
  49616. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49617. position?: Vector3;
  49618. normal?: Vector3;
  49619. size?: Vector3;
  49620. angle?: number;
  49621. }): Mesh;
  49622. }
  49623. }
  49624. declare module "babylonjs/Meshes/meshBuilder" {
  49625. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49626. import { Nullable } from "babylonjs/types";
  49627. import { Scene } from "babylonjs/scene";
  49628. import { Mesh } from "babylonjs/Meshes/mesh";
  49629. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49630. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49632. /**
  49633. * Class containing static functions to help procedurally build meshes
  49634. */
  49635. export class MeshBuilder {
  49636. /**
  49637. * Creates a box mesh
  49638. * * The parameter `size` sets the size (float) of each box side (default 1)
  49639. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49640. * * 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)
  49641. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49645. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49646. * @param name defines the name of the mesh
  49647. * @param options defines the options used to create the mesh
  49648. * @param scene defines the hosting scene
  49649. * @returns the box mesh
  49650. */
  49651. static CreateBox(name: string, options: {
  49652. size?: number;
  49653. width?: number;
  49654. height?: number;
  49655. depth?: number;
  49656. faceUV?: Vector4[];
  49657. faceColors?: Color4[];
  49658. sideOrientation?: number;
  49659. frontUVs?: Vector4;
  49660. backUVs?: Vector4;
  49661. updatable?: boolean;
  49662. }, scene?: Nullable<Scene>): Mesh;
  49663. /**
  49664. * Creates a sphere mesh
  49665. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49666. * * 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`)
  49667. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49668. * * 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
  49669. * * 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)
  49670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49673. * @param name defines the name of the mesh
  49674. * @param options defines the options used to create the mesh
  49675. * @param scene defines the hosting scene
  49676. * @returns the sphere mesh
  49677. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49678. */
  49679. static CreateSphere(name: string, options: {
  49680. segments?: number;
  49681. diameter?: number;
  49682. diameterX?: number;
  49683. diameterY?: number;
  49684. diameterZ?: number;
  49685. arc?: number;
  49686. slice?: number;
  49687. sideOrientation?: number;
  49688. frontUVs?: Vector4;
  49689. backUVs?: Vector4;
  49690. updatable?: boolean;
  49691. }, scene: any): Mesh;
  49692. /**
  49693. * Creates a plane polygonal mesh. By default, this is a disc
  49694. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49695. * * 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
  49696. * * 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
  49697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49700. * @param name defines the name of the mesh
  49701. * @param options defines the options used to create the mesh
  49702. * @param scene defines the hosting scene
  49703. * @returns the plane polygonal mesh
  49704. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49705. */
  49706. static CreateDisc(name: string, options: {
  49707. radius?: number;
  49708. tessellation?: number;
  49709. arc?: number;
  49710. updatable?: boolean;
  49711. sideOrientation?: number;
  49712. frontUVs?: Vector4;
  49713. backUVs?: Vector4;
  49714. }, scene?: Nullable<Scene>): Mesh;
  49715. /**
  49716. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49717. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49718. * * 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`)
  49719. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49720. * * 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
  49721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 options defines the options used to create the mesh
  49726. * @param scene defines the hosting scene
  49727. * @returns the icosahedron mesh
  49728. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49729. */
  49730. static CreateIcoSphere(name: string, options: {
  49731. radius?: number;
  49732. radiusX?: number;
  49733. radiusY?: number;
  49734. radiusZ?: number;
  49735. flat?: boolean;
  49736. subdivisions?: number;
  49737. sideOrientation?: number;
  49738. frontUVs?: Vector4;
  49739. backUVs?: Vector4;
  49740. updatable?: boolean;
  49741. }, scene: Scene): Mesh;
  49742. /**
  49743. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49744. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49745. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49746. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49747. * * 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
  49748. * * 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
  49749. * * 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
  49750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49753. * * 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
  49754. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49755. * * 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
  49756. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49758. * @param name defines the name of the mesh
  49759. * @param options defines the options used to create the mesh
  49760. * @param scene defines the hosting scene
  49761. * @returns the ribbon mesh
  49762. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49764. */
  49765. static CreateRibbon(name: string, options: {
  49766. pathArray: Vector3[][];
  49767. closeArray?: boolean;
  49768. closePath?: boolean;
  49769. offset?: number;
  49770. updatable?: boolean;
  49771. sideOrientation?: number;
  49772. frontUVs?: Vector4;
  49773. backUVs?: Vector4;
  49774. instance?: Mesh;
  49775. invertUV?: boolean;
  49776. uvs?: Vector2[];
  49777. colors?: Color4[];
  49778. }, scene?: Nullable<Scene>): Mesh;
  49779. /**
  49780. * Creates a cylinder or a cone mesh
  49781. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49782. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49783. * * 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.
  49784. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49785. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49786. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49787. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49789. * * 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).
  49790. * * 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
  49791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49792. * * 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
  49793. * * 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.
  49794. * * If `enclose` is false, a ring surface is one element.
  49795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49796. * * 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
  49797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49800. * @param name defines the name of the mesh
  49801. * @param options defines the options used to create the mesh
  49802. * @param scene defines the hosting scene
  49803. * @returns the cylinder mesh
  49804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49805. */
  49806. static CreateCylinder(name: string, options: {
  49807. height?: number;
  49808. diameterTop?: number;
  49809. diameterBottom?: number;
  49810. diameter?: number;
  49811. tessellation?: number;
  49812. subdivisions?: number;
  49813. arc?: number;
  49814. faceColors?: Color4[];
  49815. faceUV?: Vector4[];
  49816. updatable?: boolean;
  49817. hasRings?: boolean;
  49818. enclose?: boolean;
  49819. sideOrientation?: number;
  49820. frontUVs?: Vector4;
  49821. backUVs?: Vector4;
  49822. }, scene: any): Mesh;
  49823. /**
  49824. * Creates a torus mesh
  49825. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49826. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49827. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49831. * @param name defines the name of the mesh
  49832. * @param options defines the options used to create the mesh
  49833. * @param scene defines the hosting scene
  49834. * @returns the torus mesh
  49835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49836. */
  49837. static CreateTorus(name: string, options: {
  49838. diameter?: number;
  49839. thickness?: number;
  49840. tessellation?: number;
  49841. updatable?: boolean;
  49842. sideOrientation?: number;
  49843. frontUVs?: Vector4;
  49844. backUVs?: Vector4;
  49845. }, scene: any): Mesh;
  49846. /**
  49847. * Creates a torus knot mesh
  49848. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49849. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49850. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49851. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49855. * @param name defines the name of the mesh
  49856. * @param options defines the options used to create the mesh
  49857. * @param scene defines the hosting scene
  49858. * @returns the torus knot mesh
  49859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49860. */
  49861. static CreateTorusKnot(name: string, options: {
  49862. radius?: number;
  49863. tube?: number;
  49864. radialSegments?: number;
  49865. tubularSegments?: number;
  49866. p?: number;
  49867. q?: number;
  49868. updatable?: boolean;
  49869. sideOrientation?: number;
  49870. frontUVs?: Vector4;
  49871. backUVs?: Vector4;
  49872. }, scene: any): Mesh;
  49873. /**
  49874. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49875. * * 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
  49876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49877. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49878. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49879. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49881. * * 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
  49882. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49885. * @param name defines the name of the new line system
  49886. * @param options defines the options used to create the line system
  49887. * @param scene defines the hosting scene
  49888. * @returns a new line system mesh
  49889. */
  49890. static CreateLineSystem(name: string, options: {
  49891. lines: Vector3[][];
  49892. updatable?: boolean;
  49893. instance?: Nullable<LinesMesh>;
  49894. colors?: Nullable<Color4[][]>;
  49895. useVertexAlpha?: boolean;
  49896. }, scene: Nullable<Scene>): LinesMesh;
  49897. /**
  49898. * Creates a line mesh
  49899. * 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
  49900. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49901. * * The parameter `points` is an array successive Vector3
  49902. * * 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
  49903. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49904. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49905. * * When updating an instance, remember that only point positions can change, not the number of points
  49906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49908. * @param name defines the name of the new line system
  49909. * @param options defines the options used to create the line system
  49910. * @param scene defines the hosting scene
  49911. * @returns a new line mesh
  49912. */
  49913. static CreateLines(name: string, options: {
  49914. points: Vector3[];
  49915. updatable?: boolean;
  49916. instance?: Nullable<LinesMesh>;
  49917. colors?: Color4[];
  49918. useVertexAlpha?: boolean;
  49919. }, scene?: Nullable<Scene>): LinesMesh;
  49920. /**
  49921. * Creates a dashed line mesh
  49922. * * 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
  49923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49924. * * The parameter `points` is an array successive Vector3
  49925. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49926. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49927. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49928. * * 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
  49929. * * When updating an instance, remember that only point positions can change, not the number of points
  49930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49931. * @param name defines the name of the mesh
  49932. * @param options defines the options used to create the mesh
  49933. * @param scene defines the hosting scene
  49934. * @returns the dashed line mesh
  49935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49936. */
  49937. static CreateDashedLines(name: string, options: {
  49938. points: Vector3[];
  49939. dashSize?: number;
  49940. gapSize?: number;
  49941. dashNb?: number;
  49942. updatable?: boolean;
  49943. instance?: LinesMesh;
  49944. }, scene?: Nullable<Scene>): LinesMesh;
  49945. /**
  49946. * 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.
  49947. * * 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.
  49948. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49949. * * 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.
  49950. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49951. * * 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
  49952. * * 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
  49953. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49956. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49958. * @param name defines the name of the mesh
  49959. * @param options defines the options used to create the mesh
  49960. * @param scene defines the hosting scene
  49961. * @returns the extruded shape mesh
  49962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49964. */
  49965. static ExtrudeShape(name: string, options: {
  49966. shape: Vector3[];
  49967. path: Vector3[];
  49968. scale?: number;
  49969. rotation?: number;
  49970. cap?: number;
  49971. updatable?: boolean;
  49972. sideOrientation?: number;
  49973. frontUVs?: Vector4;
  49974. backUVs?: Vector4;
  49975. instance?: Mesh;
  49976. invertUV?: boolean;
  49977. }, scene?: Nullable<Scene>): Mesh;
  49978. /**
  49979. * Creates an custom extruded shape mesh.
  49980. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49981. * * 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.
  49982. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49983. * * 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
  49984. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49985. * * 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
  49986. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49987. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49988. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49989. * * 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
  49990. * * 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
  49991. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49996. * @param name defines the name of the mesh
  49997. * @param options defines the options used to create the mesh
  49998. * @param scene defines the hosting scene
  49999. * @returns the custom extruded shape mesh
  50000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50003. */
  50004. static ExtrudeShapeCustom(name: string, options: {
  50005. shape: Vector3[];
  50006. path: Vector3[];
  50007. scaleFunction?: any;
  50008. rotationFunction?: any;
  50009. ribbonCloseArray?: boolean;
  50010. ribbonClosePath?: boolean;
  50011. cap?: number;
  50012. updatable?: boolean;
  50013. sideOrientation?: number;
  50014. frontUVs?: Vector4;
  50015. backUVs?: Vector4;
  50016. instance?: Mesh;
  50017. invertUV?: boolean;
  50018. }, scene: Scene): Mesh;
  50019. /**
  50020. * Creates lathe mesh.
  50021. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50022. * * 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
  50023. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50024. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50025. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50026. * * 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
  50027. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50028. * * 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
  50029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50033. * @param name defines the name of the mesh
  50034. * @param options defines the options used to create the mesh
  50035. * @param scene defines the hosting scene
  50036. * @returns the lathe mesh
  50037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50038. */
  50039. static CreateLathe(name: string, options: {
  50040. shape: Vector3[];
  50041. radius?: number;
  50042. tessellation?: number;
  50043. clip?: number;
  50044. arc?: number;
  50045. closed?: boolean;
  50046. updatable?: boolean;
  50047. sideOrientation?: number;
  50048. frontUVs?: Vector4;
  50049. backUVs?: Vector4;
  50050. cap?: number;
  50051. invertUV?: boolean;
  50052. }, scene: Scene): Mesh;
  50053. /**
  50054. * Creates a plane mesh
  50055. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50056. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50057. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50061. * @param name defines the name of the mesh
  50062. * @param options defines the options used to create the mesh
  50063. * @param scene defines the hosting scene
  50064. * @returns the plane mesh
  50065. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50066. */
  50067. static CreatePlane(name: string, options: {
  50068. size?: number;
  50069. width?: number;
  50070. height?: number;
  50071. sideOrientation?: number;
  50072. frontUVs?: Vector4;
  50073. backUVs?: Vector4;
  50074. updatable?: boolean;
  50075. sourcePlane?: Plane;
  50076. }, scene: Scene): Mesh;
  50077. /**
  50078. * Creates a ground mesh
  50079. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50080. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50082. * @param name defines the name of the mesh
  50083. * @param options defines the options used to create the mesh
  50084. * @param scene defines the hosting scene
  50085. * @returns the ground mesh
  50086. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50087. */
  50088. static CreateGround(name: string, options: {
  50089. width?: number;
  50090. height?: number;
  50091. subdivisions?: number;
  50092. subdivisionsX?: number;
  50093. subdivisionsY?: number;
  50094. updatable?: boolean;
  50095. }, scene: any): Mesh;
  50096. /**
  50097. * Creates a tiled ground mesh
  50098. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50099. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50100. * * 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
  50101. * * 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
  50102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50103. * @param name defines the name of the mesh
  50104. * @param options defines the options used to create the mesh
  50105. * @param scene defines the hosting scene
  50106. * @returns the tiled ground mesh
  50107. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50108. */
  50109. static CreateTiledGround(name: string, options: {
  50110. xmin: number;
  50111. zmin: number;
  50112. xmax: number;
  50113. zmax: number;
  50114. subdivisions?: {
  50115. w: number;
  50116. h: number;
  50117. };
  50118. precision?: {
  50119. w: number;
  50120. h: number;
  50121. };
  50122. updatable?: boolean;
  50123. }, scene: Scene): Mesh;
  50124. /**
  50125. * Creates a ground mesh from a height map
  50126. * * The parameter `url` sets the URL of the height map image resource.
  50127. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50128. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50129. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50130. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50131. * * 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.
  50132. * * 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).
  50133. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50135. * @param name defines the name of the mesh
  50136. * @param url defines the url to the height map
  50137. * @param options defines the options used to create the mesh
  50138. * @param scene defines the hosting scene
  50139. * @returns the ground mesh
  50140. * @see https://doc.babylonjs.com/babylon101/height_map
  50141. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50142. */
  50143. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50144. width?: number;
  50145. height?: number;
  50146. subdivisions?: number;
  50147. minHeight?: number;
  50148. maxHeight?: number;
  50149. colorFilter?: Color3;
  50150. alphaFilter?: number;
  50151. updatable?: boolean;
  50152. onReady?: (mesh: GroundMesh) => void;
  50153. }, scene: Scene): GroundMesh;
  50154. /**
  50155. * Creates a polygon mesh
  50156. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50157. * * 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
  50158. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50161. * * Remember you can only change the shape positions, not their number when updating a polygon
  50162. * @param name defines the name of the mesh
  50163. * @param options defines the options used to create the mesh
  50164. * @param scene defines the hosting scene
  50165. * @param earcutInjection can be used to inject your own earcut reference
  50166. * @returns the polygon mesh
  50167. */
  50168. static CreatePolygon(name: string, options: {
  50169. shape: Vector3[];
  50170. holes?: Vector3[][];
  50171. depth?: number;
  50172. faceUV?: Vector4[];
  50173. faceColors?: Color4[];
  50174. updatable?: boolean;
  50175. sideOrientation?: number;
  50176. frontUVs?: Vector4;
  50177. backUVs?: Vector4;
  50178. }, scene: Scene, earcutInjection?: any): Mesh;
  50179. /**
  50180. * Creates an extruded polygon mesh, with depth in the Y direction.
  50181. * * 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)
  50182. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50183. * @param name defines the name of the mesh
  50184. * @param options defines the options used to create the mesh
  50185. * @param scene defines the hosting scene
  50186. * @param earcutInjection can be used to inject your own earcut reference
  50187. * @returns the polygon mesh
  50188. */
  50189. static ExtrudePolygon(name: string, options: {
  50190. shape: Vector3[];
  50191. holes?: Vector3[][];
  50192. depth?: number;
  50193. faceUV?: Vector4[];
  50194. faceColors?: Color4[];
  50195. updatable?: boolean;
  50196. sideOrientation?: number;
  50197. frontUVs?: Vector4;
  50198. backUVs?: Vector4;
  50199. }, scene: Scene, earcutInjection?: any): Mesh;
  50200. /**
  50201. * Creates a tube mesh.
  50202. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50203. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50204. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50205. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50206. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50207. * * 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)
  50208. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50209. * * 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
  50210. * * 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
  50211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50213. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50215. * @param name defines the name of the mesh
  50216. * @param options defines the options used to create the mesh
  50217. * @param scene defines the hosting scene
  50218. * @returns the tube mesh
  50219. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50220. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50221. */
  50222. static CreateTube(name: string, options: {
  50223. path: Vector3[];
  50224. radius?: number;
  50225. tessellation?: number;
  50226. radiusFunction?: {
  50227. (i: number, distance: number): number;
  50228. };
  50229. cap?: number;
  50230. arc?: number;
  50231. updatable?: boolean;
  50232. sideOrientation?: number;
  50233. frontUVs?: Vector4;
  50234. backUVs?: Vector4;
  50235. instance?: Mesh;
  50236. invertUV?: boolean;
  50237. }, scene: Scene): Mesh;
  50238. /**
  50239. * Creates a polyhedron mesh
  50240. * * 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
  50241. * * The parameter `size` (positive float, default 1) sets the polygon size
  50242. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50243. * * 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`
  50244. * * 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
  50245. * * 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)`)
  50246. * * 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
  50247. * * 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
  50248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50251. * @param name defines the name of the mesh
  50252. * @param options defines the options used to create the mesh
  50253. * @param scene defines the hosting scene
  50254. * @returns the polyhedron mesh
  50255. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50256. */
  50257. static CreatePolyhedron(name: string, options: {
  50258. type?: number;
  50259. size?: number;
  50260. sizeX?: number;
  50261. sizeY?: number;
  50262. sizeZ?: number;
  50263. custom?: any;
  50264. faceUV?: Vector4[];
  50265. faceColors?: Color4[];
  50266. flat?: boolean;
  50267. updatable?: boolean;
  50268. sideOrientation?: number;
  50269. frontUVs?: Vector4;
  50270. backUVs?: Vector4;
  50271. }, scene: Scene): Mesh;
  50272. /**
  50273. * Creates a decal mesh.
  50274. * 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
  50275. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50276. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50277. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50278. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50279. * @param name defines the name of the mesh
  50280. * @param sourceMesh defines the mesh where the decal must be applied
  50281. * @param options defines the options used to create the mesh
  50282. * @param scene defines the hosting scene
  50283. * @returns the decal mesh
  50284. * @see https://doc.babylonjs.com/how_to/decals
  50285. */
  50286. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50287. position?: Vector3;
  50288. normal?: Vector3;
  50289. size?: Vector3;
  50290. angle?: number;
  50291. }): Mesh;
  50292. }
  50293. }
  50294. declare module "babylonjs/Meshes/meshSimplification" {
  50295. import { Mesh } from "babylonjs/Meshes/mesh";
  50296. /**
  50297. * A simplifier interface for future simplification implementations
  50298. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50299. */
  50300. export interface ISimplifier {
  50301. /**
  50302. * Simplification of a given mesh according to the given settings.
  50303. * Since this requires computation, it is assumed that the function runs async.
  50304. * @param settings The settings of the simplification, including quality and distance
  50305. * @param successCallback A callback that will be called after the mesh was simplified.
  50306. * @param errorCallback in case of an error, this callback will be called. optional.
  50307. */
  50308. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50309. }
  50310. /**
  50311. * Expected simplification settings.
  50312. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50314. */
  50315. export interface ISimplificationSettings {
  50316. /**
  50317. * Gets or sets the expected quality
  50318. */
  50319. quality: number;
  50320. /**
  50321. * Gets or sets the distance when this optimized version should be used
  50322. */
  50323. distance: number;
  50324. /**
  50325. * Gets an already optimized mesh
  50326. */
  50327. optimizeMesh?: boolean;
  50328. }
  50329. /**
  50330. * Class used to specify simplification options
  50331. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50332. */
  50333. export class SimplificationSettings implements ISimplificationSettings {
  50334. /** expected quality */
  50335. quality: number;
  50336. /** distance when this optimized version should be used */
  50337. distance: number;
  50338. /** already optimized mesh */
  50339. optimizeMesh?: boolean | undefined;
  50340. /**
  50341. * Creates a SimplificationSettings
  50342. * @param quality expected quality
  50343. * @param distance distance when this optimized version should be used
  50344. * @param optimizeMesh already optimized mesh
  50345. */
  50346. constructor(
  50347. /** expected quality */
  50348. quality: number,
  50349. /** distance when this optimized version should be used */
  50350. distance: number,
  50351. /** already optimized mesh */
  50352. optimizeMesh?: boolean | undefined);
  50353. }
  50354. /**
  50355. * Interface used to define a simplification task
  50356. */
  50357. export interface ISimplificationTask {
  50358. /**
  50359. * Array of settings
  50360. */
  50361. settings: Array<ISimplificationSettings>;
  50362. /**
  50363. * Simplification type
  50364. */
  50365. simplificationType: SimplificationType;
  50366. /**
  50367. * Mesh to simplify
  50368. */
  50369. mesh: Mesh;
  50370. /**
  50371. * Callback called on success
  50372. */
  50373. successCallback?: () => void;
  50374. /**
  50375. * Defines if parallel processing can be used
  50376. */
  50377. parallelProcessing: boolean;
  50378. }
  50379. /**
  50380. * Queue used to order the simplification tasks
  50381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50382. */
  50383. export class SimplificationQueue {
  50384. private _simplificationArray;
  50385. /**
  50386. * Gets a boolean indicating that the process is still running
  50387. */
  50388. running: boolean;
  50389. /**
  50390. * Creates a new queue
  50391. */
  50392. constructor();
  50393. /**
  50394. * Adds a new simplification task
  50395. * @param task defines a task to add
  50396. */
  50397. addTask(task: ISimplificationTask): void;
  50398. /**
  50399. * Execute next task
  50400. */
  50401. executeNext(): void;
  50402. /**
  50403. * Execute a simplification task
  50404. * @param task defines the task to run
  50405. */
  50406. runSimplification(task: ISimplificationTask): void;
  50407. private getSimplifier;
  50408. }
  50409. /**
  50410. * The implemented types of simplification
  50411. * At the moment only Quadratic Error Decimation is implemented
  50412. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50413. */
  50414. export enum SimplificationType {
  50415. /** Quadratic error decimation */
  50416. QUADRATIC = 0
  50417. }
  50418. }
  50419. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50420. import { Scene } from "babylonjs/scene";
  50421. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50422. import { ISceneComponent } from "babylonjs/sceneComponent";
  50423. module "babylonjs/scene" {
  50424. interface Scene {
  50425. /** @hidden (Backing field) */
  50426. _simplificationQueue: SimplificationQueue;
  50427. /**
  50428. * Gets or sets the simplification queue attached to the scene
  50429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50430. */
  50431. simplificationQueue: SimplificationQueue;
  50432. }
  50433. }
  50434. module "babylonjs/Meshes/mesh" {
  50435. interface Mesh {
  50436. /**
  50437. * Simplify the mesh according to the given array of settings.
  50438. * Function will return immediately and will simplify async
  50439. * @param settings a collection of simplification settings
  50440. * @param parallelProcessing should all levels calculate parallel or one after the other
  50441. * @param simplificationType the type of simplification to run
  50442. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50443. * @returns the current mesh
  50444. */
  50445. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50446. }
  50447. }
  50448. /**
  50449. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50450. * created in a scene
  50451. */
  50452. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50453. /**
  50454. * The component name helpfull to identify the component in the list of scene components.
  50455. */
  50456. readonly name: string;
  50457. /**
  50458. * The scene the component belongs to.
  50459. */
  50460. scene: Scene;
  50461. /**
  50462. * Creates a new instance of the component for the given scene
  50463. * @param scene Defines the scene to register the component in
  50464. */
  50465. constructor(scene: Scene);
  50466. /**
  50467. * Registers the component in a given scene
  50468. */
  50469. register(): void;
  50470. /**
  50471. * Rebuilds the elements related to this component in case of
  50472. * context lost for instance.
  50473. */
  50474. rebuild(): void;
  50475. /**
  50476. * Disposes the component and the associated ressources
  50477. */
  50478. dispose(): void;
  50479. private _beforeCameraUpdate;
  50480. }
  50481. }
  50482. declare module "babylonjs/Meshes/Builders/index" {
  50483. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50484. export * from "babylonjs/Meshes/Builders/discBuilder";
  50485. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50486. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50487. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50488. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50489. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50490. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50491. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50492. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50493. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50494. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50495. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50496. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50497. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50498. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50499. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50500. }
  50501. declare module "babylonjs/Meshes/index" {
  50502. export * from "babylonjs/Meshes/abstractMesh";
  50503. export * from "babylonjs/Meshes/buffer";
  50504. export * from "babylonjs/Meshes/Compression/index";
  50505. export * from "babylonjs/Meshes/csg";
  50506. export * from "babylonjs/Meshes/geometry";
  50507. export * from "babylonjs/Meshes/groundMesh";
  50508. export * from "babylonjs/Meshes/trailMesh";
  50509. export * from "babylonjs/Meshes/instancedMesh";
  50510. export * from "babylonjs/Meshes/linesMesh";
  50511. export * from "babylonjs/Meshes/mesh";
  50512. export * from "babylonjs/Meshes/mesh.vertexData";
  50513. export * from "babylonjs/Meshes/meshBuilder";
  50514. export * from "babylonjs/Meshes/meshSimplification";
  50515. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50516. export * from "babylonjs/Meshes/polygonMesh";
  50517. export * from "babylonjs/Meshes/subMesh";
  50518. export * from "babylonjs/Meshes/transformNode";
  50519. export * from "babylonjs/Meshes/Builders/index";
  50520. }
  50521. declare module "babylonjs/Morph/index" {
  50522. export * from "babylonjs/Morph/morphTarget";
  50523. export * from "babylonjs/Morph/morphTargetManager";
  50524. }
  50525. declare module "babylonjs/Offline/database" {
  50526. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50527. /**
  50528. * Class used to enable access to IndexedDB
  50529. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50530. */
  50531. export class Database implements IOfflineProvider {
  50532. private _callbackManifestChecked;
  50533. private _currentSceneUrl;
  50534. private _db;
  50535. private _enableSceneOffline;
  50536. private _enableTexturesOffline;
  50537. private _manifestVersionFound;
  50538. private _mustUpdateRessources;
  50539. private _hasReachedQuota;
  50540. private _isSupported;
  50541. private _idbFactory;
  50542. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50543. private static IsUASupportingBlobStorage;
  50544. /**
  50545. * Gets a boolean indicating if Database storate is enabled (off by default)
  50546. */
  50547. static IDBStorageEnabled: boolean;
  50548. /**
  50549. * Gets a boolean indicating if scene must be saved in the database
  50550. */
  50551. readonly enableSceneOffline: boolean;
  50552. /**
  50553. * Gets a boolean indicating if textures must be saved in the database
  50554. */
  50555. readonly enableTexturesOffline: boolean;
  50556. /**
  50557. * Creates a new Database
  50558. * @param urlToScene defines the url to load the scene
  50559. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50560. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50561. */
  50562. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50563. private static _ParseURL;
  50564. private static _ReturnFullUrlLocation;
  50565. private _checkManifestFile;
  50566. /**
  50567. * Open the database and make it available
  50568. * @param successCallback defines the callback to call on success
  50569. * @param errorCallback defines the callback to call on error
  50570. */
  50571. open(successCallback: () => void, errorCallback: () => void): void;
  50572. /**
  50573. * Loads an image from the database
  50574. * @param url defines the url to load from
  50575. * @param image defines the target DOM image
  50576. */
  50577. loadImage(url: string, image: HTMLImageElement): void;
  50578. private _loadImageFromDBAsync;
  50579. private _saveImageIntoDBAsync;
  50580. private _checkVersionFromDB;
  50581. private _loadVersionFromDBAsync;
  50582. private _saveVersionIntoDBAsync;
  50583. /**
  50584. * Loads a file from database
  50585. * @param url defines the URL to load from
  50586. * @param sceneLoaded defines a callback to call on success
  50587. * @param progressCallBack defines a callback to call when progress changed
  50588. * @param errorCallback defines a callback to call on error
  50589. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50590. */
  50591. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50592. private _loadFileAsync;
  50593. private _saveFileAsync;
  50594. /**
  50595. * Validates if xhr data is correct
  50596. * @param xhr defines the request to validate
  50597. * @param dataType defines the expected data type
  50598. * @returns true if data is correct
  50599. */
  50600. private static _ValidateXHRData;
  50601. }
  50602. }
  50603. declare module "babylonjs/Offline/index" {
  50604. export * from "babylonjs/Offline/database";
  50605. export * from "babylonjs/Offline/IOfflineProvider";
  50606. }
  50607. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50608. /** @hidden */
  50609. export var gpuUpdateParticlesPixelShader: {
  50610. name: string;
  50611. shader: string;
  50612. };
  50613. }
  50614. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50615. /** @hidden */
  50616. export var gpuUpdateParticlesVertexShader: {
  50617. name: string;
  50618. shader: string;
  50619. };
  50620. }
  50621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50622. /** @hidden */
  50623. export var clipPlaneFragmentDeclaration2: {
  50624. name: string;
  50625. shader: string;
  50626. };
  50627. }
  50628. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50629. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50630. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50632. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50633. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50634. /** @hidden */
  50635. export var gpuRenderParticlesPixelShader: {
  50636. name: string;
  50637. shader: string;
  50638. };
  50639. }
  50640. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50641. /** @hidden */
  50642. export var clipPlaneVertexDeclaration2: {
  50643. name: string;
  50644. shader: string;
  50645. };
  50646. }
  50647. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50649. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50650. /** @hidden */
  50651. export var gpuRenderParticlesVertexShader: {
  50652. name: string;
  50653. shader: string;
  50654. };
  50655. }
  50656. declare module "babylonjs/Particles/gpuParticleSystem" {
  50657. import { Nullable } from "babylonjs/types";
  50658. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50659. import { Observable } from "babylonjs/Misc/observable";
  50660. import { Color4, Color3 } from "babylonjs/Maths/math";
  50661. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50662. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50665. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50666. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50667. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50668. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50669. /**
  50670. * This represents a GPU particle system in Babylon
  50671. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50672. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50673. */
  50674. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50675. /**
  50676. * The layer mask we are rendering the particles through.
  50677. */
  50678. layerMask: number;
  50679. private _capacity;
  50680. private _activeCount;
  50681. private _currentActiveCount;
  50682. private _accumulatedCount;
  50683. private _renderEffect;
  50684. private _updateEffect;
  50685. private _buffer0;
  50686. private _buffer1;
  50687. private _spriteBuffer;
  50688. private _updateVAO;
  50689. private _renderVAO;
  50690. private _targetIndex;
  50691. private _sourceBuffer;
  50692. private _targetBuffer;
  50693. private _engine;
  50694. private _currentRenderId;
  50695. private _started;
  50696. private _stopped;
  50697. private _timeDelta;
  50698. private _randomTexture;
  50699. private _randomTexture2;
  50700. private _attributesStrideSize;
  50701. private _updateEffectOptions;
  50702. private _randomTextureSize;
  50703. private _actualFrame;
  50704. private readonly _rawTextureWidth;
  50705. /**
  50706. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50707. */
  50708. static readonly IsSupported: boolean;
  50709. /**
  50710. * An event triggered when the system is disposed.
  50711. */
  50712. onDisposeObservable: Observable<GPUParticleSystem>;
  50713. /**
  50714. * Gets the maximum number of particles active at the same time.
  50715. * @returns The max number of active particles.
  50716. */
  50717. getCapacity(): number;
  50718. /**
  50719. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50720. * to override the particles.
  50721. */
  50722. forceDepthWrite: boolean;
  50723. /**
  50724. * Gets or set the number of active particles
  50725. */
  50726. activeParticleCount: number;
  50727. private _preWarmDone;
  50728. /**
  50729. * Is this system ready to be used/rendered
  50730. * @return true if the system is ready
  50731. */
  50732. isReady(): boolean;
  50733. /**
  50734. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50735. * @returns True if it has been started, otherwise false.
  50736. */
  50737. isStarted(): boolean;
  50738. /**
  50739. * Starts the particle system and begins to emit
  50740. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50741. */
  50742. start(delay?: number): void;
  50743. /**
  50744. * Stops the particle system.
  50745. */
  50746. stop(): void;
  50747. /**
  50748. * Remove all active particles
  50749. */
  50750. reset(): void;
  50751. /**
  50752. * Returns the string "GPUParticleSystem"
  50753. * @returns a string containing the class name
  50754. */
  50755. getClassName(): string;
  50756. private _colorGradientsTexture;
  50757. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50758. /**
  50759. * Adds a new color gradient
  50760. * @param gradient defines the gradient to use (between 0 and 1)
  50761. * @param color1 defines the color to affect to the specified gradient
  50762. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50763. * @returns the current particle system
  50764. */
  50765. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50766. /**
  50767. * Remove a specific color gradient
  50768. * @param gradient defines the gradient to remove
  50769. * @returns the current particle system
  50770. */
  50771. removeColorGradient(gradient: number): GPUParticleSystem;
  50772. private _angularSpeedGradientsTexture;
  50773. private _sizeGradientsTexture;
  50774. private _velocityGradientsTexture;
  50775. private _limitVelocityGradientsTexture;
  50776. private _dragGradientsTexture;
  50777. private _addFactorGradient;
  50778. /**
  50779. * Adds a new size gradient
  50780. * @param gradient defines the gradient to use (between 0 and 1)
  50781. * @param factor defines the size factor to affect to the specified gradient
  50782. * @returns the current particle system
  50783. */
  50784. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50785. /**
  50786. * Remove a specific size gradient
  50787. * @param gradient defines the gradient to remove
  50788. * @returns the current particle system
  50789. */
  50790. removeSizeGradient(gradient: number): GPUParticleSystem;
  50791. /**
  50792. * Adds a new angular speed gradient
  50793. * @param gradient defines the gradient to use (between 0 and 1)
  50794. * @param factor defines the angular speed to affect to the specified gradient
  50795. * @returns the current particle system
  50796. */
  50797. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50798. /**
  50799. * Remove a specific angular speed gradient
  50800. * @param gradient defines the gradient to remove
  50801. * @returns the current particle system
  50802. */
  50803. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50804. /**
  50805. * Adds a new velocity gradient
  50806. * @param gradient defines the gradient to use (between 0 and 1)
  50807. * @param factor defines the velocity to affect to the specified gradient
  50808. * @returns the current particle system
  50809. */
  50810. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50811. /**
  50812. * Remove a specific velocity gradient
  50813. * @param gradient defines the gradient to remove
  50814. * @returns the current particle system
  50815. */
  50816. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50817. /**
  50818. * Adds a new limit velocity gradient
  50819. * @param gradient defines the gradient to use (between 0 and 1)
  50820. * @param factor defines the limit velocity value to affect to the specified gradient
  50821. * @returns the current particle system
  50822. */
  50823. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50824. /**
  50825. * Remove a specific limit velocity gradient
  50826. * @param gradient defines the gradient to remove
  50827. * @returns the current particle system
  50828. */
  50829. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50830. /**
  50831. * Adds a new drag gradient
  50832. * @param gradient defines the gradient to use (between 0 and 1)
  50833. * @param factor defines the drag value to affect to the specified gradient
  50834. * @returns the current particle system
  50835. */
  50836. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50837. /**
  50838. * Remove a specific drag gradient
  50839. * @param gradient defines the gradient to remove
  50840. * @returns the current particle system
  50841. */
  50842. removeDragGradient(gradient: number): GPUParticleSystem;
  50843. /**
  50844. * Not supported by GPUParticleSystem
  50845. * @param gradient defines the gradient to use (between 0 and 1)
  50846. * @param factor defines the emit rate value to affect to the specified gradient
  50847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50848. * @returns the current particle system
  50849. */
  50850. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50851. /**
  50852. * Not supported by GPUParticleSystem
  50853. * @param gradient defines the gradient to remove
  50854. * @returns the current particle system
  50855. */
  50856. removeEmitRateGradient(gradient: number): IParticleSystem;
  50857. /**
  50858. * Not supported by GPUParticleSystem
  50859. * @param gradient defines the gradient to use (between 0 and 1)
  50860. * @param factor defines the start size value to affect to the specified gradient
  50861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50862. * @returns the current particle system
  50863. */
  50864. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50865. /**
  50866. * Not supported by GPUParticleSystem
  50867. * @param gradient defines the gradient to remove
  50868. * @returns the current particle system
  50869. */
  50870. removeStartSizeGradient(gradient: number): IParticleSystem;
  50871. /**
  50872. * Not supported by GPUParticleSystem
  50873. * @param gradient defines the gradient to use (between 0 and 1)
  50874. * @param min defines the color remap minimal range
  50875. * @param max defines the color remap maximal range
  50876. * @returns the current particle system
  50877. */
  50878. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50879. /**
  50880. * Not supported by GPUParticleSystem
  50881. * @param gradient defines the gradient to remove
  50882. * @returns the current particle system
  50883. */
  50884. removeColorRemapGradient(): IParticleSystem;
  50885. /**
  50886. * Not supported by GPUParticleSystem
  50887. * @param gradient defines the gradient to use (between 0 and 1)
  50888. * @param min defines the alpha remap minimal range
  50889. * @param max defines the alpha remap maximal range
  50890. * @returns the current particle system
  50891. */
  50892. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50893. /**
  50894. * Not supported by GPUParticleSystem
  50895. * @param gradient defines the gradient to remove
  50896. * @returns the current particle system
  50897. */
  50898. removeAlphaRemapGradient(): IParticleSystem;
  50899. /**
  50900. * Not supported by GPUParticleSystem
  50901. * @param gradient defines the gradient to use (between 0 and 1)
  50902. * @param color defines the color to affect to the specified gradient
  50903. * @returns the current particle system
  50904. */
  50905. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50906. /**
  50907. * Not supported by GPUParticleSystem
  50908. * @param gradient defines the gradient to remove
  50909. * @returns the current particle system
  50910. */
  50911. removeRampGradient(): IParticleSystem;
  50912. /**
  50913. * Not supported by GPUParticleSystem
  50914. * @returns the list of ramp gradients
  50915. */
  50916. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50917. /**
  50918. * Not supported by GPUParticleSystem
  50919. * Gets or sets a boolean indicating that ramp gradients must be used
  50920. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50921. */
  50922. useRampGradients: boolean;
  50923. /**
  50924. * Not supported by GPUParticleSystem
  50925. * @param gradient defines the gradient to use (between 0 and 1)
  50926. * @param factor defines the life time factor to affect to the specified gradient
  50927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50928. * @returns the current particle system
  50929. */
  50930. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50931. /**
  50932. * Not supported by GPUParticleSystem
  50933. * @param gradient defines the gradient to remove
  50934. * @returns the current particle system
  50935. */
  50936. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50937. /**
  50938. * Instantiates a GPU particle system.
  50939. * 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.
  50940. * @param name The name of the particle system
  50941. * @param options The options used to create the system
  50942. * @param scene The scene the particle system belongs to
  50943. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50944. */
  50945. constructor(name: string, options: Partial<{
  50946. capacity: number;
  50947. randomTextureSize: number;
  50948. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50949. protected _reset(): void;
  50950. private _createUpdateVAO;
  50951. private _createRenderVAO;
  50952. private _initialize;
  50953. /** @hidden */
  50954. _recreateUpdateEffect(): void;
  50955. /** @hidden */
  50956. _recreateRenderEffect(): void;
  50957. /**
  50958. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50959. * @param preWarm defines if we are in the pre-warmimg phase
  50960. */
  50961. animate(preWarm?: boolean): void;
  50962. private _createFactorGradientTexture;
  50963. private _createSizeGradientTexture;
  50964. private _createAngularSpeedGradientTexture;
  50965. private _createVelocityGradientTexture;
  50966. private _createLimitVelocityGradientTexture;
  50967. private _createDragGradientTexture;
  50968. private _createColorGradientTexture;
  50969. /**
  50970. * Renders the particle system in its current state
  50971. * @param preWarm defines if the system should only update the particles but not render them
  50972. * @returns the current number of particles
  50973. */
  50974. render(preWarm?: boolean): number;
  50975. /**
  50976. * Rebuilds the particle system
  50977. */
  50978. rebuild(): void;
  50979. private _releaseBuffers;
  50980. private _releaseVAOs;
  50981. /**
  50982. * Disposes the particle system and free the associated resources
  50983. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50984. */
  50985. dispose(disposeTexture?: boolean): void;
  50986. /**
  50987. * Clones the particle system.
  50988. * @param name The name of the cloned object
  50989. * @param newEmitter The new emitter to use
  50990. * @returns the cloned particle system
  50991. */
  50992. clone(name: string, newEmitter: any): GPUParticleSystem;
  50993. /**
  50994. * Serializes the particle system to a JSON object.
  50995. * @returns the JSON object
  50996. */
  50997. serialize(): any;
  50998. /**
  50999. * Parses a JSON object to create a GPU particle system.
  51000. * @param parsedParticleSystem The JSON object to parse
  51001. * @param scene The scene to create the particle system in
  51002. * @param rootUrl The root url to use to load external dependencies like texture
  51003. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51004. * @returns the parsed GPU particle system
  51005. */
  51006. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51007. }
  51008. }
  51009. declare module "babylonjs/Particles/particleSystemSet" {
  51010. import { Nullable } from "babylonjs/types";
  51011. import { Color3 } from "babylonjs/Maths/math";
  51012. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51014. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51015. import { Scene, IDisposable } from "babylonjs/scene";
  51016. /**
  51017. * Represents a set of particle systems working together to create a specific effect
  51018. */
  51019. export class ParticleSystemSet implements IDisposable {
  51020. private _emitterCreationOptions;
  51021. private _emitterNode;
  51022. /**
  51023. * Gets the particle system list
  51024. */
  51025. systems: IParticleSystem[];
  51026. /**
  51027. * Gets the emitter node used with this set
  51028. */
  51029. readonly emitterNode: Nullable<TransformNode>;
  51030. /**
  51031. * Creates a new emitter mesh as a sphere
  51032. * @param options defines the options used to create the sphere
  51033. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51034. * @param scene defines the hosting scene
  51035. */
  51036. setEmitterAsSphere(options: {
  51037. diameter: number;
  51038. segments: number;
  51039. color: Color3;
  51040. }, renderingGroupId: number, scene: Scene): void;
  51041. /**
  51042. * Starts all particle systems of the set
  51043. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51044. */
  51045. start(emitter?: AbstractMesh): void;
  51046. /**
  51047. * Release all associated resources
  51048. */
  51049. dispose(): void;
  51050. /**
  51051. * Serialize the set into a JSON compatible object
  51052. * @returns a JSON compatible representation of the set
  51053. */
  51054. serialize(): any;
  51055. /**
  51056. * Parse a new ParticleSystemSet from a serialized source
  51057. * @param data defines a JSON compatible representation of the set
  51058. * @param scene defines the hosting scene
  51059. * @param gpu defines if we want GPU particles or CPU particles
  51060. * @returns a new ParticleSystemSet
  51061. */
  51062. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51063. }
  51064. }
  51065. declare module "babylonjs/Particles/particleHelper" {
  51066. import { Nullable } from "babylonjs/types";
  51067. import { Scene } from "babylonjs/scene";
  51068. import { Vector3 } from "babylonjs/Maths/math";
  51069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51070. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51071. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51072. /**
  51073. * This class is made for on one-liner static method to help creating particle system set.
  51074. */
  51075. export class ParticleHelper {
  51076. /**
  51077. * Gets or sets base Assets URL
  51078. */
  51079. static BaseAssetsUrl: string;
  51080. /**
  51081. * Create a default particle system that you can tweak
  51082. * @param emitter defines the emitter to use
  51083. * @param capacity defines the system capacity (default is 500 particles)
  51084. * @param scene defines the hosting scene
  51085. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51086. * @returns the new Particle system
  51087. */
  51088. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51089. /**
  51090. * This is the main static method (one-liner) of this helper to create different particle systems
  51091. * @param type This string represents the type to the particle system to create
  51092. * @param scene The scene where the particle system should live
  51093. * @param gpu If the system will use gpu
  51094. * @returns the ParticleSystemSet created
  51095. */
  51096. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51097. /**
  51098. * Static function used to export a particle system to a ParticleSystemSet variable.
  51099. * Please note that the emitter shape is not exported
  51100. * @param systems defines the particle systems to export
  51101. * @returns the created particle system set
  51102. */
  51103. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51104. }
  51105. }
  51106. declare module "babylonjs/Particles/particleSystemComponent" {
  51107. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51108. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51109. import "babylonjs/Shaders/particles.vertex";
  51110. module "babylonjs/Engines/engine" {
  51111. interface Engine {
  51112. /**
  51113. * Create an effect to use with particle systems.
  51114. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51115. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51116. * @param uniformsNames defines a list of attribute names
  51117. * @param samplers defines an array of string used to represent textures
  51118. * @param defines defines the string containing the defines to use to compile the shaders
  51119. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51120. * @param onCompiled defines a function to call when the effect creation is successful
  51121. * @param onError defines a function to call when the effect creation has failed
  51122. * @returns the new Effect
  51123. */
  51124. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51125. }
  51126. }
  51127. module "babylonjs/Meshes/mesh" {
  51128. interface Mesh {
  51129. /**
  51130. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51131. * @returns an array of IParticleSystem
  51132. */
  51133. getEmittedParticleSystems(): IParticleSystem[];
  51134. /**
  51135. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51136. * @returns an array of IParticleSystem
  51137. */
  51138. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51139. }
  51140. }
  51141. /**
  51142. * @hidden
  51143. */
  51144. export var _IDoNeedToBeInTheBuild: number;
  51145. }
  51146. declare module "babylonjs/Particles/index" {
  51147. export * from "babylonjs/Particles/baseParticleSystem";
  51148. export * from "babylonjs/Particles/EmitterTypes/index";
  51149. export * from "babylonjs/Particles/gpuParticleSystem";
  51150. export * from "babylonjs/Particles/IParticleSystem";
  51151. export * from "babylonjs/Particles/particle";
  51152. export * from "babylonjs/Particles/particleHelper";
  51153. export * from "babylonjs/Particles/particleSystem";
  51154. export * from "babylonjs/Particles/particleSystemComponent";
  51155. export * from "babylonjs/Particles/particleSystemSet";
  51156. export * from "babylonjs/Particles/solidParticle";
  51157. export * from "babylonjs/Particles/solidParticleSystem";
  51158. export * from "babylonjs/Particles/subEmitter";
  51159. }
  51160. declare module "babylonjs/Physics/physicsEngineComponent" {
  51161. import { Nullable } from "babylonjs/types";
  51162. import { Observable, Observer } from "babylonjs/Misc/observable";
  51163. import { Vector3 } from "babylonjs/Maths/math";
  51164. import { Mesh } from "babylonjs/Meshes/mesh";
  51165. import { ISceneComponent } from "babylonjs/sceneComponent";
  51166. import { Scene } from "babylonjs/scene";
  51167. import { Node } from "babylonjs/node";
  51168. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51169. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51170. module "babylonjs/scene" {
  51171. interface Scene {
  51172. /** @hidden (Backing field) */
  51173. _physicsEngine: Nullable<IPhysicsEngine>;
  51174. /**
  51175. * Gets the current physics engine
  51176. * @returns a IPhysicsEngine or null if none attached
  51177. */
  51178. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51179. /**
  51180. * Enables physics to the current scene
  51181. * @param gravity defines the scene's gravity for the physics engine
  51182. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51183. * @return a boolean indicating if the physics engine was initialized
  51184. */
  51185. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51186. /**
  51187. * Disables and disposes the physics engine associated with the scene
  51188. */
  51189. disablePhysicsEngine(): void;
  51190. /**
  51191. * Gets a boolean indicating if there is an active physics engine
  51192. * @returns a boolean indicating if there is an active physics engine
  51193. */
  51194. isPhysicsEnabled(): boolean;
  51195. /**
  51196. * Deletes a physics compound impostor
  51197. * @param compound defines the compound to delete
  51198. */
  51199. deleteCompoundImpostor(compound: any): void;
  51200. /**
  51201. * An event triggered when physic simulation is about to be run
  51202. */
  51203. onBeforePhysicsObservable: Observable<Scene>;
  51204. /**
  51205. * An event triggered when physic simulation has been done
  51206. */
  51207. onAfterPhysicsObservable: Observable<Scene>;
  51208. }
  51209. }
  51210. module "babylonjs/Meshes/abstractMesh" {
  51211. interface AbstractMesh {
  51212. /** @hidden */
  51213. _physicsImpostor: Nullable<PhysicsImpostor>;
  51214. /**
  51215. * Gets or sets impostor used for physic simulation
  51216. * @see http://doc.babylonjs.com/features/physics_engine
  51217. */
  51218. physicsImpostor: Nullable<PhysicsImpostor>;
  51219. /**
  51220. * Gets the current physics impostor
  51221. * @see http://doc.babylonjs.com/features/physics_engine
  51222. * @returns a physics impostor or null
  51223. */
  51224. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51225. /** Apply a physic impulse to the mesh
  51226. * @param force defines the force to apply
  51227. * @param contactPoint defines where to apply the force
  51228. * @returns the current mesh
  51229. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51230. */
  51231. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51232. /**
  51233. * Creates a physic joint between two meshes
  51234. * @param otherMesh defines the other mesh to use
  51235. * @param pivot1 defines the pivot to use on this mesh
  51236. * @param pivot2 defines the pivot to use on the other mesh
  51237. * @param options defines additional options (can be plugin dependent)
  51238. * @returns the current mesh
  51239. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51240. */
  51241. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51242. /** @hidden */
  51243. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51244. }
  51245. }
  51246. /**
  51247. * Defines the physics engine scene component responsible to manage a physics engine
  51248. */
  51249. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51250. /**
  51251. * The component name helpful to identify the component in the list of scene components.
  51252. */
  51253. readonly name: string;
  51254. /**
  51255. * The scene the component belongs to.
  51256. */
  51257. scene: Scene;
  51258. /**
  51259. * Creates a new instance of the component for the given scene
  51260. * @param scene Defines the scene to register the component in
  51261. */
  51262. constructor(scene: Scene);
  51263. /**
  51264. * Registers the component in a given scene
  51265. */
  51266. register(): void;
  51267. /**
  51268. * Rebuilds the elements related to this component in case of
  51269. * context lost for instance.
  51270. */
  51271. rebuild(): void;
  51272. /**
  51273. * Disposes the component and the associated ressources
  51274. */
  51275. dispose(): void;
  51276. }
  51277. }
  51278. declare module "babylonjs/Physics/physicsHelper" {
  51279. import { Nullable } from "babylonjs/types";
  51280. import { Vector3 } from "babylonjs/Maths/math";
  51281. import { Mesh } from "babylonjs/Meshes/mesh";
  51282. import { Ray } from "babylonjs/Culling/ray";
  51283. import { Scene } from "babylonjs/scene";
  51284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51285. /**
  51286. * A helper for physics simulations
  51287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51288. */
  51289. export class PhysicsHelper {
  51290. private _scene;
  51291. private _physicsEngine;
  51292. /**
  51293. * Initializes the Physics helper
  51294. * @param scene Babylon.js scene
  51295. */
  51296. constructor(scene: Scene);
  51297. /**
  51298. * Applies a radial explosion impulse
  51299. * @param origin the origin of the explosion
  51300. * @param radius the explosion radius
  51301. * @param strength the explosion strength
  51302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51303. * @returns A physics radial explosion event, or null
  51304. */
  51305. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51306. /**
  51307. * Applies a radial explosion force
  51308. * @param origin the origin of the explosion
  51309. * @param radius the explosion radius
  51310. * @param strength the explosion strength
  51311. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51312. * @returns A physics radial explosion event, or null
  51313. */
  51314. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51315. /**
  51316. * Creates a gravitational field
  51317. * @param origin the origin of the explosion
  51318. * @param radius the explosion radius
  51319. * @param strength the explosion strength
  51320. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51321. * @returns A physics gravitational field event, or null
  51322. */
  51323. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51324. /**
  51325. * Creates a physics updraft event
  51326. * @param origin the origin of the updraft
  51327. * @param radius the radius of the updraft
  51328. * @param strength the strength of the updraft
  51329. * @param height the height of the updraft
  51330. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51331. * @returns A physics updraft event, or null
  51332. */
  51333. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51334. /**
  51335. * Creates a physics vortex event
  51336. * @param origin the of the vortex
  51337. * @param radius the radius of the vortex
  51338. * @param strength the strength of the vortex
  51339. * @param height the height of the vortex
  51340. * @returns a Physics vortex event, or null
  51341. * A physics vortex event or null
  51342. */
  51343. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51344. }
  51345. /**
  51346. * Represents a physics radial explosion event
  51347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51348. */
  51349. export class PhysicsRadialExplosionEvent {
  51350. private _scene;
  51351. private _sphere;
  51352. private _sphereOptions;
  51353. private _rays;
  51354. private _dataFetched;
  51355. /**
  51356. * Initializes a radial explosioin event
  51357. * @param scene BabylonJS scene
  51358. */
  51359. constructor(scene: Scene);
  51360. /**
  51361. * Returns the data related to the radial explosion event (sphere & rays).
  51362. * @returns The radial explosion event data
  51363. */
  51364. getData(): PhysicsRadialExplosionEventData;
  51365. /**
  51366. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51367. * @param impostor A physics imposter
  51368. * @param origin the origin of the explosion
  51369. * @param radius the explosion radius
  51370. * @param strength the explosion strength
  51371. * @param falloff possible options: Constant & Linear
  51372. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51373. */
  51374. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51375. /**
  51376. * Disposes the sphere.
  51377. * @param force Specifies if the sphere should be disposed by force
  51378. */
  51379. dispose(force?: boolean): void;
  51380. /*** Helpers ***/
  51381. private _prepareSphere;
  51382. private _intersectsWithSphere;
  51383. }
  51384. /**
  51385. * Represents a gravitational field event
  51386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51387. */
  51388. export class PhysicsGravitationalFieldEvent {
  51389. private _physicsHelper;
  51390. private _scene;
  51391. private _origin;
  51392. private _radius;
  51393. private _strength;
  51394. private _falloff;
  51395. private _tickCallback;
  51396. private _sphere;
  51397. private _dataFetched;
  51398. /**
  51399. * Initializes the physics gravitational field event
  51400. * @param physicsHelper A physics helper
  51401. * @param scene BabylonJS scene
  51402. * @param origin The origin position of the gravitational field event
  51403. * @param radius The radius of the gravitational field event
  51404. * @param strength The strength of the gravitational field event
  51405. * @param falloff The falloff for the gravitational field event
  51406. */
  51407. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51408. /**
  51409. * Returns the data related to the gravitational field event (sphere).
  51410. * @returns A gravitational field event
  51411. */
  51412. getData(): PhysicsGravitationalFieldEventData;
  51413. /**
  51414. * Enables the gravitational field.
  51415. */
  51416. enable(): void;
  51417. /**
  51418. * Disables the gravitational field.
  51419. */
  51420. disable(): void;
  51421. /**
  51422. * Disposes the sphere.
  51423. * @param force The force to dispose from the gravitational field event
  51424. */
  51425. dispose(force?: boolean): void;
  51426. private _tick;
  51427. }
  51428. /**
  51429. * Represents a physics updraft event
  51430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51431. */
  51432. export class PhysicsUpdraftEvent {
  51433. private _scene;
  51434. private _origin;
  51435. private _radius;
  51436. private _strength;
  51437. private _height;
  51438. private _updraftMode;
  51439. private _physicsEngine;
  51440. private _originTop;
  51441. private _originDirection;
  51442. private _tickCallback;
  51443. private _cylinder;
  51444. private _cylinderPosition;
  51445. private _dataFetched;
  51446. /**
  51447. * Initializes the physics updraft event
  51448. * @param _scene BabylonJS scene
  51449. * @param _origin The origin position of the updraft
  51450. * @param _radius The radius of the updraft
  51451. * @param _strength The strength of the updraft
  51452. * @param _height The height of the updraft
  51453. * @param _updraftMode The mode of the updraft
  51454. */
  51455. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51456. /**
  51457. * Returns the data related to the updraft event (cylinder).
  51458. * @returns A physics updraft event
  51459. */
  51460. getData(): PhysicsUpdraftEventData;
  51461. /**
  51462. * Enables the updraft.
  51463. */
  51464. enable(): void;
  51465. /**
  51466. * Disables the cortex.
  51467. */
  51468. disable(): void;
  51469. /**
  51470. * Disposes the sphere.
  51471. * @param force Specifies if the updraft should be disposed by force
  51472. */
  51473. dispose(force?: boolean): void;
  51474. private getImpostorForceAndContactPoint;
  51475. private _tick;
  51476. /*** Helpers ***/
  51477. private _prepareCylinder;
  51478. private _intersectsWithCylinder;
  51479. }
  51480. /**
  51481. * Represents a physics vortex event
  51482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51483. */
  51484. export class PhysicsVortexEvent {
  51485. private _scene;
  51486. private _origin;
  51487. private _radius;
  51488. private _strength;
  51489. private _height;
  51490. private _physicsEngine;
  51491. private _originTop;
  51492. private _centripetalForceThreshold;
  51493. private _updraftMultiplier;
  51494. private _tickCallback;
  51495. private _cylinder;
  51496. private _cylinderPosition;
  51497. private _dataFetched;
  51498. /**
  51499. * Initializes the physics vortex event
  51500. * @param _scene The BabylonJS scene
  51501. * @param _origin The origin position of the vortex
  51502. * @param _radius The radius of the vortex
  51503. * @param _strength The strength of the vortex
  51504. * @param _height The height of the vortex
  51505. */
  51506. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51507. /**
  51508. * Returns the data related to the vortex event (cylinder).
  51509. * @returns The physics vortex event data
  51510. */
  51511. getData(): PhysicsVortexEventData;
  51512. /**
  51513. * Enables the vortex.
  51514. */
  51515. enable(): void;
  51516. /**
  51517. * Disables the cortex.
  51518. */
  51519. disable(): void;
  51520. /**
  51521. * Disposes the sphere.
  51522. * @param force
  51523. */
  51524. dispose(force?: boolean): void;
  51525. private getImpostorForceAndContactPoint;
  51526. private _tick;
  51527. /*** Helpers ***/
  51528. private _prepareCylinder;
  51529. private _intersectsWithCylinder;
  51530. }
  51531. /**
  51532. * The strenght of the force in correspondence to the distance of the affected object
  51533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51534. */
  51535. export enum PhysicsRadialImpulseFalloff {
  51536. /** Defines that impulse is constant in strength across it's whole radius */
  51537. Constant = 0,
  51538. /** DEfines that impulse gets weaker if it's further from the origin */
  51539. Linear = 1
  51540. }
  51541. /**
  51542. * The strength of the force in correspondence to the distance of the affected object
  51543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51544. */
  51545. export enum PhysicsUpdraftMode {
  51546. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51547. Center = 0,
  51548. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51549. Perpendicular = 1
  51550. }
  51551. /**
  51552. * Interface for a physics force and contact point
  51553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51554. */
  51555. export interface PhysicsForceAndContactPoint {
  51556. /**
  51557. * The force applied at the contact point
  51558. */
  51559. force: Vector3;
  51560. /**
  51561. * The contact point
  51562. */
  51563. contactPoint: Vector3;
  51564. }
  51565. /**
  51566. * Interface for radial explosion event data
  51567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51568. */
  51569. export interface PhysicsRadialExplosionEventData {
  51570. /**
  51571. * A sphere used for the radial explosion event
  51572. */
  51573. sphere: Mesh;
  51574. /**
  51575. * An array of rays for the radial explosion event
  51576. */
  51577. rays: Array<Ray>;
  51578. }
  51579. /**
  51580. * Interface for gravitational field event data
  51581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51582. */
  51583. export interface PhysicsGravitationalFieldEventData {
  51584. /**
  51585. * A sphere mesh used for the gravitational field event
  51586. */
  51587. sphere: Mesh;
  51588. }
  51589. /**
  51590. * Interface for updraft event data
  51591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51592. */
  51593. export interface PhysicsUpdraftEventData {
  51594. /**
  51595. * A cylinder used for the updraft event
  51596. */
  51597. cylinder: Mesh;
  51598. }
  51599. /**
  51600. * Interface for vortex event data
  51601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51602. */
  51603. export interface PhysicsVortexEventData {
  51604. /**
  51605. * A cylinder used for the vortex event
  51606. */
  51607. cylinder: Mesh;
  51608. }
  51609. }
  51610. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51611. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51612. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51613. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51614. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51615. import { Nullable } from "babylonjs/types";
  51616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51617. /**
  51618. * AmmoJS Physics plugin
  51619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51620. * @see https://github.com/kripken/ammo.js/
  51621. */
  51622. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51623. private _useDeltaForWorldStep;
  51624. /**
  51625. * Reference to the Ammo library
  51626. */
  51627. bjsAMMO: any;
  51628. /**
  51629. * Created ammoJS world which physics bodies are added to
  51630. */
  51631. world: any;
  51632. /**
  51633. * Name of the plugin
  51634. */
  51635. name: string;
  51636. private _timeStep;
  51637. private _fixedTimeStep;
  51638. private _maxSteps;
  51639. private _tmpQuaternion;
  51640. private _tmpAmmoTransform;
  51641. private _tmpAmmoQuaternion;
  51642. private _tmpAmmoConcreteContactResultCallback;
  51643. private _collisionConfiguration;
  51644. private _dispatcher;
  51645. private _overlappingPairCache;
  51646. private _solver;
  51647. private _tmpAmmoVectorA;
  51648. private _tmpAmmoVectorB;
  51649. private _tmpAmmoVectorC;
  51650. private _tmpContactCallbackResult;
  51651. private static readonly DISABLE_COLLISION_FLAG;
  51652. private static readonly KINEMATIC_FLAG;
  51653. private static readonly DISABLE_DEACTIVATION_FLAG;
  51654. /**
  51655. * Initializes the ammoJS plugin
  51656. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51657. * @param ammoInjection can be used to inject your own ammo reference
  51658. */
  51659. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51660. /**
  51661. * Sets the gravity of the physics world (m/(s^2))
  51662. * @param gravity Gravity to set
  51663. */
  51664. setGravity(gravity: Vector3): void;
  51665. /**
  51666. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51667. * @param timeStep timestep to use in seconds
  51668. */
  51669. setTimeStep(timeStep: number): void;
  51670. /**
  51671. * 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)
  51672. * @param fixedTimeStep fixedTimeStep to use in seconds
  51673. */
  51674. setFixedTimeStep(fixedTimeStep: number): void;
  51675. /**
  51676. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51677. * @param maxSteps the maximum number of steps by the physics engine per frame
  51678. */
  51679. setMaxSteps(maxSteps: number): void;
  51680. /**
  51681. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51682. * @returns the current timestep in seconds
  51683. */
  51684. getTimeStep(): number;
  51685. private _isImpostorInContact;
  51686. private _isImpostorPairInContact;
  51687. private _stepSimulation;
  51688. /**
  51689. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51690. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51691. * After the step the babylon meshes are set to the position of the physics imposters
  51692. * @param delta amount of time to step forward
  51693. * @param impostors array of imposters to update before/after the step
  51694. */
  51695. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51696. private _tmpVector;
  51697. private _tmpMatrix;
  51698. /**
  51699. * Applies an implulse on the imposter
  51700. * @param impostor imposter to apply impulse
  51701. * @param force amount of force to be applied to the imposter
  51702. * @param contactPoint the location to apply the impulse on the imposter
  51703. */
  51704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51705. /**
  51706. * Applies a force on the imposter
  51707. * @param impostor imposter to apply force
  51708. * @param force amount of force to be applied to the imposter
  51709. * @param contactPoint the location to apply the force on the imposter
  51710. */
  51711. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51712. /**
  51713. * Creates a physics body using the plugin
  51714. * @param impostor the imposter to create the physics body on
  51715. */
  51716. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51717. /**
  51718. * Removes the physics body from the imposter and disposes of the body's memory
  51719. * @param impostor imposter to remove the physics body from
  51720. */
  51721. removePhysicsBody(impostor: PhysicsImpostor): void;
  51722. /**
  51723. * Generates a joint
  51724. * @param impostorJoint the imposter joint to create the joint with
  51725. */
  51726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51727. /**
  51728. * Removes a joint
  51729. * @param impostorJoint the imposter joint to remove the joint from
  51730. */
  51731. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51732. private _addMeshVerts;
  51733. private _createShape;
  51734. /**
  51735. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51736. * @param impostor imposter containing the physics body and babylon object
  51737. */
  51738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51739. /**
  51740. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51741. * @param impostor imposter containing the physics body and babylon object
  51742. * @param newPosition new position
  51743. * @param newRotation new rotation
  51744. */
  51745. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51746. /**
  51747. * If this plugin is supported
  51748. * @returns true if its supported
  51749. */
  51750. isSupported(): boolean;
  51751. /**
  51752. * Sets the linear velocity of the physics body
  51753. * @param impostor imposter to set the velocity on
  51754. * @param velocity velocity to set
  51755. */
  51756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51757. /**
  51758. * Sets the angular velocity of the physics body
  51759. * @param impostor imposter to set the velocity on
  51760. * @param velocity velocity to set
  51761. */
  51762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51763. /**
  51764. * gets the linear velocity
  51765. * @param impostor imposter to get linear velocity from
  51766. * @returns linear velocity
  51767. */
  51768. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51769. /**
  51770. * gets the angular velocity
  51771. * @param impostor imposter to get angular velocity from
  51772. * @returns angular velocity
  51773. */
  51774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51775. /**
  51776. * Sets the mass of physics body
  51777. * @param impostor imposter to set the mass on
  51778. * @param mass mass to set
  51779. */
  51780. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51781. /**
  51782. * Gets the mass of the physics body
  51783. * @param impostor imposter to get the mass from
  51784. * @returns mass
  51785. */
  51786. getBodyMass(impostor: PhysicsImpostor): number;
  51787. /**
  51788. * Gets friction of the impostor
  51789. * @param impostor impostor to get friction from
  51790. * @returns friction value
  51791. */
  51792. getBodyFriction(impostor: PhysicsImpostor): number;
  51793. /**
  51794. * Sets friction of the impostor
  51795. * @param impostor impostor to set friction on
  51796. * @param friction friction value
  51797. */
  51798. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51799. /**
  51800. * Gets restitution of the impostor
  51801. * @param impostor impostor to get restitution from
  51802. * @returns restitution value
  51803. */
  51804. getBodyRestitution(impostor: PhysicsImpostor): number;
  51805. /**
  51806. * Sets resitution of the impostor
  51807. * @param impostor impostor to set resitution on
  51808. * @param restitution resitution value
  51809. */
  51810. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51811. /**
  51812. * Sleeps the physics body and stops it from being active
  51813. * @param impostor impostor to sleep
  51814. */
  51815. sleepBody(impostor: PhysicsImpostor): void;
  51816. /**
  51817. * Activates the physics body
  51818. * @param impostor impostor to activate
  51819. */
  51820. wakeUpBody(impostor: PhysicsImpostor): void;
  51821. /**
  51822. * Updates the distance parameters of the joint
  51823. * @param joint joint to update
  51824. * @param maxDistance maximum distance of the joint
  51825. * @param minDistance minimum distance of the joint
  51826. */
  51827. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51828. /**
  51829. * Sets a motor on the joint
  51830. * @param joint joint to set motor on
  51831. * @param speed speed of the motor
  51832. * @param maxForce maximum force of the motor
  51833. * @param motorIndex index of the motor
  51834. */
  51835. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51836. /**
  51837. * Sets the motors limit
  51838. * @param joint joint to set limit on
  51839. * @param upperLimit upper limit
  51840. * @param lowerLimit lower limit
  51841. */
  51842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51843. /**
  51844. * Syncs the position and rotation of a mesh with the impostor
  51845. * @param mesh mesh to sync
  51846. * @param impostor impostor to update the mesh with
  51847. */
  51848. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51849. /**
  51850. * Gets the radius of the impostor
  51851. * @param impostor impostor to get radius from
  51852. * @returns the radius
  51853. */
  51854. getRadius(impostor: PhysicsImpostor): number;
  51855. /**
  51856. * Gets the box size of the impostor
  51857. * @param impostor impostor to get box size from
  51858. * @param result the resulting box size
  51859. */
  51860. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51861. /**
  51862. * Disposes of the impostor
  51863. */
  51864. dispose(): void;
  51865. }
  51866. }
  51867. declare module "babylonjs/Physics/Plugins/index" {
  51868. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51869. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51870. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51871. }
  51872. declare module "babylonjs/Physics/index" {
  51873. export * from "babylonjs/Physics/IPhysicsEngine";
  51874. export * from "babylonjs/Physics/physicsEngine";
  51875. export * from "babylonjs/Physics/physicsEngineComponent";
  51876. export * from "babylonjs/Physics/physicsHelper";
  51877. export * from "babylonjs/Physics/physicsImpostor";
  51878. export * from "babylonjs/Physics/physicsJoint";
  51879. export * from "babylonjs/Physics/Plugins/index";
  51880. }
  51881. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51882. /** @hidden */
  51883. export var blackAndWhitePixelShader: {
  51884. name: string;
  51885. shader: string;
  51886. };
  51887. }
  51888. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51889. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51890. import { Camera } from "babylonjs/Cameras/camera";
  51891. import { Engine } from "babylonjs/Engines/engine";
  51892. import "babylonjs/Shaders/blackAndWhite.fragment";
  51893. /**
  51894. * Post process used to render in black and white
  51895. */
  51896. export class BlackAndWhitePostProcess extends PostProcess {
  51897. /**
  51898. * Linear about to convert he result to black and white (default: 1)
  51899. */
  51900. degree: number;
  51901. /**
  51902. * Creates a black and white post process
  51903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51904. * @param name The name of the effect.
  51905. * @param options The required width/height ratio to downsize to before computing the render pass.
  51906. * @param camera The camera to apply the render pass to.
  51907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51908. * @param engine The engine which the post process will be applied. (default: current engine)
  51909. * @param reusable If the post process can be reused on the same frame. (default: false)
  51910. */
  51911. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51912. }
  51913. }
  51914. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51915. import { Nullable } from "babylonjs/types";
  51916. import { Camera } from "babylonjs/Cameras/camera";
  51917. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51918. import { Engine } from "babylonjs/Engines/engine";
  51919. /**
  51920. * This represents a set of one or more post processes in Babylon.
  51921. * A post process can be used to apply a shader to a texture after it is rendered.
  51922. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51923. */
  51924. export class PostProcessRenderEffect {
  51925. private _postProcesses;
  51926. private _getPostProcesses;
  51927. private _singleInstance;
  51928. private _cameras;
  51929. private _indicesForCamera;
  51930. /**
  51931. * Name of the effect
  51932. * @hidden
  51933. */
  51934. _name: string;
  51935. /**
  51936. * Instantiates a post process render effect.
  51937. * A post process can be used to apply a shader to a texture after it is rendered.
  51938. * @param engine The engine the effect is tied to
  51939. * @param name The name of the effect
  51940. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51941. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51942. */
  51943. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51944. /**
  51945. * Checks if all the post processes in the effect are supported.
  51946. */
  51947. readonly isSupported: boolean;
  51948. /**
  51949. * Updates the current state of the effect
  51950. * @hidden
  51951. */
  51952. _update(): void;
  51953. /**
  51954. * Attaches the effect on cameras
  51955. * @param cameras The camera to attach to.
  51956. * @hidden
  51957. */
  51958. _attachCameras(cameras: Camera): void;
  51959. /**
  51960. * Attaches the effect on cameras
  51961. * @param cameras The camera to attach to.
  51962. * @hidden
  51963. */
  51964. _attachCameras(cameras: Camera[]): void;
  51965. /**
  51966. * Detatches the effect on cameras
  51967. * @param cameras The camera to detatch from.
  51968. * @hidden
  51969. */
  51970. _detachCameras(cameras: Camera): void;
  51971. /**
  51972. * Detatches the effect on cameras
  51973. * @param cameras The camera to detatch from.
  51974. * @hidden
  51975. */
  51976. _detachCameras(cameras: Camera[]): void;
  51977. /**
  51978. * Enables the effect on given cameras
  51979. * @param cameras The camera to enable.
  51980. * @hidden
  51981. */
  51982. _enable(cameras: Camera): void;
  51983. /**
  51984. * Enables the effect on given cameras
  51985. * @param cameras The camera to enable.
  51986. * @hidden
  51987. */
  51988. _enable(cameras: Nullable<Camera[]>): void;
  51989. /**
  51990. * Disables the effect on the given cameras
  51991. * @param cameras The camera to disable.
  51992. * @hidden
  51993. */
  51994. _disable(cameras: Camera): void;
  51995. /**
  51996. * Disables the effect on the given cameras
  51997. * @param cameras The camera to disable.
  51998. * @hidden
  51999. */
  52000. _disable(cameras: Nullable<Camera[]>): void;
  52001. /**
  52002. * Gets a list of the post processes contained in the effect.
  52003. * @param camera The camera to get the post processes on.
  52004. * @returns The list of the post processes in the effect.
  52005. */
  52006. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52007. }
  52008. }
  52009. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52010. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52011. /** @hidden */
  52012. export var extractHighlightsPixelShader: {
  52013. name: string;
  52014. shader: string;
  52015. };
  52016. }
  52017. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52018. import { Nullable } from "babylonjs/types";
  52019. import { Camera } from "babylonjs/Cameras/camera";
  52020. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52021. import { Engine } from "babylonjs/Engines/engine";
  52022. import "babylonjs/Shaders/extractHighlights.fragment";
  52023. /**
  52024. * 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.
  52025. */
  52026. export class ExtractHighlightsPostProcess extends PostProcess {
  52027. /**
  52028. * The luminance threshold, pixels below this value will be set to black.
  52029. */
  52030. threshold: number;
  52031. /** @hidden */
  52032. _exposure: number;
  52033. /**
  52034. * Post process which has the input texture to be used when performing highlight extraction
  52035. * @hidden
  52036. */
  52037. _inputPostProcess: Nullable<PostProcess>;
  52038. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52039. }
  52040. }
  52041. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52042. /** @hidden */
  52043. export var bloomMergePixelShader: {
  52044. name: string;
  52045. shader: string;
  52046. };
  52047. }
  52048. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52050. import { Nullable } from "babylonjs/types";
  52051. import { Engine } from "babylonjs/Engines/engine";
  52052. import { Camera } from "babylonjs/Cameras/camera";
  52053. import "babylonjs/Shaders/bloomMerge.fragment";
  52054. /**
  52055. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52056. */
  52057. export class BloomMergePostProcess extends PostProcess {
  52058. /** Weight of the bloom to be added to the original input. */
  52059. weight: number;
  52060. /**
  52061. * Creates a new instance of @see BloomMergePostProcess
  52062. * @param name The name of the effect.
  52063. * @param originalFromInput Post process which's input will be used for the merge.
  52064. * @param blurred Blurred highlights post process which's output will be used.
  52065. * @param weight Weight of the bloom to be added to the original input.
  52066. * @param options The required width/height ratio to downsize to before computing the render pass.
  52067. * @param camera The camera to apply the render pass to.
  52068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52069. * @param engine The engine which the post process will be applied. (default: current engine)
  52070. * @param reusable If the post process can be reused on the same frame. (default: false)
  52071. * @param textureType Type of textures used when performing the post process. (default: 0)
  52072. * @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)
  52073. */
  52074. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52075. /** Weight of the bloom to be added to the original input. */
  52076. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52077. }
  52078. }
  52079. declare module "babylonjs/PostProcesses/bloomEffect" {
  52080. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52082. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52083. import { Camera } from "babylonjs/Cameras/camera";
  52084. import { Scene } from "babylonjs/scene";
  52085. /**
  52086. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52087. */
  52088. export class BloomEffect extends PostProcessRenderEffect {
  52089. private bloomScale;
  52090. /**
  52091. * @hidden Internal
  52092. */
  52093. _effects: Array<PostProcess>;
  52094. /**
  52095. * @hidden Internal
  52096. */
  52097. _downscale: ExtractHighlightsPostProcess;
  52098. private _blurX;
  52099. private _blurY;
  52100. private _merge;
  52101. /**
  52102. * The luminance threshold to find bright areas of the image to bloom.
  52103. */
  52104. threshold: number;
  52105. /**
  52106. * The strength of the bloom.
  52107. */
  52108. weight: number;
  52109. /**
  52110. * Specifies the size of the bloom blur kernel, relative to the final output size
  52111. */
  52112. kernel: number;
  52113. /**
  52114. * Creates a new instance of @see BloomEffect
  52115. * @param scene The scene the effect belongs to.
  52116. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52117. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52118. * @param bloomWeight The the strength of bloom.
  52119. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52120. * @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)
  52121. */
  52122. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52123. /**
  52124. * Disposes each of the internal effects for a given camera.
  52125. * @param camera The camera to dispose the effect on.
  52126. */
  52127. disposeEffects(camera: Camera): void;
  52128. /**
  52129. * @hidden Internal
  52130. */
  52131. _updateEffects(): void;
  52132. /**
  52133. * Internal
  52134. * @returns if all the contained post processes are ready.
  52135. * @hidden
  52136. */
  52137. _isReady(): boolean;
  52138. }
  52139. }
  52140. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52141. /** @hidden */
  52142. export var chromaticAberrationPixelShader: {
  52143. name: string;
  52144. shader: string;
  52145. };
  52146. }
  52147. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52148. import { Vector2 } from "babylonjs/Maths/math";
  52149. import { Nullable } from "babylonjs/types";
  52150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52151. import { Camera } from "babylonjs/Cameras/camera";
  52152. import { Engine } from "babylonjs/Engines/engine";
  52153. import "babylonjs/Shaders/chromaticAberration.fragment";
  52154. /**
  52155. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52156. */
  52157. export class ChromaticAberrationPostProcess extends PostProcess {
  52158. /**
  52159. * The amount of seperation of rgb channels (default: 30)
  52160. */
  52161. aberrationAmount: number;
  52162. /**
  52163. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52164. */
  52165. radialIntensity: number;
  52166. /**
  52167. * 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))
  52168. */
  52169. direction: Vector2;
  52170. /**
  52171. * 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))
  52172. */
  52173. centerPosition: Vector2;
  52174. /**
  52175. * Creates a new instance ChromaticAberrationPostProcess
  52176. * @param name The name of the effect.
  52177. * @param screenWidth The width of the screen to apply the effect on.
  52178. * @param screenHeight The height of the screen to apply the effect on.
  52179. * @param options The required width/height ratio to downsize to before computing the render pass.
  52180. * @param camera The camera to apply the render pass to.
  52181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52182. * @param engine The engine which the post process will be applied. (default: current engine)
  52183. * @param reusable If the post process can be reused on the same frame. (default: false)
  52184. * @param textureType Type of textures used when performing the post process. (default: 0)
  52185. * @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)
  52186. */
  52187. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52188. }
  52189. }
  52190. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52191. /** @hidden */
  52192. export var circleOfConfusionPixelShader: {
  52193. name: string;
  52194. shader: string;
  52195. };
  52196. }
  52197. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52198. import { Nullable } from "babylonjs/types";
  52199. import { Engine } from "babylonjs/Engines/engine";
  52200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52201. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52202. import { Camera } from "babylonjs/Cameras/camera";
  52203. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52204. /**
  52205. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52206. */
  52207. export class CircleOfConfusionPostProcess extends PostProcess {
  52208. /**
  52209. * 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.
  52210. */
  52211. lensSize: number;
  52212. /**
  52213. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52214. */
  52215. fStop: number;
  52216. /**
  52217. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52218. */
  52219. focusDistance: number;
  52220. /**
  52221. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52222. */
  52223. focalLength: number;
  52224. private _depthTexture;
  52225. /**
  52226. * Creates a new instance CircleOfConfusionPostProcess
  52227. * @param name The name of the effect.
  52228. * @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.
  52229. * @param options The required width/height ratio to downsize to before computing the render pass.
  52230. * @param camera The camera to apply the render pass to.
  52231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52232. * @param engine The engine which the post process will be applied. (default: current engine)
  52233. * @param reusable If the post process can be reused on the same frame. (default: false)
  52234. * @param textureType Type of textures used when performing the post process. (default: 0)
  52235. * @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)
  52236. */
  52237. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52238. /**
  52239. * 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.
  52240. */
  52241. depthTexture: RenderTargetTexture;
  52242. }
  52243. }
  52244. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52245. /** @hidden */
  52246. export var colorCorrectionPixelShader: {
  52247. name: string;
  52248. shader: string;
  52249. };
  52250. }
  52251. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52253. import { Engine } from "babylonjs/Engines/engine";
  52254. import { Camera } from "babylonjs/Cameras/camera";
  52255. import "babylonjs/Shaders/colorCorrection.fragment";
  52256. /**
  52257. *
  52258. * This post-process allows the modification of rendered colors by using
  52259. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52260. *
  52261. * The object needs to be provided an url to a texture containing the color
  52262. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52263. * Use an image editing software to tweak the LUT to match your needs.
  52264. *
  52265. * For an example of a color LUT, see here:
  52266. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52267. * For explanations on color grading, see here:
  52268. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52269. *
  52270. */
  52271. export class ColorCorrectionPostProcess extends PostProcess {
  52272. private _colorTableTexture;
  52273. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52274. }
  52275. }
  52276. declare module "babylonjs/Shaders/convolution.fragment" {
  52277. /** @hidden */
  52278. export var convolutionPixelShader: {
  52279. name: string;
  52280. shader: string;
  52281. };
  52282. }
  52283. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52285. import { Nullable } from "babylonjs/types";
  52286. import { Camera } from "babylonjs/Cameras/camera";
  52287. import { Engine } from "babylonjs/Engines/engine";
  52288. import "babylonjs/Shaders/convolution.fragment";
  52289. /**
  52290. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52291. * input texture to perform effects such as edge detection or sharpening
  52292. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52293. */
  52294. export class ConvolutionPostProcess extends PostProcess {
  52295. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52296. kernel: number[];
  52297. /**
  52298. * Creates a new instance ConvolutionPostProcess
  52299. * @param name The name of the effect.
  52300. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52301. * @param options The required width/height ratio to downsize to before computing the render pass.
  52302. * @param camera The camera to apply the render pass to.
  52303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52304. * @param engine The engine which the post process will be applied. (default: current engine)
  52305. * @param reusable If the post process can be reused on the same frame. (default: false)
  52306. * @param textureType Type of textures used when performing the post process. (default: 0)
  52307. */
  52308. constructor(name: string,
  52309. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52310. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52311. /**
  52312. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52313. */
  52314. static EdgeDetect0Kernel: number[];
  52315. /**
  52316. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52317. */
  52318. static EdgeDetect1Kernel: number[];
  52319. /**
  52320. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52321. */
  52322. static EdgeDetect2Kernel: number[];
  52323. /**
  52324. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52325. */
  52326. static SharpenKernel: number[];
  52327. /**
  52328. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52329. */
  52330. static EmbossKernel: number[];
  52331. /**
  52332. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52333. */
  52334. static GaussianKernel: number[];
  52335. }
  52336. }
  52337. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52338. import { Nullable } from "babylonjs/types";
  52339. import { Vector2 } from "babylonjs/Maths/math";
  52340. import { Camera } from "babylonjs/Cameras/camera";
  52341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52342. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52343. import { Engine } from "babylonjs/Engines/engine";
  52344. import { Scene } from "babylonjs/scene";
  52345. /**
  52346. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52347. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52348. * based on samples that have a large difference in distance than the center pixel.
  52349. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52350. */
  52351. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52352. direction: Vector2;
  52353. /**
  52354. * Creates a new instance CircleOfConfusionPostProcess
  52355. * @param name The name of the effect.
  52356. * @param scene The scene the effect belongs to.
  52357. * @param direction The direction the blur should be applied.
  52358. * @param kernel The size of the kernel used to blur.
  52359. * @param options The required width/height ratio to downsize to before computing the render pass.
  52360. * @param camera The camera to apply the render pass to.
  52361. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52362. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52364. * @param engine The engine which the post process will be applied. (default: current engine)
  52365. * @param reusable If the post process can be reused on the same frame. (default: false)
  52366. * @param textureType Type of textures used when performing the post process. (default: 0)
  52367. * @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)
  52368. */
  52369. 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);
  52370. }
  52371. }
  52372. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52373. /** @hidden */
  52374. export var depthOfFieldMergePixelShader: {
  52375. name: string;
  52376. shader: string;
  52377. };
  52378. }
  52379. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52380. import { Nullable } from "babylonjs/types";
  52381. import { Camera } from "babylonjs/Cameras/camera";
  52382. import { Effect } from "babylonjs/Materials/effect";
  52383. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52384. import { Engine } from "babylonjs/Engines/engine";
  52385. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52386. /**
  52387. * Options to be set when merging outputs from the default pipeline.
  52388. */
  52389. export class DepthOfFieldMergePostProcessOptions {
  52390. /**
  52391. * The original image to merge on top of
  52392. */
  52393. originalFromInput: PostProcess;
  52394. /**
  52395. * Parameters to perform the merge of the depth of field effect
  52396. */
  52397. depthOfField?: {
  52398. circleOfConfusion: PostProcess;
  52399. blurSteps: Array<PostProcess>;
  52400. };
  52401. /**
  52402. * Parameters to perform the merge of bloom effect
  52403. */
  52404. bloom?: {
  52405. blurred: PostProcess;
  52406. weight: number;
  52407. };
  52408. }
  52409. /**
  52410. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52411. */
  52412. export class DepthOfFieldMergePostProcess extends PostProcess {
  52413. private blurSteps;
  52414. /**
  52415. * Creates a new instance of DepthOfFieldMergePostProcess
  52416. * @param name The name of the effect.
  52417. * @param originalFromInput Post process which's input will be used for the merge.
  52418. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52419. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52420. * @param options The required width/height ratio to downsize to before computing the render pass.
  52421. * @param camera The camera to apply the render pass to.
  52422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52423. * @param engine The engine which the post process will be applied. (default: current engine)
  52424. * @param reusable If the post process can be reused on the same frame. (default: false)
  52425. * @param textureType Type of textures used when performing the post process. (default: 0)
  52426. * @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)
  52427. */
  52428. 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);
  52429. /**
  52430. * Updates the effect with the current post process compile time values and recompiles the shader.
  52431. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52432. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52433. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52434. * @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
  52435. * @param onCompiled Called when the shader has been compiled.
  52436. * @param onError Called if there is an error when compiling a shader.
  52437. */
  52438. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52439. }
  52440. }
  52441. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52442. import { Nullable } from "babylonjs/types";
  52443. import { Camera } from "babylonjs/Cameras/camera";
  52444. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52445. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52446. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52447. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52448. import { Scene } from "babylonjs/scene";
  52449. /**
  52450. * Specifies the level of max blur that should be applied when using the depth of field effect
  52451. */
  52452. export enum DepthOfFieldEffectBlurLevel {
  52453. /**
  52454. * Subtle blur
  52455. */
  52456. Low = 0,
  52457. /**
  52458. * Medium blur
  52459. */
  52460. Medium = 1,
  52461. /**
  52462. * Large blur
  52463. */
  52464. High = 2
  52465. }
  52466. /**
  52467. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52468. */
  52469. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52470. private _circleOfConfusion;
  52471. /**
  52472. * @hidden Internal, blurs from high to low
  52473. */
  52474. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52475. private _depthOfFieldBlurY;
  52476. private _dofMerge;
  52477. /**
  52478. * @hidden Internal post processes in depth of field effect
  52479. */
  52480. _effects: Array<PostProcess>;
  52481. /**
  52482. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52483. */
  52484. focalLength: number;
  52485. /**
  52486. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52487. */
  52488. fStop: number;
  52489. /**
  52490. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52491. */
  52492. focusDistance: number;
  52493. /**
  52494. * 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.
  52495. */
  52496. lensSize: number;
  52497. /**
  52498. * Creates a new instance DepthOfFieldEffect
  52499. * @param scene The scene the effect belongs to.
  52500. * @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.
  52501. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52502. * @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)
  52503. */
  52504. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52505. /**
  52506. * 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.
  52507. */
  52508. depthTexture: RenderTargetTexture;
  52509. /**
  52510. * Disposes each of the internal effects for a given camera.
  52511. * @param camera The camera to dispose the effect on.
  52512. */
  52513. disposeEffects(camera: Camera): void;
  52514. /**
  52515. * @hidden Internal
  52516. */
  52517. _updateEffects(): void;
  52518. /**
  52519. * Internal
  52520. * @returns if all the contained post processes are ready.
  52521. * @hidden
  52522. */
  52523. _isReady(): boolean;
  52524. }
  52525. }
  52526. declare module "babylonjs/Shaders/displayPass.fragment" {
  52527. /** @hidden */
  52528. export var displayPassPixelShader: {
  52529. name: string;
  52530. shader: string;
  52531. };
  52532. }
  52533. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52534. import { Nullable } from "babylonjs/types";
  52535. import { Camera } from "babylonjs/Cameras/camera";
  52536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52537. import { Engine } from "babylonjs/Engines/engine";
  52538. import "babylonjs/Shaders/displayPass.fragment";
  52539. /**
  52540. * DisplayPassPostProcess which produces an output the same as it's input
  52541. */
  52542. export class DisplayPassPostProcess extends PostProcess {
  52543. /**
  52544. * Creates the DisplayPassPostProcess
  52545. * @param name The name of the effect.
  52546. * @param options The required width/height ratio to downsize to before computing the render pass.
  52547. * @param camera The camera to apply the render pass to.
  52548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52549. * @param engine The engine which the post process will be applied. (default: current engine)
  52550. * @param reusable If the post process can be reused on the same frame. (default: false)
  52551. */
  52552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52553. }
  52554. }
  52555. declare module "babylonjs/Shaders/filter.fragment" {
  52556. /** @hidden */
  52557. export var filterPixelShader: {
  52558. name: string;
  52559. shader: string;
  52560. };
  52561. }
  52562. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52563. import { Nullable } from "babylonjs/types";
  52564. import { Matrix } from "babylonjs/Maths/math";
  52565. import { Camera } from "babylonjs/Cameras/camera";
  52566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52567. import { Engine } from "babylonjs/Engines/engine";
  52568. import "babylonjs/Shaders/filter.fragment";
  52569. /**
  52570. * Applies a kernel filter to the image
  52571. */
  52572. export class FilterPostProcess extends PostProcess {
  52573. /** The matrix to be applied to the image */
  52574. kernelMatrix: Matrix;
  52575. /**
  52576. *
  52577. * @param name The name of the effect.
  52578. * @param kernelMatrix The matrix to be applied to the image
  52579. * @param options The required width/height ratio to downsize to before computing the render pass.
  52580. * @param camera The camera to apply the render pass to.
  52581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52582. * @param engine The engine which the post process will be applied. (default: current engine)
  52583. * @param reusable If the post process can be reused on the same frame. (default: false)
  52584. */
  52585. constructor(name: string,
  52586. /** The matrix to be applied to the image */
  52587. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52588. }
  52589. }
  52590. declare module "babylonjs/Shaders/fxaa.fragment" {
  52591. /** @hidden */
  52592. export var fxaaPixelShader: {
  52593. name: string;
  52594. shader: string;
  52595. };
  52596. }
  52597. declare module "babylonjs/Shaders/fxaa.vertex" {
  52598. /** @hidden */
  52599. export var fxaaVertexShader: {
  52600. name: string;
  52601. shader: string;
  52602. };
  52603. }
  52604. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52605. import { Nullable } from "babylonjs/types";
  52606. import { Camera } from "babylonjs/Cameras/camera";
  52607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52608. import { Engine } from "babylonjs/Engines/engine";
  52609. import "babylonjs/Shaders/fxaa.fragment";
  52610. import "babylonjs/Shaders/fxaa.vertex";
  52611. /**
  52612. * Fxaa post process
  52613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52614. */
  52615. export class FxaaPostProcess extends PostProcess {
  52616. /** @hidden */
  52617. texelWidth: number;
  52618. /** @hidden */
  52619. texelHeight: number;
  52620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52621. private _getDefines;
  52622. }
  52623. }
  52624. declare module "babylonjs/Shaders/grain.fragment" {
  52625. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52626. /** @hidden */
  52627. export var grainPixelShader: {
  52628. name: string;
  52629. shader: string;
  52630. };
  52631. }
  52632. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52633. import { Nullable } from "babylonjs/types";
  52634. import { Camera } from "babylonjs/Cameras/camera";
  52635. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52636. import { Engine } from "babylonjs/Engines/engine";
  52637. import "babylonjs/Shaders/grain.fragment";
  52638. /**
  52639. * The GrainPostProcess adds noise to the image at mid luminance levels
  52640. */
  52641. export class GrainPostProcess extends PostProcess {
  52642. /**
  52643. * The intensity of the grain added (default: 30)
  52644. */
  52645. intensity: number;
  52646. /**
  52647. * If the grain should be randomized on every frame
  52648. */
  52649. animated: boolean;
  52650. /**
  52651. * Creates a new instance of @see GrainPostProcess
  52652. * @param name The name of the effect.
  52653. * @param options The required width/height ratio to downsize to before computing the render pass.
  52654. * @param camera The camera to apply the render pass to.
  52655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52656. * @param engine The engine which the post process will be applied. (default: current engine)
  52657. * @param reusable If the post process can be reused on the same frame. (default: false)
  52658. * @param textureType Type of textures used when performing the post process. (default: 0)
  52659. * @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)
  52660. */
  52661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52662. }
  52663. }
  52664. declare module "babylonjs/Shaders/highlights.fragment" {
  52665. /** @hidden */
  52666. export var highlightsPixelShader: {
  52667. name: string;
  52668. shader: string;
  52669. };
  52670. }
  52671. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52672. import { Nullable } from "babylonjs/types";
  52673. import { Camera } from "babylonjs/Cameras/camera";
  52674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52675. import { Engine } from "babylonjs/Engines/engine";
  52676. import "babylonjs/Shaders/highlights.fragment";
  52677. /**
  52678. * Extracts highlights from the image
  52679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52680. */
  52681. export class HighlightsPostProcess extends PostProcess {
  52682. /**
  52683. * Extracts highlights from the image
  52684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52685. * @param name The name of the effect.
  52686. * @param options The required width/height ratio to downsize to before computing the render pass.
  52687. * @param camera The camera to apply the render pass to.
  52688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52689. * @param engine The engine which the post process will be applied. (default: current engine)
  52690. * @param reusable If the post process can be reused on the same frame. (default: false)
  52691. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52692. */
  52693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52694. }
  52695. }
  52696. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52697. /** @hidden */
  52698. export var mrtFragmentDeclaration: {
  52699. name: string;
  52700. shader: string;
  52701. };
  52702. }
  52703. declare module "babylonjs/Shaders/geometry.fragment" {
  52704. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52705. /** @hidden */
  52706. export var geometryPixelShader: {
  52707. name: string;
  52708. shader: string;
  52709. };
  52710. }
  52711. declare module "babylonjs/Shaders/geometry.vertex" {
  52712. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52713. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52714. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52715. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52716. /** @hidden */
  52717. export var geometryVertexShader: {
  52718. name: string;
  52719. shader: string;
  52720. };
  52721. }
  52722. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52723. import { Matrix } from "babylonjs/Maths/math";
  52724. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52725. import { Mesh } from "babylonjs/Meshes/mesh";
  52726. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52727. import { Effect } from "babylonjs/Materials/effect";
  52728. import { Scene } from "babylonjs/scene";
  52729. import "babylonjs/Shaders/geometry.fragment";
  52730. import "babylonjs/Shaders/geometry.vertex";
  52731. /**
  52732. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52733. */
  52734. export class GeometryBufferRenderer {
  52735. /**
  52736. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52737. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52738. */
  52739. static readonly POSITION_TEXTURE_TYPE: number;
  52740. /**
  52741. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52742. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52743. */
  52744. static readonly VELOCITY_TEXTURE_TYPE: number;
  52745. /**
  52746. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52747. * in order to compute objects velocities when enableVelocity is set to "true"
  52748. * @hidden
  52749. */
  52750. _previousTransformationMatrices: {
  52751. [index: number]: Matrix;
  52752. };
  52753. private _scene;
  52754. private _multiRenderTarget;
  52755. private _ratio;
  52756. private _enablePosition;
  52757. private _enableVelocity;
  52758. private _positionIndex;
  52759. private _velocityIndex;
  52760. protected _effect: Effect;
  52761. protected _cachedDefines: string;
  52762. /**
  52763. * Set the render list (meshes to be rendered) used in the G buffer.
  52764. */
  52765. renderList: Mesh[];
  52766. /**
  52767. * Gets wether or not G buffer are supported by the running hardware.
  52768. * This requires draw buffer supports
  52769. */
  52770. readonly isSupported: boolean;
  52771. /**
  52772. * Returns the index of the given texture type in the G-Buffer textures array
  52773. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52774. * @returns the index of the given texture type in the G-Buffer textures array
  52775. */
  52776. getTextureIndex(textureType: number): number;
  52777. /**
  52778. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52779. */
  52780. /**
  52781. * Sets whether or not objects positions are enabled for the G buffer.
  52782. */
  52783. enablePosition: boolean;
  52784. /**
  52785. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52786. */
  52787. /**
  52788. * Sets wether or not objects velocities are enabled for the G buffer.
  52789. */
  52790. enableVelocity: boolean;
  52791. /**
  52792. * Gets the scene associated with the buffer.
  52793. */
  52794. readonly scene: Scene;
  52795. /**
  52796. * Gets the ratio used by the buffer during its creation.
  52797. * How big is the buffer related to the main canvas.
  52798. */
  52799. readonly ratio: number;
  52800. /** @hidden */
  52801. static _SceneComponentInitialization: (scene: Scene) => void;
  52802. /**
  52803. * Creates a new G Buffer for the scene
  52804. * @param scene The scene the buffer belongs to
  52805. * @param ratio How big is the buffer related to the main canvas.
  52806. */
  52807. constructor(scene: Scene, ratio?: number);
  52808. /**
  52809. * Checks wether everything is ready to render a submesh to the G buffer.
  52810. * @param subMesh the submesh to check readiness for
  52811. * @param useInstances is the mesh drawn using instance or not
  52812. * @returns true if ready otherwise false
  52813. */
  52814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52815. /**
  52816. * Gets the current underlying G Buffer.
  52817. * @returns the buffer
  52818. */
  52819. getGBuffer(): MultiRenderTarget;
  52820. /**
  52821. * Gets the number of samples used to render the buffer (anti aliasing).
  52822. */
  52823. /**
  52824. * Sets the number of samples used to render the buffer (anti aliasing).
  52825. */
  52826. samples: number;
  52827. /**
  52828. * Disposes the renderer and frees up associated resources.
  52829. */
  52830. dispose(): void;
  52831. protected _createRenderTargets(): void;
  52832. }
  52833. }
  52834. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52835. /** @hidden */
  52836. export var motionBlurPixelShader: {
  52837. name: string;
  52838. shader: string;
  52839. };
  52840. }
  52841. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52842. import { Nullable } from "babylonjs/types";
  52843. import { Camera } from "babylonjs/Cameras/camera";
  52844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52845. import { Scene } from "babylonjs/scene";
  52846. import "babylonjs/Shaders/motionBlur.fragment";
  52847. import { Engine } from "babylonjs/Engines/engine";
  52848. /**
  52849. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52850. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52851. * As an example, all you have to do is to create the post-process:
  52852. * var mb = new BABYLON.MotionBlurPostProcess(
  52853. * 'mb', // The name of the effect.
  52854. * scene, // The scene containing the objects to blur according to their velocity.
  52855. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52856. * camera // The camera to apply the render pass to.
  52857. * );
  52858. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52859. */
  52860. export class MotionBlurPostProcess extends PostProcess {
  52861. /**
  52862. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52863. */
  52864. motionStrength: number;
  52865. /**
  52866. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52867. */
  52868. /**
  52869. * Sets the number of iterations to be used for motion blur quality
  52870. */
  52871. motionBlurSamples: number;
  52872. private _motionBlurSamples;
  52873. private _geometryBufferRenderer;
  52874. /**
  52875. * Creates a new instance MotionBlurPostProcess
  52876. * @param name The name of the effect.
  52877. * @param scene The scene containing the objects to blur according to their velocity.
  52878. * @param options The required width/height ratio to downsize to before computing the render pass.
  52879. * @param camera The camera to apply the render pass to.
  52880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52881. * @param engine The engine which the post process will be applied. (default: current engine)
  52882. * @param reusable If the post process can be reused on the same frame. (default: false)
  52883. * @param textureType Type of textures used when performing the post process. (default: 0)
  52884. * @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)
  52885. */
  52886. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52887. /**
  52888. * Disposes the post process.
  52889. * @param camera The camera to dispose the post process on.
  52890. */
  52891. dispose(camera?: Camera): void;
  52892. }
  52893. }
  52894. declare module "babylonjs/Shaders/refraction.fragment" {
  52895. /** @hidden */
  52896. export var refractionPixelShader: {
  52897. name: string;
  52898. shader: string;
  52899. };
  52900. }
  52901. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52902. import { Color3 } from "babylonjs/Maths/math";
  52903. import { Camera } from "babylonjs/Cameras/camera";
  52904. import { Texture } from "babylonjs/Materials/Textures/texture";
  52905. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52906. import { Engine } from "babylonjs/Engines/engine";
  52907. import "babylonjs/Shaders/refraction.fragment";
  52908. /**
  52909. * Post process which applies a refractin texture
  52910. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52911. */
  52912. export class RefractionPostProcess extends PostProcess {
  52913. /** the base color of the refraction (used to taint the rendering) */
  52914. color: Color3;
  52915. /** simulated refraction depth */
  52916. depth: number;
  52917. /** the coefficient of the base color (0 to remove base color tainting) */
  52918. colorLevel: number;
  52919. private _refTexture;
  52920. private _ownRefractionTexture;
  52921. /**
  52922. * Gets or sets the refraction texture
  52923. * Please note that you are responsible for disposing the texture if you set it manually
  52924. */
  52925. refractionTexture: Texture;
  52926. /**
  52927. * Initializes the RefractionPostProcess
  52928. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52929. * @param name The name of the effect.
  52930. * @param refractionTextureUrl Url of the refraction texture to use
  52931. * @param color the base color of the refraction (used to taint the rendering)
  52932. * @param depth simulated refraction depth
  52933. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52934. * @param camera The camera to apply the render pass to.
  52935. * @param options The required width/height ratio to downsize to before computing the render pass.
  52936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52937. * @param engine The engine which the post process will be applied. (default: current engine)
  52938. * @param reusable If the post process can be reused on the same frame. (default: false)
  52939. */
  52940. constructor(name: string, refractionTextureUrl: string,
  52941. /** the base color of the refraction (used to taint the rendering) */
  52942. color: Color3,
  52943. /** simulated refraction depth */
  52944. depth: number,
  52945. /** the coefficient of the base color (0 to remove base color tainting) */
  52946. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52947. /**
  52948. * Disposes of the post process
  52949. * @param camera Camera to dispose post process on
  52950. */
  52951. dispose(camera: Camera): void;
  52952. }
  52953. }
  52954. declare module "babylonjs/Shaders/sharpen.fragment" {
  52955. /** @hidden */
  52956. export var sharpenPixelShader: {
  52957. name: string;
  52958. shader: string;
  52959. };
  52960. }
  52961. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52962. import { Nullable } from "babylonjs/types";
  52963. import { Camera } from "babylonjs/Cameras/camera";
  52964. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52965. import "babylonjs/Shaders/sharpen.fragment";
  52966. import { Engine } from "babylonjs/Engines/engine";
  52967. /**
  52968. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52969. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52970. */
  52971. export class SharpenPostProcess extends PostProcess {
  52972. /**
  52973. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52974. */
  52975. colorAmount: number;
  52976. /**
  52977. * How much sharpness should be applied (default: 0.3)
  52978. */
  52979. edgeAmount: number;
  52980. /**
  52981. * Creates a new instance ConvolutionPostProcess
  52982. * @param name The name of the effect.
  52983. * @param options The required width/height ratio to downsize to before computing the render pass.
  52984. * @param camera The camera to apply the render pass to.
  52985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52986. * @param engine The engine which the post process will be applied. (default: current engine)
  52987. * @param reusable If the post process can be reused on the same frame. (default: false)
  52988. * @param textureType Type of textures used when performing the post process. (default: 0)
  52989. * @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)
  52990. */
  52991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52992. }
  52993. }
  52994. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52995. import { Nullable } from "babylonjs/types";
  52996. import { Camera } from "babylonjs/Cameras/camera";
  52997. import { Engine } from "babylonjs/Engines/engine";
  52998. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52999. /**
  53000. * PostProcessRenderPipeline
  53001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53002. */
  53003. export class PostProcessRenderPipeline {
  53004. private engine;
  53005. private _renderEffects;
  53006. private _renderEffectsForIsolatedPass;
  53007. /**
  53008. * @hidden
  53009. */
  53010. protected _cameras: Camera[];
  53011. /** @hidden */
  53012. _name: string;
  53013. /**
  53014. * Gets pipeline name
  53015. */
  53016. readonly name: string;
  53017. /**
  53018. * Initializes a PostProcessRenderPipeline
  53019. * @param engine engine to add the pipeline to
  53020. * @param name name of the pipeline
  53021. */
  53022. constructor(engine: Engine, name: string);
  53023. /**
  53024. * Gets the class name
  53025. * @returns "PostProcessRenderPipeline"
  53026. */
  53027. getClassName(): string;
  53028. /**
  53029. * If all the render effects in the pipeline are supported
  53030. */
  53031. readonly isSupported: boolean;
  53032. /**
  53033. * Adds an effect to the pipeline
  53034. * @param renderEffect the effect to add
  53035. */
  53036. addEffect(renderEffect: PostProcessRenderEffect): void;
  53037. /** @hidden */
  53038. _rebuild(): void;
  53039. /** @hidden */
  53040. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53041. /** @hidden */
  53042. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53043. /** @hidden */
  53044. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53045. /** @hidden */
  53046. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53047. /** @hidden */
  53048. _attachCameras(cameras: Camera, unique: boolean): void;
  53049. /** @hidden */
  53050. _attachCameras(cameras: Camera[], unique: boolean): void;
  53051. /** @hidden */
  53052. _detachCameras(cameras: Camera): void;
  53053. /** @hidden */
  53054. _detachCameras(cameras: Nullable<Camera[]>): void;
  53055. /** @hidden */
  53056. _update(): void;
  53057. /** @hidden */
  53058. _reset(): void;
  53059. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53060. /**
  53061. * Disposes of the pipeline
  53062. */
  53063. dispose(): void;
  53064. }
  53065. }
  53066. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53067. import { IAnimatable } from "babylonjs/Misc/tools";
  53068. import { Camera } from "babylonjs/Cameras/camera";
  53069. import { IDisposable } from "babylonjs/scene";
  53070. import { Scene } from "babylonjs/scene";
  53071. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53072. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53073. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53074. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53075. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53076. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53077. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53078. import { Animation } from "babylonjs/Animations/animation";
  53079. /**
  53080. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53081. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53082. */
  53083. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53084. private _scene;
  53085. private _camerasToBeAttached;
  53086. /**
  53087. * ID of the sharpen post process,
  53088. */
  53089. private readonly SharpenPostProcessId;
  53090. /**
  53091. * @ignore
  53092. * ID of the image processing post process;
  53093. */
  53094. readonly ImageProcessingPostProcessId: string;
  53095. /**
  53096. * @ignore
  53097. * ID of the Fast Approximate Anti-Aliasing post process;
  53098. */
  53099. readonly FxaaPostProcessId: string;
  53100. /**
  53101. * ID of the chromatic aberration post process,
  53102. */
  53103. private readonly ChromaticAberrationPostProcessId;
  53104. /**
  53105. * ID of the grain post process
  53106. */
  53107. private readonly GrainPostProcessId;
  53108. /**
  53109. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53110. */
  53111. sharpen: SharpenPostProcess;
  53112. private _sharpenEffect;
  53113. private bloom;
  53114. /**
  53115. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53116. */
  53117. depthOfField: DepthOfFieldEffect;
  53118. /**
  53119. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53120. */
  53121. fxaa: FxaaPostProcess;
  53122. /**
  53123. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53124. */
  53125. imageProcessing: ImageProcessingPostProcess;
  53126. /**
  53127. * Chromatic aberration post process which will shift rgb colors in the image
  53128. */
  53129. chromaticAberration: ChromaticAberrationPostProcess;
  53130. private _chromaticAberrationEffect;
  53131. /**
  53132. * Grain post process which add noise to the image
  53133. */
  53134. grain: GrainPostProcess;
  53135. private _grainEffect;
  53136. /**
  53137. * Glow post process which adds a glow to emissive areas of the image
  53138. */
  53139. private _glowLayer;
  53140. /**
  53141. * Animations which can be used to tweak settings over a period of time
  53142. */
  53143. animations: Animation[];
  53144. private _imageProcessingConfigurationObserver;
  53145. private _sharpenEnabled;
  53146. private _bloomEnabled;
  53147. private _depthOfFieldEnabled;
  53148. private _depthOfFieldBlurLevel;
  53149. private _fxaaEnabled;
  53150. private _imageProcessingEnabled;
  53151. private _defaultPipelineTextureType;
  53152. private _bloomScale;
  53153. private _chromaticAberrationEnabled;
  53154. private _grainEnabled;
  53155. private _buildAllowed;
  53156. /**
  53157. * Gets active scene
  53158. */
  53159. readonly scene: Scene;
  53160. /**
  53161. * Enable or disable the sharpen process from the pipeline
  53162. */
  53163. sharpenEnabled: boolean;
  53164. private _resizeObserver;
  53165. private _hardwareScaleLevel;
  53166. private _bloomKernel;
  53167. /**
  53168. * Specifies the size of the bloom blur kernel, relative to the final output size
  53169. */
  53170. bloomKernel: number;
  53171. /**
  53172. * Specifies the weight of the bloom in the final rendering
  53173. */
  53174. private _bloomWeight;
  53175. /**
  53176. * Specifies the luma threshold for the area that will be blurred by the bloom
  53177. */
  53178. private _bloomThreshold;
  53179. private _hdr;
  53180. /**
  53181. * The strength of the bloom.
  53182. */
  53183. bloomWeight: number;
  53184. /**
  53185. * The strength of the bloom.
  53186. */
  53187. bloomThreshold: number;
  53188. /**
  53189. * The scale of the bloom, lower value will provide better performance.
  53190. */
  53191. bloomScale: number;
  53192. /**
  53193. * Enable or disable the bloom from the pipeline
  53194. */
  53195. bloomEnabled: boolean;
  53196. private _rebuildBloom;
  53197. /**
  53198. * If the depth of field is enabled.
  53199. */
  53200. depthOfFieldEnabled: boolean;
  53201. /**
  53202. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53203. */
  53204. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53205. /**
  53206. * If the anti aliasing is enabled.
  53207. */
  53208. fxaaEnabled: boolean;
  53209. private _samples;
  53210. /**
  53211. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53212. */
  53213. samples: number;
  53214. /**
  53215. * If image processing is enabled.
  53216. */
  53217. imageProcessingEnabled: boolean;
  53218. /**
  53219. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53220. */
  53221. glowLayerEnabled: boolean;
  53222. /**
  53223. * Enable or disable the chromaticAberration process from the pipeline
  53224. */
  53225. chromaticAberrationEnabled: boolean;
  53226. /**
  53227. * Enable or disable the grain process from the pipeline
  53228. */
  53229. grainEnabled: boolean;
  53230. /**
  53231. * @constructor
  53232. * @param name - The rendering pipeline name (default: "")
  53233. * @param hdr - If high dynamic range textures should be used (default: true)
  53234. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53235. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53236. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53237. */
  53238. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53239. /**
  53240. * Get the class name
  53241. * @returns "DefaultRenderingPipeline"
  53242. */
  53243. getClassName(): string;
  53244. /**
  53245. * Force the compilation of the entire pipeline.
  53246. */
  53247. prepare(): void;
  53248. private _hasCleared;
  53249. private _prevPostProcess;
  53250. private _prevPrevPostProcess;
  53251. private _setAutoClearAndTextureSharing;
  53252. private _depthOfFieldSceneObserver;
  53253. private _buildPipeline;
  53254. private _disposePostProcesses;
  53255. /**
  53256. * Adds a camera to the pipeline
  53257. * @param camera the camera to be added
  53258. */
  53259. addCamera(camera: Camera): void;
  53260. /**
  53261. * Removes a camera from the pipeline
  53262. * @param camera the camera to remove
  53263. */
  53264. removeCamera(camera: Camera): void;
  53265. /**
  53266. * Dispose of the pipeline and stop all post processes
  53267. */
  53268. dispose(): void;
  53269. /**
  53270. * Serialize the rendering pipeline (Used when exporting)
  53271. * @returns the serialized object
  53272. */
  53273. serialize(): any;
  53274. /**
  53275. * Parse the serialized pipeline
  53276. * @param source Source pipeline.
  53277. * @param scene The scene to load the pipeline to.
  53278. * @param rootUrl The URL of the serialized pipeline.
  53279. * @returns An instantiated pipeline from the serialized object.
  53280. */
  53281. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53282. }
  53283. }
  53284. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53285. /** @hidden */
  53286. export var lensHighlightsPixelShader: {
  53287. name: string;
  53288. shader: string;
  53289. };
  53290. }
  53291. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53292. /** @hidden */
  53293. export var depthOfFieldPixelShader: {
  53294. name: string;
  53295. shader: string;
  53296. };
  53297. }
  53298. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53299. import { Camera } from "babylonjs/Cameras/camera";
  53300. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53301. import { Scene } from "babylonjs/scene";
  53302. import "babylonjs/Shaders/chromaticAberration.fragment";
  53303. import "babylonjs/Shaders/lensHighlights.fragment";
  53304. import "babylonjs/Shaders/depthOfField.fragment";
  53305. /**
  53306. * BABYLON.JS Chromatic Aberration GLSL Shader
  53307. * Author: Olivier Guyot
  53308. * Separates very slightly R, G and B colors on the edges of the screen
  53309. * Inspired by Francois Tarlier & Martins Upitis
  53310. */
  53311. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53312. /**
  53313. * @ignore
  53314. * The chromatic aberration PostProcess id in the pipeline
  53315. */
  53316. LensChromaticAberrationEffect: string;
  53317. /**
  53318. * @ignore
  53319. * The highlights enhancing PostProcess id in the pipeline
  53320. */
  53321. HighlightsEnhancingEffect: string;
  53322. /**
  53323. * @ignore
  53324. * The depth-of-field PostProcess id in the pipeline
  53325. */
  53326. LensDepthOfFieldEffect: string;
  53327. private _scene;
  53328. private _depthTexture;
  53329. private _grainTexture;
  53330. private _chromaticAberrationPostProcess;
  53331. private _highlightsPostProcess;
  53332. private _depthOfFieldPostProcess;
  53333. private _edgeBlur;
  53334. private _grainAmount;
  53335. private _chromaticAberration;
  53336. private _distortion;
  53337. private _highlightsGain;
  53338. private _highlightsThreshold;
  53339. private _dofDistance;
  53340. private _dofAperture;
  53341. private _dofDarken;
  53342. private _dofPentagon;
  53343. private _blurNoise;
  53344. /**
  53345. * @constructor
  53346. *
  53347. * Effect parameters are as follow:
  53348. * {
  53349. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53350. * edge_blur: number; // from 0 to x (1 for realism)
  53351. * distortion: number; // from 0 to x (1 for realism)
  53352. * grain_amount: number; // from 0 to 1
  53353. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53354. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53355. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53356. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53357. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53358. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53359. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53360. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53361. * }
  53362. * Note: if an effect parameter is unset, effect is disabled
  53363. *
  53364. * @param name The rendering pipeline name
  53365. * @param parameters - An object containing all parameters (see above)
  53366. * @param scene The scene linked to this pipeline
  53367. * @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)
  53368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53369. */
  53370. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53371. /**
  53372. * Sets the amount of blur at the edges
  53373. * @param amount blur amount
  53374. */
  53375. setEdgeBlur(amount: number): void;
  53376. /**
  53377. * Sets edge blur to 0
  53378. */
  53379. disableEdgeBlur(): void;
  53380. /**
  53381. * Sets the amout of grain
  53382. * @param amount Amount of grain
  53383. */
  53384. setGrainAmount(amount: number): void;
  53385. /**
  53386. * Set grain amount to 0
  53387. */
  53388. disableGrain(): void;
  53389. /**
  53390. * Sets the chromatic aberration amount
  53391. * @param amount amount of chromatic aberration
  53392. */
  53393. setChromaticAberration(amount: number): void;
  53394. /**
  53395. * Sets chromatic aberration amount to 0
  53396. */
  53397. disableChromaticAberration(): void;
  53398. /**
  53399. * Sets the EdgeDistortion amount
  53400. * @param amount amount of EdgeDistortion
  53401. */
  53402. setEdgeDistortion(amount: number): void;
  53403. /**
  53404. * Sets edge distortion to 0
  53405. */
  53406. disableEdgeDistortion(): void;
  53407. /**
  53408. * Sets the FocusDistance amount
  53409. * @param amount amount of FocusDistance
  53410. */
  53411. setFocusDistance(amount: number): void;
  53412. /**
  53413. * Disables depth of field
  53414. */
  53415. disableDepthOfField(): void;
  53416. /**
  53417. * Sets the Aperture amount
  53418. * @param amount amount of Aperture
  53419. */
  53420. setAperture(amount: number): void;
  53421. /**
  53422. * Sets the DarkenOutOfFocus amount
  53423. * @param amount amount of DarkenOutOfFocus
  53424. */
  53425. setDarkenOutOfFocus(amount: number): void;
  53426. /**
  53427. * Creates a pentagon bokeh effect
  53428. */
  53429. enablePentagonBokeh(): void;
  53430. /**
  53431. * Disables the pentagon bokeh effect
  53432. */
  53433. disablePentagonBokeh(): void;
  53434. /**
  53435. * Enables noise blur
  53436. */
  53437. enableNoiseBlur(): void;
  53438. /**
  53439. * Disables noise blur
  53440. */
  53441. disableNoiseBlur(): void;
  53442. /**
  53443. * Sets the HighlightsGain amount
  53444. * @param amount amount of HighlightsGain
  53445. */
  53446. setHighlightsGain(amount: number): void;
  53447. /**
  53448. * Sets the HighlightsThreshold amount
  53449. * @param amount amount of HighlightsThreshold
  53450. */
  53451. setHighlightsThreshold(amount: number): void;
  53452. /**
  53453. * Disables highlights
  53454. */
  53455. disableHighlights(): void;
  53456. /**
  53457. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53458. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53459. */
  53460. dispose(disableDepthRender?: boolean): void;
  53461. private _createChromaticAberrationPostProcess;
  53462. private _createHighlightsPostProcess;
  53463. private _createDepthOfFieldPostProcess;
  53464. private _createGrainTexture;
  53465. }
  53466. }
  53467. declare module "babylonjs/Shaders/ssao2.fragment" {
  53468. /** @hidden */
  53469. export var ssao2PixelShader: {
  53470. name: string;
  53471. shader: string;
  53472. };
  53473. }
  53474. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53475. /** @hidden */
  53476. export var ssaoCombinePixelShader: {
  53477. name: string;
  53478. shader: string;
  53479. };
  53480. }
  53481. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53482. import { Camera } from "babylonjs/Cameras/camera";
  53483. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53484. import { Scene } from "babylonjs/scene";
  53485. import "babylonjs/Shaders/ssao2.fragment";
  53486. import "babylonjs/Shaders/ssaoCombine.fragment";
  53487. /**
  53488. * Render pipeline to produce ssao effect
  53489. */
  53490. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53491. /**
  53492. * @ignore
  53493. * The PassPostProcess id in the pipeline that contains the original scene color
  53494. */
  53495. SSAOOriginalSceneColorEffect: string;
  53496. /**
  53497. * @ignore
  53498. * The SSAO PostProcess id in the pipeline
  53499. */
  53500. SSAORenderEffect: string;
  53501. /**
  53502. * @ignore
  53503. * The horizontal blur PostProcess id in the pipeline
  53504. */
  53505. SSAOBlurHRenderEffect: string;
  53506. /**
  53507. * @ignore
  53508. * The vertical blur PostProcess id in the pipeline
  53509. */
  53510. SSAOBlurVRenderEffect: string;
  53511. /**
  53512. * @ignore
  53513. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53514. */
  53515. SSAOCombineRenderEffect: string;
  53516. /**
  53517. * The output strength of the SSAO post-process. Default value is 1.0.
  53518. */
  53519. totalStrength: number;
  53520. /**
  53521. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53522. */
  53523. maxZ: number;
  53524. /**
  53525. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53526. */
  53527. minZAspect: number;
  53528. private _samples;
  53529. /**
  53530. * Number of samples used for the SSAO calculations. Default value is 8
  53531. */
  53532. samples: number;
  53533. private _textureSamples;
  53534. /**
  53535. * Number of samples to use for antialiasing
  53536. */
  53537. textureSamples: number;
  53538. /**
  53539. * Ratio object used for SSAO ratio and blur ratio
  53540. */
  53541. private _ratio;
  53542. /**
  53543. * Dynamically generated sphere sampler.
  53544. */
  53545. private _sampleSphere;
  53546. /**
  53547. * Blur filter offsets
  53548. */
  53549. private _samplerOffsets;
  53550. private _expensiveBlur;
  53551. /**
  53552. * If bilateral blur should be used
  53553. */
  53554. expensiveBlur: boolean;
  53555. /**
  53556. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53557. */
  53558. radius: number;
  53559. /**
  53560. * The base color of the SSAO post-process
  53561. * The final result is "base + ssao" between [0, 1]
  53562. */
  53563. base: number;
  53564. /**
  53565. * Support test.
  53566. */
  53567. static readonly IsSupported: boolean;
  53568. private _scene;
  53569. private _depthTexture;
  53570. private _normalTexture;
  53571. private _randomTexture;
  53572. private _originalColorPostProcess;
  53573. private _ssaoPostProcess;
  53574. private _blurHPostProcess;
  53575. private _blurVPostProcess;
  53576. private _ssaoCombinePostProcess;
  53577. private _firstUpdate;
  53578. /**
  53579. * Gets active scene
  53580. */
  53581. readonly scene: Scene;
  53582. /**
  53583. * @constructor
  53584. * @param name The rendering pipeline name
  53585. * @param scene The scene linked to this pipeline
  53586. * @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 }
  53587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53588. */
  53589. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53590. /**
  53591. * Get the class name
  53592. * @returns "SSAO2RenderingPipeline"
  53593. */
  53594. getClassName(): string;
  53595. /**
  53596. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53597. */
  53598. dispose(disableGeometryBufferRenderer?: boolean): void;
  53599. private _createBlurPostProcess;
  53600. /** @hidden */
  53601. _rebuild(): void;
  53602. private _bits;
  53603. private _radicalInverse_VdC;
  53604. private _hammersley;
  53605. private _hemisphereSample_uniform;
  53606. private _generateHemisphere;
  53607. private _createSSAOPostProcess;
  53608. private _createSSAOCombinePostProcess;
  53609. private _createRandomTexture;
  53610. /**
  53611. * Serialize the rendering pipeline (Used when exporting)
  53612. * @returns the serialized object
  53613. */
  53614. serialize(): any;
  53615. /**
  53616. * Parse the serialized pipeline
  53617. * @param source Source pipeline.
  53618. * @param scene The scene to load the pipeline to.
  53619. * @param rootUrl The URL of the serialized pipeline.
  53620. * @returns An instantiated pipeline from the serialized object.
  53621. */
  53622. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53623. }
  53624. }
  53625. declare module "babylonjs/Shaders/ssao.fragment" {
  53626. /** @hidden */
  53627. export var ssaoPixelShader: {
  53628. name: string;
  53629. shader: string;
  53630. };
  53631. }
  53632. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53633. import { Camera } from "babylonjs/Cameras/camera";
  53634. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53635. import { Scene } from "babylonjs/scene";
  53636. import "babylonjs/Shaders/ssao.fragment";
  53637. import "babylonjs/Shaders/ssaoCombine.fragment";
  53638. /**
  53639. * Render pipeline to produce ssao effect
  53640. */
  53641. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53642. /**
  53643. * @ignore
  53644. * The PassPostProcess id in the pipeline that contains the original scene color
  53645. */
  53646. SSAOOriginalSceneColorEffect: string;
  53647. /**
  53648. * @ignore
  53649. * The SSAO PostProcess id in the pipeline
  53650. */
  53651. SSAORenderEffect: string;
  53652. /**
  53653. * @ignore
  53654. * The horizontal blur PostProcess id in the pipeline
  53655. */
  53656. SSAOBlurHRenderEffect: string;
  53657. /**
  53658. * @ignore
  53659. * The vertical blur PostProcess id in the pipeline
  53660. */
  53661. SSAOBlurVRenderEffect: string;
  53662. /**
  53663. * @ignore
  53664. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53665. */
  53666. SSAOCombineRenderEffect: string;
  53667. /**
  53668. * The output strength of the SSAO post-process. Default value is 1.0.
  53669. */
  53670. totalStrength: number;
  53671. /**
  53672. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53673. */
  53674. radius: number;
  53675. /**
  53676. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53677. * Must not be equal to fallOff and superior to fallOff.
  53678. * Default value is 0.0075
  53679. */
  53680. area: number;
  53681. /**
  53682. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53683. * Must not be equal to area and inferior to area.
  53684. * Default value is 0.000001
  53685. */
  53686. fallOff: number;
  53687. /**
  53688. * The base color of the SSAO post-process
  53689. * The final result is "base + ssao" between [0, 1]
  53690. */
  53691. base: number;
  53692. private _scene;
  53693. private _depthTexture;
  53694. private _randomTexture;
  53695. private _originalColorPostProcess;
  53696. private _ssaoPostProcess;
  53697. private _blurHPostProcess;
  53698. private _blurVPostProcess;
  53699. private _ssaoCombinePostProcess;
  53700. private _firstUpdate;
  53701. /**
  53702. * Gets active scene
  53703. */
  53704. readonly scene: Scene;
  53705. /**
  53706. * @constructor
  53707. * @param name - The rendering pipeline name
  53708. * @param scene - The scene linked to this pipeline
  53709. * @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 }
  53710. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53711. */
  53712. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53713. /**
  53714. * Get the class name
  53715. * @returns "SSAORenderingPipeline"
  53716. */
  53717. getClassName(): string;
  53718. /**
  53719. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53720. */
  53721. dispose(disableDepthRender?: boolean): void;
  53722. private _createBlurPostProcess;
  53723. /** @hidden */
  53724. _rebuild(): void;
  53725. private _createSSAOPostProcess;
  53726. private _createSSAOCombinePostProcess;
  53727. private _createRandomTexture;
  53728. }
  53729. }
  53730. declare module "babylonjs/Shaders/standard.fragment" {
  53731. /** @hidden */
  53732. export var standardPixelShader: {
  53733. name: string;
  53734. shader: string;
  53735. };
  53736. }
  53737. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53738. import { Nullable } from "babylonjs/types";
  53739. import { IAnimatable } from "babylonjs/Misc/tools";
  53740. import { Camera } from "babylonjs/Cameras/camera";
  53741. import { Texture } from "babylonjs/Materials/Textures/texture";
  53742. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53743. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53744. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53745. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53746. import { IDisposable } from "babylonjs/scene";
  53747. import { SpotLight } from "babylonjs/Lights/spotLight";
  53748. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53749. import { Scene } from "babylonjs/scene";
  53750. import { Animation } from "babylonjs/Animations/animation";
  53751. import "babylonjs/Shaders/standard.fragment";
  53752. /**
  53753. * Standard rendering pipeline
  53754. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53755. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53756. */
  53757. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53758. /**
  53759. * Public members
  53760. */
  53761. /**
  53762. * Post-process which contains the original scene color before the pipeline applies all the effects
  53763. */
  53764. originalPostProcess: Nullable<PostProcess>;
  53765. /**
  53766. * Post-process used to down scale an image x4
  53767. */
  53768. downSampleX4PostProcess: Nullable<PostProcess>;
  53769. /**
  53770. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53771. */
  53772. brightPassPostProcess: Nullable<PostProcess>;
  53773. /**
  53774. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53775. */
  53776. blurHPostProcesses: PostProcess[];
  53777. /**
  53778. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53779. */
  53780. blurVPostProcesses: PostProcess[];
  53781. /**
  53782. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53783. */
  53784. textureAdderPostProcess: Nullable<PostProcess>;
  53785. /**
  53786. * Post-process used to create volumetric lighting effect
  53787. */
  53788. volumetricLightPostProcess: Nullable<PostProcess>;
  53789. /**
  53790. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53791. */
  53792. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53793. /**
  53794. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53795. */
  53796. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53797. /**
  53798. * Post-process used to merge the volumetric light effect and the real scene color
  53799. */
  53800. volumetricLightMergePostProces: Nullable<PostProcess>;
  53801. /**
  53802. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53803. */
  53804. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53805. /**
  53806. * Base post-process used to calculate the average luminance of the final image for HDR
  53807. */
  53808. luminancePostProcess: Nullable<PostProcess>;
  53809. /**
  53810. * Post-processes used to create down sample post-processes in order to get
  53811. * the average luminance of the final image for HDR
  53812. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53813. */
  53814. luminanceDownSamplePostProcesses: PostProcess[];
  53815. /**
  53816. * Post-process used to create a HDR effect (light adaptation)
  53817. */
  53818. hdrPostProcess: Nullable<PostProcess>;
  53819. /**
  53820. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53821. */
  53822. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53823. /**
  53824. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53825. */
  53826. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53827. /**
  53828. * Post-process used to merge the final HDR post-process and the real scene color
  53829. */
  53830. hdrFinalPostProcess: Nullable<PostProcess>;
  53831. /**
  53832. * Post-process used to create a lens flare effect
  53833. */
  53834. lensFlarePostProcess: Nullable<PostProcess>;
  53835. /**
  53836. * Post-process that merges the result of the lens flare post-process and the real scene color
  53837. */
  53838. lensFlareComposePostProcess: Nullable<PostProcess>;
  53839. /**
  53840. * Post-process used to create a motion blur effect
  53841. */
  53842. motionBlurPostProcess: Nullable<PostProcess>;
  53843. /**
  53844. * Post-process used to create a depth of field effect
  53845. */
  53846. depthOfFieldPostProcess: Nullable<PostProcess>;
  53847. /**
  53848. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53849. */
  53850. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53851. /**
  53852. * Represents the brightness threshold in order to configure the illuminated surfaces
  53853. */
  53854. brightThreshold: number;
  53855. /**
  53856. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53857. */
  53858. blurWidth: number;
  53859. /**
  53860. * Sets if the blur for highlighted surfaces must be only horizontal
  53861. */
  53862. horizontalBlur: boolean;
  53863. /**
  53864. * Sets the overall exposure used by the pipeline
  53865. */
  53866. exposure: number;
  53867. /**
  53868. * Texture used typically to simulate "dirty" on camera lens
  53869. */
  53870. lensTexture: Nullable<Texture>;
  53871. /**
  53872. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53873. */
  53874. volumetricLightCoefficient: number;
  53875. /**
  53876. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53877. */
  53878. volumetricLightPower: number;
  53879. /**
  53880. * Used the set the blur intensity to smooth the volumetric lights
  53881. */
  53882. volumetricLightBlurScale: number;
  53883. /**
  53884. * Light (spot or directional) used to generate the volumetric lights rays
  53885. * The source light must have a shadow generate so the pipeline can get its
  53886. * depth map
  53887. */
  53888. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53889. /**
  53890. * For eye adaptation, represents the minimum luminance the eye can see
  53891. */
  53892. hdrMinimumLuminance: number;
  53893. /**
  53894. * For eye adaptation, represents the decrease luminance speed
  53895. */
  53896. hdrDecreaseRate: number;
  53897. /**
  53898. * For eye adaptation, represents the increase luminance speed
  53899. */
  53900. hdrIncreaseRate: number;
  53901. /**
  53902. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53903. */
  53904. lensColorTexture: Nullable<Texture>;
  53905. /**
  53906. * The overall strengh for the lens flare effect
  53907. */
  53908. lensFlareStrength: number;
  53909. /**
  53910. * Dispersion coefficient for lens flare ghosts
  53911. */
  53912. lensFlareGhostDispersal: number;
  53913. /**
  53914. * Main lens flare halo width
  53915. */
  53916. lensFlareHaloWidth: number;
  53917. /**
  53918. * Based on the lens distortion effect, defines how much the lens flare result
  53919. * is distorted
  53920. */
  53921. lensFlareDistortionStrength: number;
  53922. /**
  53923. * Lens star texture must be used to simulate rays on the flares and is available
  53924. * in the documentation
  53925. */
  53926. lensStarTexture: Nullable<Texture>;
  53927. /**
  53928. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53929. * flare effect by taking account of the dirt texture
  53930. */
  53931. lensFlareDirtTexture: Nullable<Texture>;
  53932. /**
  53933. * Represents the focal length for the depth of field effect
  53934. */
  53935. depthOfFieldDistance: number;
  53936. /**
  53937. * Represents the blur intensity for the blurred part of the depth of field effect
  53938. */
  53939. depthOfFieldBlurWidth: number;
  53940. /**
  53941. * For motion blur, defines how much the image is blurred by the movement
  53942. */
  53943. motionStrength: number;
  53944. /**
  53945. * List of animations for the pipeline (IAnimatable implementation)
  53946. */
  53947. animations: Animation[];
  53948. /**
  53949. * Private members
  53950. */
  53951. private _scene;
  53952. private _currentDepthOfFieldSource;
  53953. private _basePostProcess;
  53954. private _hdrCurrentLuminance;
  53955. private _floatTextureType;
  53956. private _ratio;
  53957. private _bloomEnabled;
  53958. private _depthOfFieldEnabled;
  53959. private _vlsEnabled;
  53960. private _lensFlareEnabled;
  53961. private _hdrEnabled;
  53962. private _motionBlurEnabled;
  53963. private _fxaaEnabled;
  53964. private _motionBlurSamples;
  53965. private _volumetricLightStepsCount;
  53966. private _samples;
  53967. /**
  53968. * @ignore
  53969. * Specifies if the bloom pipeline is enabled
  53970. */
  53971. BloomEnabled: boolean;
  53972. /**
  53973. * @ignore
  53974. * Specifies if the depth of field pipeline is enabed
  53975. */
  53976. DepthOfFieldEnabled: boolean;
  53977. /**
  53978. * @ignore
  53979. * Specifies if the lens flare pipeline is enabed
  53980. */
  53981. LensFlareEnabled: boolean;
  53982. /**
  53983. * @ignore
  53984. * Specifies if the HDR pipeline is enabled
  53985. */
  53986. HDREnabled: boolean;
  53987. /**
  53988. * @ignore
  53989. * Specifies if the volumetric lights scattering effect is enabled
  53990. */
  53991. VLSEnabled: boolean;
  53992. /**
  53993. * @ignore
  53994. * Specifies if the motion blur effect is enabled
  53995. */
  53996. MotionBlurEnabled: boolean;
  53997. /**
  53998. * Specifies if anti-aliasing is enabled
  53999. */
  54000. fxaaEnabled: boolean;
  54001. /**
  54002. * Specifies the number of steps used to calculate the volumetric lights
  54003. * Typically in interval [50, 200]
  54004. */
  54005. volumetricLightStepsCount: number;
  54006. /**
  54007. * Specifies the number of samples used for the motion blur effect
  54008. * Typically in interval [16, 64]
  54009. */
  54010. motionBlurSamples: number;
  54011. /**
  54012. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54013. */
  54014. samples: number;
  54015. /**
  54016. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54017. * @constructor
  54018. * @param name The rendering pipeline name
  54019. * @param scene The scene linked to this pipeline
  54020. * @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)
  54021. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54023. */
  54024. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54025. private _buildPipeline;
  54026. private _createDownSampleX4PostProcess;
  54027. private _createBrightPassPostProcess;
  54028. private _createBlurPostProcesses;
  54029. private _createTextureAdderPostProcess;
  54030. private _createVolumetricLightPostProcess;
  54031. private _createLuminancePostProcesses;
  54032. private _createHdrPostProcess;
  54033. private _createLensFlarePostProcess;
  54034. private _createDepthOfFieldPostProcess;
  54035. private _createMotionBlurPostProcess;
  54036. private _getDepthTexture;
  54037. private _disposePostProcesses;
  54038. /**
  54039. * Dispose of the pipeline and stop all post processes
  54040. */
  54041. dispose(): void;
  54042. /**
  54043. * Serialize the rendering pipeline (Used when exporting)
  54044. * @returns the serialized object
  54045. */
  54046. serialize(): any;
  54047. /**
  54048. * Parse the serialized pipeline
  54049. * @param source Source pipeline.
  54050. * @param scene The scene to load the pipeline to.
  54051. * @param rootUrl The URL of the serialized pipeline.
  54052. * @returns An instantiated pipeline from the serialized object.
  54053. */
  54054. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54055. /**
  54056. * Luminance steps
  54057. */
  54058. static LuminanceSteps: number;
  54059. }
  54060. }
  54061. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54062. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54063. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54064. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54065. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54066. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54067. }
  54068. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54069. import { Camera } from "babylonjs/Cameras/camera";
  54070. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54071. /**
  54072. * PostProcessRenderPipelineManager class
  54073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54074. */
  54075. export class PostProcessRenderPipelineManager {
  54076. private _renderPipelines;
  54077. /**
  54078. * Initializes a PostProcessRenderPipelineManager
  54079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54080. */
  54081. constructor();
  54082. /**
  54083. * Gets the list of supported render pipelines
  54084. */
  54085. readonly supportedPipelines: PostProcessRenderPipeline[];
  54086. /**
  54087. * Adds a pipeline to the manager
  54088. * @param renderPipeline The pipeline to add
  54089. */
  54090. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54091. /**
  54092. * Attaches a camera to the pipeline
  54093. * @param renderPipelineName The name of the pipeline to attach to
  54094. * @param cameras the camera to attach
  54095. * @param unique if the camera can be attached multiple times to the pipeline
  54096. */
  54097. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54098. /**
  54099. * Detaches a camera from the pipeline
  54100. * @param renderPipelineName The name of the pipeline to detach from
  54101. * @param cameras the camera to detach
  54102. */
  54103. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54104. /**
  54105. * Enables an effect by name on a pipeline
  54106. * @param renderPipelineName the name of the pipeline to enable the effect in
  54107. * @param renderEffectName the name of the effect to enable
  54108. * @param cameras the cameras that the effect should be enabled on
  54109. */
  54110. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54111. /**
  54112. * Disables an effect by name on a pipeline
  54113. * @param renderPipelineName the name of the pipeline to disable the effect in
  54114. * @param renderEffectName the name of the effect to disable
  54115. * @param cameras the cameras that the effect should be disabled on
  54116. */
  54117. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54118. /**
  54119. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54120. */
  54121. update(): void;
  54122. /** @hidden */
  54123. _rebuild(): void;
  54124. /**
  54125. * Disposes of the manager and pipelines
  54126. */
  54127. dispose(): void;
  54128. }
  54129. }
  54130. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54131. import { ISceneComponent } from "babylonjs/sceneComponent";
  54132. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54133. import { Scene } from "babylonjs/scene";
  54134. module "babylonjs/scene" {
  54135. interface Scene {
  54136. /** @hidden (Backing field) */
  54137. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54138. /**
  54139. * Gets the postprocess render pipeline manager
  54140. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54141. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54142. */
  54143. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54144. }
  54145. }
  54146. /**
  54147. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54148. */
  54149. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54150. /**
  54151. * The component name helpfull to identify the component in the list of scene components.
  54152. */
  54153. readonly name: string;
  54154. /**
  54155. * The scene the component belongs to.
  54156. */
  54157. scene: Scene;
  54158. /**
  54159. * Creates a new instance of the component for the given scene
  54160. * @param scene Defines the scene to register the component in
  54161. */
  54162. constructor(scene: Scene);
  54163. /**
  54164. * Registers the component in a given scene
  54165. */
  54166. register(): void;
  54167. /**
  54168. * Rebuilds the elements related to this component in case of
  54169. * context lost for instance.
  54170. */
  54171. rebuild(): void;
  54172. /**
  54173. * Disposes the component and the associated ressources
  54174. */
  54175. dispose(): void;
  54176. private _gatherRenderTargets;
  54177. }
  54178. }
  54179. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54180. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54181. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54182. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54183. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54184. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54185. }
  54186. declare module "babylonjs/Shaders/tonemap.fragment" {
  54187. /** @hidden */
  54188. export var tonemapPixelShader: {
  54189. name: string;
  54190. shader: string;
  54191. };
  54192. }
  54193. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54194. import { Camera } from "babylonjs/Cameras/camera";
  54195. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54196. import "babylonjs/Shaders/tonemap.fragment";
  54197. import { Engine } from "babylonjs/Engines/engine";
  54198. /** Defines operator used for tonemapping */
  54199. export enum TonemappingOperator {
  54200. /** Hable */
  54201. Hable = 0,
  54202. /** Reinhard */
  54203. Reinhard = 1,
  54204. /** HejiDawson */
  54205. HejiDawson = 2,
  54206. /** Photographic */
  54207. Photographic = 3
  54208. }
  54209. /**
  54210. * Defines a post process to apply tone mapping
  54211. */
  54212. export class TonemapPostProcess extends PostProcess {
  54213. private _operator;
  54214. /** Defines the required exposure adjustement */
  54215. exposureAdjustment: number;
  54216. /**
  54217. * Creates a new TonemapPostProcess
  54218. * @param name defines the name of the postprocess
  54219. * @param _operator defines the operator to use
  54220. * @param exposureAdjustment defines the required exposure adjustement
  54221. * @param camera defines the camera to use (can be null)
  54222. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54223. * @param engine defines the hosting engine (can be ignore if camera is set)
  54224. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54225. */
  54226. constructor(name: string, _operator: TonemappingOperator,
  54227. /** Defines the required exposure adjustement */
  54228. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54229. }
  54230. }
  54231. declare module "babylonjs/Shaders/depth.vertex" {
  54232. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54233. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54234. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54235. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54236. /** @hidden */
  54237. export var depthVertexShader: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54243. /** @hidden */
  54244. export var volumetricLightScatteringPixelShader: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54250. /** @hidden */
  54251. export var volumetricLightScatteringPassPixelShader: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54257. import { Vector3 } from "babylonjs/Maths/math";
  54258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54259. import { Mesh } from "babylonjs/Meshes/mesh";
  54260. import { Camera } from "babylonjs/Cameras/camera";
  54261. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54262. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54263. import { Scene } from "babylonjs/scene";
  54264. import "babylonjs/Meshes/Builders/planeBuilder";
  54265. import "babylonjs/Shaders/depth.vertex";
  54266. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54267. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54268. import { Engine } from "babylonjs/Engines/engine";
  54269. /**
  54270. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54271. */
  54272. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54273. private _volumetricLightScatteringPass;
  54274. private _volumetricLightScatteringRTT;
  54275. private _viewPort;
  54276. private _screenCoordinates;
  54277. private _cachedDefines;
  54278. /**
  54279. * If not undefined, the mesh position is computed from the attached node position
  54280. */
  54281. attachedNode: {
  54282. position: Vector3;
  54283. };
  54284. /**
  54285. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54286. */
  54287. customMeshPosition: Vector3;
  54288. /**
  54289. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54290. */
  54291. useCustomMeshPosition: boolean;
  54292. /**
  54293. * If the post-process should inverse the light scattering direction
  54294. */
  54295. invert: boolean;
  54296. /**
  54297. * The internal mesh used by the post-process
  54298. */
  54299. mesh: Mesh;
  54300. /**
  54301. * @hidden
  54302. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54303. */
  54304. useDiffuseColor: boolean;
  54305. /**
  54306. * Array containing the excluded meshes not rendered in the internal pass
  54307. */
  54308. excludedMeshes: AbstractMesh[];
  54309. /**
  54310. * Controls the overall intensity of the post-process
  54311. */
  54312. exposure: number;
  54313. /**
  54314. * Dissipates each sample's contribution in range [0, 1]
  54315. */
  54316. decay: number;
  54317. /**
  54318. * Controls the overall intensity of each sample
  54319. */
  54320. weight: number;
  54321. /**
  54322. * Controls the density of each sample
  54323. */
  54324. density: number;
  54325. /**
  54326. * @constructor
  54327. * @param name The post-process name
  54328. * @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)
  54329. * @param camera The camera that the post-process will be attached to
  54330. * @param mesh The mesh used to create the light scattering
  54331. * @param samples The post-process quality, default 100
  54332. * @param samplingModeThe post-process filtering mode
  54333. * @param engine The babylon engine
  54334. * @param reusable If the post-process is reusable
  54335. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54336. */
  54337. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54338. /**
  54339. * Returns the string "VolumetricLightScatteringPostProcess"
  54340. * @returns "VolumetricLightScatteringPostProcess"
  54341. */
  54342. getClassName(): string;
  54343. private _isReady;
  54344. /**
  54345. * Sets the new light position for light scattering effect
  54346. * @param position The new custom light position
  54347. */
  54348. setCustomMeshPosition(position: Vector3): void;
  54349. /**
  54350. * Returns the light position for light scattering effect
  54351. * @return Vector3 The custom light position
  54352. */
  54353. getCustomMeshPosition(): Vector3;
  54354. /**
  54355. * Disposes the internal assets and detaches the post-process from the camera
  54356. */
  54357. dispose(camera: Camera): void;
  54358. /**
  54359. * Returns the render target texture used by the post-process
  54360. * @return the render target texture used by the post-process
  54361. */
  54362. getPass(): RenderTargetTexture;
  54363. private _meshExcluded;
  54364. private _createPass;
  54365. private _updateMeshScreenCoordinates;
  54366. /**
  54367. * Creates a default mesh for the Volumeric Light Scattering post-process
  54368. * @param name The mesh name
  54369. * @param scene The scene where to create the mesh
  54370. * @return the default mesh
  54371. */
  54372. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54373. }
  54374. }
  54375. declare module "babylonjs/PostProcesses/index" {
  54376. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54377. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54378. export * from "babylonjs/PostProcesses/bloomEffect";
  54379. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54380. export * from "babylonjs/PostProcesses/blurPostProcess";
  54381. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54382. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54383. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54384. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54385. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54386. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54387. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54388. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54389. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54390. export * from "babylonjs/PostProcesses/filterPostProcess";
  54391. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54392. export * from "babylonjs/PostProcesses/grainPostProcess";
  54393. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54394. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54395. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54396. export * from "babylonjs/PostProcesses/passPostProcess";
  54397. export * from "babylonjs/PostProcesses/postProcess";
  54398. export * from "babylonjs/PostProcesses/postProcessManager";
  54399. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54400. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54401. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54402. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54403. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54404. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54405. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54406. }
  54407. declare module "babylonjs/Probes/index" {
  54408. export * from "babylonjs/Probes/reflectionProbe";
  54409. }
  54410. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54411. import { Scene } from "babylonjs/scene";
  54412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54413. import { Color3 } from "babylonjs/Maths/math";
  54414. import { SmartArray } from "babylonjs/Misc/smartArray";
  54415. import { ISceneComponent } from "babylonjs/sceneComponent";
  54416. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54417. import "babylonjs/Meshes/Builders/boxBuilder";
  54418. import "babylonjs/Shaders/color.fragment";
  54419. import "babylonjs/Shaders/color.vertex";
  54420. module "babylonjs/scene" {
  54421. interface Scene {
  54422. /** @hidden (Backing field) */
  54423. _boundingBoxRenderer: BoundingBoxRenderer;
  54424. /** @hidden (Backing field) */
  54425. _forceShowBoundingBoxes: boolean;
  54426. /**
  54427. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54428. */
  54429. forceShowBoundingBoxes: boolean;
  54430. /**
  54431. * Gets the bounding box renderer associated with the scene
  54432. * @returns a BoundingBoxRenderer
  54433. */
  54434. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54435. }
  54436. }
  54437. module "babylonjs/Meshes/abstractMesh" {
  54438. interface AbstractMesh {
  54439. /** @hidden (Backing field) */
  54440. _showBoundingBox: boolean;
  54441. /**
  54442. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54443. */
  54444. showBoundingBox: boolean;
  54445. }
  54446. }
  54447. /**
  54448. * Component responsible of rendering the bounding box of the meshes in a scene.
  54449. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54450. */
  54451. export class BoundingBoxRenderer implements ISceneComponent {
  54452. /**
  54453. * The component name helpfull to identify the component in the list of scene components.
  54454. */
  54455. readonly name: string;
  54456. /**
  54457. * The scene the component belongs to.
  54458. */
  54459. scene: Scene;
  54460. /**
  54461. * Color of the bounding box lines placed in front of an object
  54462. */
  54463. frontColor: Color3;
  54464. /**
  54465. * Color of the bounding box lines placed behind an object
  54466. */
  54467. backColor: Color3;
  54468. /**
  54469. * Defines if the renderer should show the back lines or not
  54470. */
  54471. showBackLines: boolean;
  54472. /**
  54473. * @hidden
  54474. */
  54475. renderList: SmartArray<BoundingBox>;
  54476. private _colorShader;
  54477. private _vertexBuffers;
  54478. private _indexBuffer;
  54479. /**
  54480. * Instantiates a new bounding box renderer in a scene.
  54481. * @param scene the scene the renderer renders in
  54482. */
  54483. constructor(scene: Scene);
  54484. /**
  54485. * Registers the component in a given scene
  54486. */
  54487. register(): void;
  54488. private _evaluateSubMesh;
  54489. private _activeMesh;
  54490. private _prepareRessources;
  54491. private _createIndexBuffer;
  54492. /**
  54493. * Rebuilds the elements related to this component in case of
  54494. * context lost for instance.
  54495. */
  54496. rebuild(): void;
  54497. /**
  54498. * @hidden
  54499. */
  54500. reset(): void;
  54501. /**
  54502. * Render the bounding boxes of a specific rendering group
  54503. * @param renderingGroupId defines the rendering group to render
  54504. */
  54505. render(renderingGroupId: number): void;
  54506. /**
  54507. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54508. * @param mesh Define the mesh to render the occlusion bounding box for
  54509. */
  54510. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54511. /**
  54512. * Dispose and release the resources attached to this renderer.
  54513. */
  54514. dispose(): void;
  54515. }
  54516. }
  54517. declare module "babylonjs/Shaders/depth.fragment" {
  54518. /** @hidden */
  54519. export var depthPixelShader: {
  54520. name: string;
  54521. shader: string;
  54522. };
  54523. }
  54524. declare module "babylonjs/Rendering/depthRenderer" {
  54525. import { Nullable } from "babylonjs/types";
  54526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54527. import { Scene } from "babylonjs/scene";
  54528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54529. import { Camera } from "babylonjs/Cameras/camera";
  54530. import "babylonjs/Shaders/depth.fragment";
  54531. import "babylonjs/Shaders/depth.vertex";
  54532. /**
  54533. * This represents a depth renderer in Babylon.
  54534. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54535. */
  54536. export class DepthRenderer {
  54537. private _scene;
  54538. private _depthMap;
  54539. private _effect;
  54540. private _cachedDefines;
  54541. private _camera;
  54542. /**
  54543. * Specifiess that the depth renderer will only be used within
  54544. * the camera it is created for.
  54545. * This can help forcing its rendering during the camera processing.
  54546. */
  54547. useOnlyInActiveCamera: boolean;
  54548. /** @hidden */
  54549. static _SceneComponentInitialization: (scene: Scene) => void;
  54550. /**
  54551. * Instantiates a depth renderer
  54552. * @param scene The scene the renderer belongs to
  54553. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54554. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54555. */
  54556. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54557. /**
  54558. * Creates the depth rendering effect and checks if the effect is ready.
  54559. * @param subMesh The submesh to be used to render the depth map of
  54560. * @param useInstances If multiple world instances should be used
  54561. * @returns if the depth renderer is ready to render the depth map
  54562. */
  54563. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54564. /**
  54565. * Gets the texture which the depth map will be written to.
  54566. * @returns The depth map texture
  54567. */
  54568. getDepthMap(): RenderTargetTexture;
  54569. /**
  54570. * Disposes of the depth renderer.
  54571. */
  54572. dispose(): void;
  54573. }
  54574. }
  54575. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54576. import { Nullable } from "babylonjs/types";
  54577. import { Scene } from "babylonjs/scene";
  54578. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54579. import { Camera } from "babylonjs/Cameras/camera";
  54580. import { ISceneComponent } from "babylonjs/sceneComponent";
  54581. module "babylonjs/scene" {
  54582. interface Scene {
  54583. /** @hidden (Backing field) */
  54584. _depthRenderer: {
  54585. [id: string]: DepthRenderer;
  54586. };
  54587. /**
  54588. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54589. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54590. * @returns the created depth renderer
  54591. */
  54592. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54593. /**
  54594. * Disables a depth renderer for a given camera
  54595. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54596. */
  54597. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54598. }
  54599. }
  54600. /**
  54601. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54602. * in several rendering techniques.
  54603. */
  54604. export class DepthRendererSceneComponent implements ISceneComponent {
  54605. /**
  54606. * The component name helpfull to identify the component in the list of scene components.
  54607. */
  54608. readonly name: string;
  54609. /**
  54610. * The scene the component belongs to.
  54611. */
  54612. scene: Scene;
  54613. /**
  54614. * Creates a new instance of the component for the given scene
  54615. * @param scene Defines the scene to register the component in
  54616. */
  54617. constructor(scene: Scene);
  54618. /**
  54619. * Registers the component in a given scene
  54620. */
  54621. register(): void;
  54622. /**
  54623. * Rebuilds the elements related to this component in case of
  54624. * context lost for instance.
  54625. */
  54626. rebuild(): void;
  54627. /**
  54628. * Disposes the component and the associated ressources
  54629. */
  54630. dispose(): void;
  54631. private _gatherRenderTargets;
  54632. private _gatherActiveCameraRenderTargets;
  54633. }
  54634. }
  54635. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54636. import { Nullable } from "babylonjs/types";
  54637. import { Scene } from "babylonjs/scene";
  54638. import { ISceneComponent } from "babylonjs/sceneComponent";
  54639. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54640. module "babylonjs/scene" {
  54641. interface Scene {
  54642. /** @hidden (Backing field) */
  54643. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54644. /**
  54645. * Gets or Sets the current geometry buffer associated to the scene.
  54646. */
  54647. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54648. /**
  54649. * Enables a GeometryBufferRender and associates it with the scene
  54650. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54651. * @returns the GeometryBufferRenderer
  54652. */
  54653. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54654. /**
  54655. * Disables the GeometryBufferRender associated with the scene
  54656. */
  54657. disableGeometryBufferRenderer(): void;
  54658. }
  54659. }
  54660. /**
  54661. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54662. * in several rendering techniques.
  54663. */
  54664. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54665. /**
  54666. * The component name helpful to identify the component in the list of scene components.
  54667. */
  54668. readonly name: string;
  54669. /**
  54670. * The scene the component belongs to.
  54671. */
  54672. scene: Scene;
  54673. /**
  54674. * Creates a new instance of the component for the given scene
  54675. * @param scene Defines the scene to register the component in
  54676. */
  54677. constructor(scene: Scene);
  54678. /**
  54679. * Registers the component in a given scene
  54680. */
  54681. register(): void;
  54682. /**
  54683. * Rebuilds the elements related to this component in case of
  54684. * context lost for instance.
  54685. */
  54686. rebuild(): void;
  54687. /**
  54688. * Disposes the component and the associated ressources
  54689. */
  54690. dispose(): void;
  54691. private _gatherRenderTargets;
  54692. }
  54693. }
  54694. declare module "babylonjs/Shaders/outline.fragment" {
  54695. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54696. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54697. /** @hidden */
  54698. export var outlinePixelShader: {
  54699. name: string;
  54700. shader: string;
  54701. };
  54702. }
  54703. declare module "babylonjs/Shaders/outline.vertex" {
  54704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54706. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54707. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54708. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54709. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54710. /** @hidden */
  54711. export var outlineVertexShader: {
  54712. name: string;
  54713. shader: string;
  54714. };
  54715. }
  54716. declare module "babylonjs/Rendering/outlineRenderer" {
  54717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54718. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54719. import { Scene } from "babylonjs/scene";
  54720. import { ISceneComponent } from "babylonjs/sceneComponent";
  54721. import "babylonjs/Shaders/outline.fragment";
  54722. import "babylonjs/Shaders/outline.vertex";
  54723. module "babylonjs/scene" {
  54724. interface Scene {
  54725. /** @hidden */
  54726. _outlineRenderer: OutlineRenderer;
  54727. /**
  54728. * Gets the outline renderer associated with the scene
  54729. * @returns a OutlineRenderer
  54730. */
  54731. getOutlineRenderer(): OutlineRenderer;
  54732. }
  54733. }
  54734. module "babylonjs/Meshes/abstractMesh" {
  54735. interface AbstractMesh {
  54736. /** @hidden (Backing field) */
  54737. _renderOutline: boolean;
  54738. /**
  54739. * Gets or sets a boolean indicating if the outline must be rendered as well
  54740. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54741. */
  54742. renderOutline: boolean;
  54743. /** @hidden (Backing field) */
  54744. _renderOverlay: boolean;
  54745. /**
  54746. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54747. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54748. */
  54749. renderOverlay: boolean;
  54750. }
  54751. }
  54752. /**
  54753. * This class is responsible to draw bothe outline/overlay of meshes.
  54754. * It should not be used directly but through the available method on mesh.
  54755. */
  54756. export class OutlineRenderer implements ISceneComponent {
  54757. /**
  54758. * The name of the component. Each component must have a unique name.
  54759. */
  54760. name: string;
  54761. /**
  54762. * The scene the component belongs to.
  54763. */
  54764. scene: Scene;
  54765. /**
  54766. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54767. */
  54768. zOffset: number;
  54769. private _engine;
  54770. private _effect;
  54771. private _cachedDefines;
  54772. private _savedDepthWrite;
  54773. /**
  54774. * Instantiates a new outline renderer. (There could be only one per scene).
  54775. * @param scene Defines the scene it belongs to
  54776. */
  54777. constructor(scene: Scene);
  54778. /**
  54779. * Register the component to one instance of a scene.
  54780. */
  54781. register(): void;
  54782. /**
  54783. * Rebuilds the elements related to this component in case of
  54784. * context lost for instance.
  54785. */
  54786. rebuild(): void;
  54787. /**
  54788. * Disposes the component and the associated ressources.
  54789. */
  54790. dispose(): void;
  54791. /**
  54792. * Renders the outline in the canvas.
  54793. * @param subMesh Defines the sumesh to render
  54794. * @param batch Defines the batch of meshes in case of instances
  54795. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54796. */
  54797. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54798. /**
  54799. * Returns whether or not the outline renderer is ready for a given submesh.
  54800. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54801. * @param subMesh Defines the submesh to check readyness for
  54802. * @param useInstances Defines wheter wee are trying to render instances or not
  54803. * @returns true if ready otherwise false
  54804. */
  54805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54806. private _beforeRenderingMesh;
  54807. private _afterRenderingMesh;
  54808. }
  54809. }
  54810. declare module "babylonjs/Rendering/index" {
  54811. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54812. export * from "babylonjs/Rendering/depthRenderer";
  54813. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54814. export * from "babylonjs/Rendering/edgesRenderer";
  54815. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54816. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54817. export * from "babylonjs/Rendering/outlineRenderer";
  54818. export * from "babylonjs/Rendering/renderingGroup";
  54819. export * from "babylonjs/Rendering/renderingManager";
  54820. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54821. }
  54822. declare module "babylonjs/Sprites/index" {
  54823. export * from "babylonjs/Sprites/sprite";
  54824. export * from "babylonjs/Sprites/spriteManager";
  54825. export * from "babylonjs/Sprites/spriteSceneComponent";
  54826. }
  54827. declare module "babylonjs/Misc/assetsManager" {
  54828. import { Scene } from "babylonjs/scene";
  54829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54831. import { Skeleton } from "babylonjs/Bones/skeleton";
  54832. import { Observable } from "babylonjs/Misc/observable";
  54833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54834. import { Texture } from "babylonjs/Materials/Textures/texture";
  54835. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54836. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54837. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54838. /**
  54839. * Defines the list of states available for a task inside a AssetsManager
  54840. */
  54841. export enum AssetTaskState {
  54842. /**
  54843. * Initialization
  54844. */
  54845. INIT = 0,
  54846. /**
  54847. * Running
  54848. */
  54849. RUNNING = 1,
  54850. /**
  54851. * Done
  54852. */
  54853. DONE = 2,
  54854. /**
  54855. * Error
  54856. */
  54857. ERROR = 3
  54858. }
  54859. /**
  54860. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54861. */
  54862. export abstract class AbstractAssetTask {
  54863. /**
  54864. * Task name
  54865. */ name: string;
  54866. /**
  54867. * Callback called when the task is successful
  54868. */
  54869. onSuccess: (task: any) => void;
  54870. /**
  54871. * Callback called when the task is not successful
  54872. */
  54873. onError: (task: any, message?: string, exception?: any) => void;
  54874. /**
  54875. * Creates a new AssetsManager
  54876. * @param name defines the name of the task
  54877. */
  54878. constructor(
  54879. /**
  54880. * Task name
  54881. */ name: string);
  54882. private _isCompleted;
  54883. private _taskState;
  54884. private _errorObject;
  54885. /**
  54886. * Get if the task is completed
  54887. */
  54888. readonly isCompleted: boolean;
  54889. /**
  54890. * Gets the current state of the task
  54891. */
  54892. readonly taskState: AssetTaskState;
  54893. /**
  54894. * Gets the current error object (if task is in error)
  54895. */
  54896. readonly errorObject: {
  54897. message?: string;
  54898. exception?: any;
  54899. };
  54900. /**
  54901. * Internal only
  54902. * @hidden
  54903. */
  54904. _setErrorObject(message?: string, exception?: any): void;
  54905. /**
  54906. * Execute the current task
  54907. * @param scene defines the scene where you want your assets to be loaded
  54908. * @param onSuccess is a callback called when the task is successfully executed
  54909. * @param onError is a callback called if an error occurs
  54910. */
  54911. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54912. /**
  54913. * Execute the current task
  54914. * @param scene defines the scene where you want your assets to be loaded
  54915. * @param onSuccess is a callback called when the task is successfully executed
  54916. * @param onError is a callback called if an error occurs
  54917. */
  54918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54919. /**
  54920. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54921. * This can be used with failed tasks that have the reason for failure fixed.
  54922. */
  54923. reset(): void;
  54924. private onErrorCallback;
  54925. private onDoneCallback;
  54926. }
  54927. /**
  54928. * Define the interface used by progress events raised during assets loading
  54929. */
  54930. export interface IAssetsProgressEvent {
  54931. /**
  54932. * Defines the number of remaining tasks to process
  54933. */
  54934. remainingCount: number;
  54935. /**
  54936. * Defines the total number of tasks
  54937. */
  54938. totalCount: number;
  54939. /**
  54940. * Defines the task that was just processed
  54941. */
  54942. task: AbstractAssetTask;
  54943. }
  54944. /**
  54945. * Class used to share progress information about assets loading
  54946. */
  54947. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54948. /**
  54949. * Defines the number of remaining tasks to process
  54950. */
  54951. remainingCount: number;
  54952. /**
  54953. * Defines the total number of tasks
  54954. */
  54955. totalCount: number;
  54956. /**
  54957. * Defines the task that was just processed
  54958. */
  54959. task: AbstractAssetTask;
  54960. /**
  54961. * Creates a AssetsProgressEvent
  54962. * @param remainingCount defines the number of remaining tasks to process
  54963. * @param totalCount defines the total number of tasks
  54964. * @param task defines the task that was just processed
  54965. */
  54966. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54967. }
  54968. /**
  54969. * Define a task used by AssetsManager to load meshes
  54970. */
  54971. export class MeshAssetTask extends AbstractAssetTask {
  54972. /**
  54973. * Defines the name of the task
  54974. */
  54975. name: string;
  54976. /**
  54977. * Defines the list of mesh's names you want to load
  54978. */
  54979. meshesNames: any;
  54980. /**
  54981. * Defines the root url to use as a base to load your meshes and associated resources
  54982. */
  54983. rootUrl: string;
  54984. /**
  54985. * Defines the filename of the scene to load from
  54986. */
  54987. sceneFilename: string;
  54988. /**
  54989. * Gets the list of loaded meshes
  54990. */
  54991. loadedMeshes: Array<AbstractMesh>;
  54992. /**
  54993. * Gets the list of loaded particle systems
  54994. */
  54995. loadedParticleSystems: Array<IParticleSystem>;
  54996. /**
  54997. * Gets the list of loaded skeletons
  54998. */
  54999. loadedSkeletons: Array<Skeleton>;
  55000. /**
  55001. * Gets the list of loaded animation groups
  55002. */
  55003. loadedAnimationGroups: Array<AnimationGroup>;
  55004. /**
  55005. * Callback called when the task is successful
  55006. */
  55007. onSuccess: (task: MeshAssetTask) => void;
  55008. /**
  55009. * Callback called when the task is successful
  55010. */
  55011. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55012. /**
  55013. * Creates a new MeshAssetTask
  55014. * @param name defines the name of the task
  55015. * @param meshesNames defines the list of mesh's names you want to load
  55016. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55017. * @param sceneFilename defines the filename of the scene to load from
  55018. */
  55019. constructor(
  55020. /**
  55021. * Defines the name of the task
  55022. */
  55023. name: string,
  55024. /**
  55025. * Defines the list of mesh's names you want to load
  55026. */
  55027. meshesNames: any,
  55028. /**
  55029. * Defines the root url to use as a base to load your meshes and associated resources
  55030. */
  55031. rootUrl: string,
  55032. /**
  55033. * Defines the filename of the scene to load from
  55034. */
  55035. sceneFilename: string);
  55036. /**
  55037. * Execute the current task
  55038. * @param scene defines the scene where you want your assets to be loaded
  55039. * @param onSuccess is a callback called when the task is successfully executed
  55040. * @param onError is a callback called if an error occurs
  55041. */
  55042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55043. }
  55044. /**
  55045. * Define a task used by AssetsManager to load text content
  55046. */
  55047. export class TextFileAssetTask extends AbstractAssetTask {
  55048. /**
  55049. * Defines the name of the task
  55050. */
  55051. name: string;
  55052. /**
  55053. * Defines the location of the file to load
  55054. */
  55055. url: string;
  55056. /**
  55057. * Gets the loaded text string
  55058. */
  55059. text: string;
  55060. /**
  55061. * Callback called when the task is successful
  55062. */
  55063. onSuccess: (task: TextFileAssetTask) => void;
  55064. /**
  55065. * Callback called when the task is successful
  55066. */
  55067. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55068. /**
  55069. * Creates a new TextFileAssetTask object
  55070. * @param name defines the name of the task
  55071. * @param url defines the location of the file to load
  55072. */
  55073. constructor(
  55074. /**
  55075. * Defines the name of the task
  55076. */
  55077. name: string,
  55078. /**
  55079. * Defines the location of the file to load
  55080. */
  55081. url: string);
  55082. /**
  55083. * Execute the current task
  55084. * @param scene defines the scene where you want your assets to be loaded
  55085. * @param onSuccess is a callback called when the task is successfully executed
  55086. * @param onError is a callback called if an error occurs
  55087. */
  55088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55089. }
  55090. /**
  55091. * Define a task used by AssetsManager to load binary data
  55092. */
  55093. export class BinaryFileAssetTask extends AbstractAssetTask {
  55094. /**
  55095. * Defines the name of the task
  55096. */
  55097. name: string;
  55098. /**
  55099. * Defines the location of the file to load
  55100. */
  55101. url: string;
  55102. /**
  55103. * Gets the lodaded data (as an array buffer)
  55104. */
  55105. data: ArrayBuffer;
  55106. /**
  55107. * Callback called when the task is successful
  55108. */
  55109. onSuccess: (task: BinaryFileAssetTask) => void;
  55110. /**
  55111. * Callback called when the task is successful
  55112. */
  55113. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55114. /**
  55115. * Creates a new BinaryFileAssetTask object
  55116. * @param name defines the name of the new task
  55117. * @param url defines the location of the file to load
  55118. */
  55119. constructor(
  55120. /**
  55121. * Defines the name of the task
  55122. */
  55123. name: string,
  55124. /**
  55125. * Defines the location of the file to load
  55126. */
  55127. url: string);
  55128. /**
  55129. * Execute the current task
  55130. * @param scene defines the scene where you want your assets to be loaded
  55131. * @param onSuccess is a callback called when the task is successfully executed
  55132. * @param onError is a callback called if an error occurs
  55133. */
  55134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55135. }
  55136. /**
  55137. * Define a task used by AssetsManager to load images
  55138. */
  55139. export class ImageAssetTask extends AbstractAssetTask {
  55140. /**
  55141. * Defines the name of the task
  55142. */
  55143. name: string;
  55144. /**
  55145. * Defines the location of the image to load
  55146. */
  55147. url: string;
  55148. /**
  55149. * Gets the loaded images
  55150. */
  55151. image: HTMLImageElement;
  55152. /**
  55153. * Callback called when the task is successful
  55154. */
  55155. onSuccess: (task: ImageAssetTask) => void;
  55156. /**
  55157. * Callback called when the task is successful
  55158. */
  55159. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55160. /**
  55161. * Creates a new ImageAssetTask
  55162. * @param name defines the name of the task
  55163. * @param url defines the location of the image to load
  55164. */
  55165. constructor(
  55166. /**
  55167. * Defines the name of the task
  55168. */
  55169. name: string,
  55170. /**
  55171. * Defines the location of the image to load
  55172. */
  55173. url: string);
  55174. /**
  55175. * Execute the current task
  55176. * @param scene defines the scene where you want your assets to be loaded
  55177. * @param onSuccess is a callback called when the task is successfully executed
  55178. * @param onError is a callback called if an error occurs
  55179. */
  55180. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55181. }
  55182. /**
  55183. * Defines the interface used by texture loading tasks
  55184. */
  55185. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55186. /**
  55187. * Gets the loaded texture
  55188. */
  55189. texture: TEX;
  55190. }
  55191. /**
  55192. * Define a task used by AssetsManager to load 2D textures
  55193. */
  55194. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55195. /**
  55196. * Defines the name of the task
  55197. */
  55198. name: string;
  55199. /**
  55200. * Defines the location of the file to load
  55201. */
  55202. url: string;
  55203. /**
  55204. * Defines if mipmap should not be generated (default is false)
  55205. */
  55206. noMipmap?: boolean | undefined;
  55207. /**
  55208. * Defines if texture must be inverted on Y axis (default is false)
  55209. */
  55210. invertY?: boolean | undefined;
  55211. /**
  55212. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55213. */
  55214. samplingMode: number;
  55215. /**
  55216. * Gets the loaded texture
  55217. */
  55218. texture: Texture;
  55219. /**
  55220. * Callback called when the task is successful
  55221. */
  55222. onSuccess: (task: TextureAssetTask) => void;
  55223. /**
  55224. * Callback called when the task is successful
  55225. */
  55226. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55227. /**
  55228. * Creates a new TextureAssetTask object
  55229. * @param name defines the name of the task
  55230. * @param url defines the location of the file to load
  55231. * @param noMipmap defines if mipmap should not be generated (default is false)
  55232. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55233. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55234. */
  55235. constructor(
  55236. /**
  55237. * Defines the name of the task
  55238. */
  55239. name: string,
  55240. /**
  55241. * Defines the location of the file to load
  55242. */
  55243. url: string,
  55244. /**
  55245. * Defines if mipmap should not be generated (default is false)
  55246. */
  55247. noMipmap?: boolean | undefined,
  55248. /**
  55249. * Defines if texture must be inverted on Y axis (default is false)
  55250. */
  55251. invertY?: boolean | undefined,
  55252. /**
  55253. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55254. */
  55255. samplingMode?: number);
  55256. /**
  55257. * Execute the current task
  55258. * @param scene defines the scene where you want your assets to be loaded
  55259. * @param onSuccess is a callback called when the task is successfully executed
  55260. * @param onError is a callback called if an error occurs
  55261. */
  55262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55263. }
  55264. /**
  55265. * Define a task used by AssetsManager to load cube textures
  55266. */
  55267. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55268. /**
  55269. * Defines the name of the task
  55270. */
  55271. name: string;
  55272. /**
  55273. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55274. */
  55275. url: string;
  55276. /**
  55277. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55278. */
  55279. extensions?: string[] | undefined;
  55280. /**
  55281. * Defines if mipmaps should not be generated (default is false)
  55282. */
  55283. noMipmap?: boolean | undefined;
  55284. /**
  55285. * Defines the explicit list of files (undefined by default)
  55286. */
  55287. files?: string[] | undefined;
  55288. /**
  55289. * Gets the loaded texture
  55290. */
  55291. texture: CubeTexture;
  55292. /**
  55293. * Callback called when the task is successful
  55294. */
  55295. onSuccess: (task: CubeTextureAssetTask) => void;
  55296. /**
  55297. * Callback called when the task is successful
  55298. */
  55299. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55300. /**
  55301. * Creates a new CubeTextureAssetTask
  55302. * @param name defines the name of the task
  55303. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55304. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55305. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55306. * @param files defines the explicit list of files (undefined by default)
  55307. */
  55308. constructor(
  55309. /**
  55310. * Defines the name of the task
  55311. */
  55312. name: string,
  55313. /**
  55314. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55315. */
  55316. url: string,
  55317. /**
  55318. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55319. */
  55320. extensions?: string[] | undefined,
  55321. /**
  55322. * Defines if mipmaps should not be generated (default is false)
  55323. */
  55324. noMipmap?: boolean | undefined,
  55325. /**
  55326. * Defines the explicit list of files (undefined by default)
  55327. */
  55328. files?: string[] | undefined);
  55329. /**
  55330. * Execute the current task
  55331. * @param scene defines the scene where you want your assets to be loaded
  55332. * @param onSuccess is a callback called when the task is successfully executed
  55333. * @param onError is a callback called if an error occurs
  55334. */
  55335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55336. }
  55337. /**
  55338. * Define a task used by AssetsManager to load HDR cube textures
  55339. */
  55340. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55341. /**
  55342. * Defines the name of the task
  55343. */
  55344. name: string;
  55345. /**
  55346. * Defines the location of the file to load
  55347. */
  55348. url: string;
  55349. /**
  55350. * Defines the desired size (the more it increases the longer the generation will be)
  55351. */
  55352. size: number;
  55353. /**
  55354. * Defines if mipmaps should not be generated (default is false)
  55355. */
  55356. noMipmap: boolean;
  55357. /**
  55358. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55359. */
  55360. generateHarmonics: boolean;
  55361. /**
  55362. * 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)
  55363. */
  55364. gammaSpace: boolean;
  55365. /**
  55366. * Internal Use Only
  55367. */
  55368. reserved: boolean;
  55369. /**
  55370. * Gets the loaded texture
  55371. */
  55372. texture: HDRCubeTexture;
  55373. /**
  55374. * Callback called when the task is successful
  55375. */
  55376. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55377. /**
  55378. * Callback called when the task is successful
  55379. */
  55380. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55381. /**
  55382. * Creates a new HDRCubeTextureAssetTask object
  55383. * @param name defines the name of the task
  55384. * @param url defines the location of the file to load
  55385. * @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.
  55386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55387. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55388. * @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)
  55389. * @param reserved Internal use only
  55390. */
  55391. constructor(
  55392. /**
  55393. * Defines the name of the task
  55394. */
  55395. name: string,
  55396. /**
  55397. * Defines the location of the file to load
  55398. */
  55399. url: string,
  55400. /**
  55401. * Defines the desired size (the more it increases the longer the generation will be)
  55402. */
  55403. size: number,
  55404. /**
  55405. * Defines if mipmaps should not be generated (default is false)
  55406. */
  55407. noMipmap?: boolean,
  55408. /**
  55409. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55410. */
  55411. generateHarmonics?: boolean,
  55412. /**
  55413. * 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)
  55414. */
  55415. gammaSpace?: boolean,
  55416. /**
  55417. * Internal Use Only
  55418. */
  55419. reserved?: boolean);
  55420. /**
  55421. * Execute the current task
  55422. * @param scene defines the scene where you want your assets to be loaded
  55423. * @param onSuccess is a callback called when the task is successfully executed
  55424. * @param onError is a callback called if an error occurs
  55425. */
  55426. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55427. }
  55428. /**
  55429. * This class can be used to easily import assets into a scene
  55430. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55431. */
  55432. export class AssetsManager {
  55433. private _scene;
  55434. private _isLoading;
  55435. protected _tasks: AbstractAssetTask[];
  55436. protected _waitingTasksCount: number;
  55437. protected _totalTasksCount: number;
  55438. /**
  55439. * Callback called when all tasks are processed
  55440. */
  55441. onFinish: (tasks: AbstractAssetTask[]) => void;
  55442. /**
  55443. * Callback called when a task is successful
  55444. */
  55445. onTaskSuccess: (task: AbstractAssetTask) => void;
  55446. /**
  55447. * Callback called when a task had an error
  55448. */
  55449. onTaskError: (task: AbstractAssetTask) => void;
  55450. /**
  55451. * Callback called when a task is done (whatever the result is)
  55452. */
  55453. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55454. /**
  55455. * Observable called when all tasks are processed
  55456. */
  55457. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55458. /**
  55459. * Observable called when a task had an error
  55460. */
  55461. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55462. /**
  55463. * Observable called when a task is successful
  55464. */
  55465. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55466. /**
  55467. * Observable called when a task is done (whatever the result is)
  55468. */
  55469. onProgressObservable: Observable<IAssetsProgressEvent>;
  55470. /**
  55471. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55473. */
  55474. useDefaultLoadingScreen: boolean;
  55475. /**
  55476. * Creates a new AssetsManager
  55477. * @param scene defines the scene to work on
  55478. */
  55479. constructor(scene: Scene);
  55480. /**
  55481. * Add a MeshAssetTask to the list of active tasks
  55482. * @param taskName defines the name of the new task
  55483. * @param meshesNames defines the name of meshes to load
  55484. * @param rootUrl defines the root url to use to locate files
  55485. * @param sceneFilename defines the filename of the scene file
  55486. * @returns a new MeshAssetTask object
  55487. */
  55488. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55489. /**
  55490. * Add a TextFileAssetTask to the list of active tasks
  55491. * @param taskName defines the name of the new task
  55492. * @param url defines the url of the file to load
  55493. * @returns a new TextFileAssetTask object
  55494. */
  55495. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55496. /**
  55497. * Add a BinaryFileAssetTask to the list of active tasks
  55498. * @param taskName defines the name of the new task
  55499. * @param url defines the url of the file to load
  55500. * @returns a new BinaryFileAssetTask object
  55501. */
  55502. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55503. /**
  55504. * Add a ImageAssetTask to the list of active tasks
  55505. * @param taskName defines the name of the new task
  55506. * @param url defines the url of the file to load
  55507. * @returns a new ImageAssetTask object
  55508. */
  55509. addImageTask(taskName: string, url: string): ImageAssetTask;
  55510. /**
  55511. * Add a TextureAssetTask to the list of active tasks
  55512. * @param taskName defines the name of the new task
  55513. * @param url defines the url of the file to load
  55514. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55515. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55516. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55517. * @returns a new TextureAssetTask object
  55518. */
  55519. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55520. /**
  55521. * Add a CubeTextureAssetTask to the list of active tasks
  55522. * @param taskName defines the name of the new task
  55523. * @param url defines the url of the file to load
  55524. * @param extensions defines the extension to use to load the cube map (can be null)
  55525. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55526. * @param files defines the list of files to load (can be null)
  55527. * @returns a new CubeTextureAssetTask object
  55528. */
  55529. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55530. /**
  55531. *
  55532. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55533. * @param taskName defines the name of the new task
  55534. * @param url defines the url of the file to load
  55535. * @param size defines the size you want for the cubemap (can be null)
  55536. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55537. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55538. * @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)
  55539. * @param reserved Internal use only
  55540. * @returns a new HDRCubeTextureAssetTask object
  55541. */
  55542. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55543. /**
  55544. * Remove a task from the assets manager.
  55545. * @param task the task to remove
  55546. */
  55547. removeTask(task: AbstractAssetTask): void;
  55548. private _decreaseWaitingTasksCount;
  55549. private _runTask;
  55550. /**
  55551. * Reset the AssetsManager and remove all tasks
  55552. * @return the current instance of the AssetsManager
  55553. */
  55554. reset(): AssetsManager;
  55555. /**
  55556. * Start the loading process
  55557. * @return the current instance of the AssetsManager
  55558. */
  55559. load(): AssetsManager;
  55560. }
  55561. }
  55562. declare module "babylonjs/Misc/deferred" {
  55563. /**
  55564. * Wrapper class for promise with external resolve and reject.
  55565. */
  55566. export class Deferred<T> {
  55567. /**
  55568. * The promise associated with this deferred object.
  55569. */
  55570. readonly promise: Promise<T>;
  55571. private _resolve;
  55572. private _reject;
  55573. /**
  55574. * The resolve method of the promise associated with this deferred object.
  55575. */
  55576. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55577. /**
  55578. * The reject method of the promise associated with this deferred object.
  55579. */
  55580. readonly reject: (reason?: any) => void;
  55581. /**
  55582. * Constructor for this deferred object.
  55583. */
  55584. constructor();
  55585. }
  55586. }
  55587. declare module "babylonjs/Misc/filesInput" {
  55588. import { Engine } from "babylonjs/Engines/engine";
  55589. import { Scene } from "babylonjs/scene";
  55590. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55591. /**
  55592. * Class used to help managing file picking and drag'n'drop
  55593. */
  55594. export class FilesInput {
  55595. /**
  55596. * List of files ready to be loaded
  55597. */
  55598. static readonly FilesToLoad: {
  55599. [key: string]: File;
  55600. };
  55601. /**
  55602. * Callback called when a file is processed
  55603. */
  55604. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55605. private _engine;
  55606. private _currentScene;
  55607. private _sceneLoadedCallback;
  55608. private _progressCallback;
  55609. private _additionalRenderLoopLogicCallback;
  55610. private _textureLoadingCallback;
  55611. private _startingProcessingFilesCallback;
  55612. private _onReloadCallback;
  55613. private _errorCallback;
  55614. private _elementToMonitor;
  55615. private _sceneFileToLoad;
  55616. private _filesToLoad;
  55617. /**
  55618. * Creates a new FilesInput
  55619. * @param engine defines the rendering engine
  55620. * @param scene defines the hosting scene
  55621. * @param sceneLoadedCallback callback called when scene is loaded
  55622. * @param progressCallback callback called to track progress
  55623. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55624. * @param textureLoadingCallback callback called when a texture is loading
  55625. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55626. * @param onReloadCallback callback called when a reload is requested
  55627. * @param errorCallback callback call if an error occurs
  55628. */
  55629. 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);
  55630. private _dragEnterHandler;
  55631. private _dragOverHandler;
  55632. private _dropHandler;
  55633. /**
  55634. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55635. * @param elementToMonitor defines the DOM element to track
  55636. */
  55637. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55638. /**
  55639. * Release all associated resources
  55640. */
  55641. dispose(): void;
  55642. private renderFunction;
  55643. private drag;
  55644. private drop;
  55645. private _traverseFolder;
  55646. private _processFiles;
  55647. /**
  55648. * Load files from a drop event
  55649. * @param event defines the drop event to use as source
  55650. */
  55651. loadFiles(event: any): void;
  55652. private _processReload;
  55653. /**
  55654. * Reload the current scene from the loaded files
  55655. */
  55656. reload(): void;
  55657. }
  55658. }
  55659. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55660. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55661. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55662. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55663. }
  55664. declare module "babylonjs/Misc/sceneOptimizer" {
  55665. import { Scene, IDisposable } from "babylonjs/scene";
  55666. import { Observable } from "babylonjs/Misc/observable";
  55667. /**
  55668. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55670. */
  55671. export class SceneOptimization {
  55672. /**
  55673. * Defines the priority of this optimization (0 by default which means first in the list)
  55674. */
  55675. priority: number;
  55676. /**
  55677. * Gets a string describing the action executed by the current optimization
  55678. * @returns description string
  55679. */
  55680. getDescription(): string;
  55681. /**
  55682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55683. * @param scene defines the current scene where to apply this optimization
  55684. * @param optimizer defines the current optimizer
  55685. * @returns true if everything that can be done was applied
  55686. */
  55687. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55688. /**
  55689. * Creates the SceneOptimization object
  55690. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55691. * @param desc defines the description associated with the optimization
  55692. */
  55693. constructor(
  55694. /**
  55695. * Defines the priority of this optimization (0 by default which means first in the list)
  55696. */
  55697. priority?: number);
  55698. }
  55699. /**
  55700. * Defines an optimization used to reduce the size of render target textures
  55701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55702. */
  55703. export class TextureOptimization extends SceneOptimization {
  55704. /**
  55705. * Defines the priority of this optimization (0 by default which means first in the list)
  55706. */
  55707. priority: number;
  55708. /**
  55709. * 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
  55710. */
  55711. maximumSize: number;
  55712. /**
  55713. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55714. */
  55715. step: number;
  55716. /**
  55717. * Gets a string describing the action executed by the current optimization
  55718. * @returns description string
  55719. */
  55720. getDescription(): string;
  55721. /**
  55722. * Creates the TextureOptimization object
  55723. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55724. * @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
  55725. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55726. */
  55727. constructor(
  55728. /**
  55729. * Defines the priority of this optimization (0 by default which means first in the list)
  55730. */
  55731. priority?: number,
  55732. /**
  55733. * 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
  55734. */
  55735. maximumSize?: number,
  55736. /**
  55737. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55738. */
  55739. step?: number);
  55740. /**
  55741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55742. * @param scene defines the current scene where to apply this optimization
  55743. * @param optimizer defines the current optimizer
  55744. * @returns true if everything that can be done was applied
  55745. */
  55746. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55747. }
  55748. /**
  55749. * Defines an optimization used to increase or decrease the rendering resolution
  55750. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55751. */
  55752. export class HardwareScalingOptimization extends SceneOptimization {
  55753. /**
  55754. * Defines the priority of this optimization (0 by default which means first in the list)
  55755. */
  55756. priority: number;
  55757. /**
  55758. * Defines the maximum scale to use (2 by default)
  55759. */
  55760. maximumScale: number;
  55761. /**
  55762. * Defines the step to use between two passes (0.5 by default)
  55763. */
  55764. step: number;
  55765. private _currentScale;
  55766. private _directionOffset;
  55767. /**
  55768. * Gets a string describing the action executed by the current optimization
  55769. * @return description string
  55770. */
  55771. getDescription(): string;
  55772. /**
  55773. * Creates the HardwareScalingOptimization object
  55774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55775. * @param maximumScale defines the maximum scale to use (2 by default)
  55776. * @param step defines the step to use between two passes (0.5 by default)
  55777. */
  55778. constructor(
  55779. /**
  55780. * Defines the priority of this optimization (0 by default which means first in the list)
  55781. */
  55782. priority?: number,
  55783. /**
  55784. * Defines the maximum scale to use (2 by default)
  55785. */
  55786. maximumScale?: number,
  55787. /**
  55788. * Defines the step to use between two passes (0.5 by default)
  55789. */
  55790. step?: number);
  55791. /**
  55792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55793. * @param scene defines the current scene where to apply this optimization
  55794. * @param optimizer defines the current optimizer
  55795. * @returns true if everything that can be done was applied
  55796. */
  55797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55798. }
  55799. /**
  55800. * Defines an optimization used to remove shadows
  55801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55802. */
  55803. export class ShadowsOptimization extends SceneOptimization {
  55804. /**
  55805. * Gets a string describing the action executed by the current optimization
  55806. * @return description string
  55807. */
  55808. getDescription(): string;
  55809. /**
  55810. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55811. * @param scene defines the current scene where to apply this optimization
  55812. * @param optimizer defines the current optimizer
  55813. * @returns true if everything that can be done was applied
  55814. */
  55815. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55816. }
  55817. /**
  55818. * Defines an optimization used to turn post-processes off
  55819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55820. */
  55821. export class PostProcessesOptimization extends SceneOptimization {
  55822. /**
  55823. * Gets a string describing the action executed by the current optimization
  55824. * @return description string
  55825. */
  55826. getDescription(): string;
  55827. /**
  55828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55829. * @param scene defines the current scene where to apply this optimization
  55830. * @param optimizer defines the current optimizer
  55831. * @returns true if everything that can be done was applied
  55832. */
  55833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55834. }
  55835. /**
  55836. * Defines an optimization used to turn lens flares off
  55837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55838. */
  55839. export class LensFlaresOptimization extends SceneOptimization {
  55840. /**
  55841. * Gets a string describing the action executed by the current optimization
  55842. * @return description string
  55843. */
  55844. getDescription(): string;
  55845. /**
  55846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55847. * @param scene defines the current scene where to apply this optimization
  55848. * @param optimizer defines the current optimizer
  55849. * @returns true if everything that can be done was applied
  55850. */
  55851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55852. }
  55853. /**
  55854. * Defines an optimization based on user defined callback.
  55855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55856. */
  55857. export class CustomOptimization extends SceneOptimization {
  55858. /**
  55859. * Callback called to apply the custom optimization.
  55860. */
  55861. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55862. /**
  55863. * Callback called to get custom description
  55864. */
  55865. onGetDescription: () => string;
  55866. /**
  55867. * Gets a string describing the action executed by the current optimization
  55868. * @returns description string
  55869. */
  55870. getDescription(): string;
  55871. /**
  55872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55873. * @param scene defines the current scene where to apply this optimization
  55874. * @param optimizer defines the current optimizer
  55875. * @returns true if everything that can be done was applied
  55876. */
  55877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55878. }
  55879. /**
  55880. * Defines an optimization used to turn particles off
  55881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55882. */
  55883. export class ParticlesOptimization extends SceneOptimization {
  55884. /**
  55885. * Gets a string describing the action executed by the current optimization
  55886. * @return description string
  55887. */
  55888. getDescription(): string;
  55889. /**
  55890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55891. * @param scene defines the current scene where to apply this optimization
  55892. * @param optimizer defines the current optimizer
  55893. * @returns true if everything that can be done was applied
  55894. */
  55895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55896. }
  55897. /**
  55898. * Defines an optimization used to turn render targets off
  55899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55900. */
  55901. export class RenderTargetsOptimization extends SceneOptimization {
  55902. /**
  55903. * Gets a string describing the action executed by the current optimization
  55904. * @return description string
  55905. */
  55906. getDescription(): string;
  55907. /**
  55908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55909. * @param scene defines the current scene where to apply this optimization
  55910. * @param optimizer defines the current optimizer
  55911. * @returns true if everything that can be done was applied
  55912. */
  55913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55914. }
  55915. /**
  55916. * Defines an optimization used to merge meshes with compatible materials
  55917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55918. */
  55919. export class MergeMeshesOptimization extends SceneOptimization {
  55920. private static _UpdateSelectionTree;
  55921. /**
  55922. * Gets or sets a boolean which defines if optimization octree has to be updated
  55923. */
  55924. /**
  55925. * Gets or sets a boolean which defines if optimization octree has to be updated
  55926. */
  55927. static UpdateSelectionTree: boolean;
  55928. /**
  55929. * Gets a string describing the action executed by the current optimization
  55930. * @return description string
  55931. */
  55932. getDescription(): string;
  55933. private _canBeMerged;
  55934. /**
  55935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55936. * @param scene defines the current scene where to apply this optimization
  55937. * @param optimizer defines the current optimizer
  55938. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55939. * @returns true if everything that can be done was applied
  55940. */
  55941. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55942. }
  55943. /**
  55944. * Defines a list of options used by SceneOptimizer
  55945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55946. */
  55947. export class SceneOptimizerOptions {
  55948. /**
  55949. * Defines the target frame rate to reach (60 by default)
  55950. */
  55951. targetFrameRate: number;
  55952. /**
  55953. * Defines the interval between two checkes (2000ms by default)
  55954. */
  55955. trackerDuration: number;
  55956. /**
  55957. * Gets the list of optimizations to apply
  55958. */
  55959. optimizations: SceneOptimization[];
  55960. /**
  55961. * Creates a new list of options used by SceneOptimizer
  55962. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55963. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55964. */
  55965. constructor(
  55966. /**
  55967. * Defines the target frame rate to reach (60 by default)
  55968. */
  55969. targetFrameRate?: number,
  55970. /**
  55971. * Defines the interval between two checkes (2000ms by default)
  55972. */
  55973. trackerDuration?: number);
  55974. /**
  55975. * Add a new optimization
  55976. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55977. * @returns the current SceneOptimizerOptions
  55978. */
  55979. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55980. /**
  55981. * Add a new custom optimization
  55982. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55983. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55984. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55985. * @returns the current SceneOptimizerOptions
  55986. */
  55987. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55988. /**
  55989. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55990. * @param targetFrameRate defines the target frame rate (60 by default)
  55991. * @returns a SceneOptimizerOptions object
  55992. */
  55993. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55994. /**
  55995. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55996. * @param targetFrameRate defines the target frame rate (60 by default)
  55997. * @returns a SceneOptimizerOptions object
  55998. */
  55999. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56000. /**
  56001. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56002. * @param targetFrameRate defines the target frame rate (60 by default)
  56003. * @returns a SceneOptimizerOptions object
  56004. */
  56005. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56006. }
  56007. /**
  56008. * Class used to run optimizations in order to reach a target frame rate
  56009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56010. */
  56011. export class SceneOptimizer implements IDisposable {
  56012. private _isRunning;
  56013. private _options;
  56014. private _scene;
  56015. private _currentPriorityLevel;
  56016. private _targetFrameRate;
  56017. private _trackerDuration;
  56018. private _currentFrameRate;
  56019. private _sceneDisposeObserver;
  56020. private _improvementMode;
  56021. /**
  56022. * Defines an observable called when the optimizer reaches the target frame rate
  56023. */
  56024. onSuccessObservable: Observable<SceneOptimizer>;
  56025. /**
  56026. * Defines an observable called when the optimizer enables an optimization
  56027. */
  56028. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56029. /**
  56030. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56031. */
  56032. onFailureObservable: Observable<SceneOptimizer>;
  56033. /**
  56034. * Gets a boolean indicating if the optimizer is in improvement mode
  56035. */
  56036. readonly isInImprovementMode: boolean;
  56037. /**
  56038. * Gets the current priority level (0 at start)
  56039. */
  56040. readonly currentPriorityLevel: number;
  56041. /**
  56042. * Gets the current frame rate checked by the SceneOptimizer
  56043. */
  56044. readonly currentFrameRate: number;
  56045. /**
  56046. * Gets or sets the current target frame rate (60 by default)
  56047. */
  56048. /**
  56049. * Gets or sets the current target frame rate (60 by default)
  56050. */
  56051. targetFrameRate: number;
  56052. /**
  56053. * Gets or sets the current interval between two checks (every 2000ms by default)
  56054. */
  56055. /**
  56056. * Gets or sets the current interval between two checks (every 2000ms by default)
  56057. */
  56058. trackerDuration: number;
  56059. /**
  56060. * Gets the list of active optimizations
  56061. */
  56062. readonly optimizations: SceneOptimization[];
  56063. /**
  56064. * Creates a new SceneOptimizer
  56065. * @param scene defines the scene to work on
  56066. * @param options defines the options to use with the SceneOptimizer
  56067. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56068. * @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)
  56069. */
  56070. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56071. /**
  56072. * Stops the current optimizer
  56073. */
  56074. stop(): void;
  56075. /**
  56076. * Reset the optimizer to initial step (current priority level = 0)
  56077. */
  56078. reset(): void;
  56079. /**
  56080. * Start the optimizer. By default it will try to reach a specific framerate
  56081. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56082. */
  56083. start(): void;
  56084. private _checkCurrentState;
  56085. /**
  56086. * Release all resources
  56087. */
  56088. dispose(): void;
  56089. /**
  56090. * Helper function to create a SceneOptimizer with one single line of code
  56091. * @param scene defines the scene to work on
  56092. * @param options defines the options to use with the SceneOptimizer
  56093. * @param onSuccess defines a callback to call on success
  56094. * @param onFailure defines a callback to call on failure
  56095. * @returns the new SceneOptimizer object
  56096. */
  56097. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56098. }
  56099. }
  56100. declare module "babylonjs/Misc/sceneSerializer" {
  56101. import { Scene } from "babylonjs/scene";
  56102. /**
  56103. * Class used to serialize a scene into a string
  56104. */
  56105. export class SceneSerializer {
  56106. /**
  56107. * Clear cache used by a previous serialization
  56108. */
  56109. static ClearCache(): void;
  56110. /**
  56111. * Serialize a scene into a JSON compatible object
  56112. * @param scene defines the scene to serialize
  56113. * @returns a JSON compatible object
  56114. */
  56115. static Serialize(scene: Scene): any;
  56116. /**
  56117. * Serialize a mesh into a JSON compatible object
  56118. * @param toSerialize defines the mesh to serialize
  56119. * @param withParents defines if parents must be serialized as well
  56120. * @param withChildren defines if children must be serialized as well
  56121. * @returns a JSON compatible object
  56122. */
  56123. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56124. }
  56125. }
  56126. declare module "babylonjs/Misc/videoRecorder" {
  56127. import { Nullable } from "babylonjs/types";
  56128. import { Engine } from "babylonjs/Engines/engine";
  56129. /**
  56130. * This represents the different options avilable for the video capture.
  56131. */
  56132. export interface VideoRecorderOptions {
  56133. /** Defines the mime type of the video */
  56134. mimeType: string;
  56135. /** Defines the video the video should be recorded at */
  56136. fps: number;
  56137. /** Defines the chunk size for the recording data */
  56138. recordChunckSize: number;
  56139. }
  56140. /**
  56141. * This can helps recording videos from BabylonJS.
  56142. * This is based on the available WebRTC functionalities of the browser.
  56143. *
  56144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56145. */
  56146. export class VideoRecorder {
  56147. private static readonly _defaultOptions;
  56148. /**
  56149. * Returns wehther or not the VideoRecorder is available in your browser.
  56150. * @param engine Defines the Babylon Engine to check the support for
  56151. * @returns true if supported otherwise false
  56152. */
  56153. static IsSupported(engine: Engine): boolean;
  56154. private readonly _options;
  56155. private _canvas;
  56156. private _mediaRecorder;
  56157. private _recordedChunks;
  56158. private _fileName;
  56159. private _resolve;
  56160. private _reject;
  56161. /**
  56162. * True wether a recording is already in progress.
  56163. */
  56164. readonly isRecording: boolean;
  56165. /**
  56166. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56167. * a video file.
  56168. * @param engine Defines the BabylonJS Engine you wish to record
  56169. * @param options Defines options that can be used to customized the capture
  56170. */
  56171. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56172. /**
  56173. * Stops the current recording before the default capture timeout passed in the startRecording
  56174. * functions.
  56175. */
  56176. stopRecording(): void;
  56177. /**
  56178. * Starts recording the canvas for a max duration specified in parameters.
  56179. * @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.
  56180. * @param maxDuration Defines the maximum recording time in seconds.
  56181. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56182. * @return a promise callback at the end of the recording with the video data in Blob.
  56183. */
  56184. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56185. /**
  56186. * Releases internal resources used during the recording.
  56187. */
  56188. dispose(): void;
  56189. private _handleDataAvailable;
  56190. private _handleError;
  56191. private _handleStop;
  56192. }
  56193. }
  56194. declare module "babylonjs/Misc/workerPool" {
  56195. import { IDisposable } from "babylonjs/scene";
  56196. /**
  56197. * Helper class to push actions to a pool of workers.
  56198. */
  56199. export class WorkerPool implements IDisposable {
  56200. private _workerInfos;
  56201. private _pendingActions;
  56202. /**
  56203. * Constructor
  56204. * @param workers Array of workers to use for actions
  56205. */
  56206. constructor(workers: Array<Worker>);
  56207. /**
  56208. * Terminates all workers and clears any pending actions.
  56209. */
  56210. dispose(): void;
  56211. /**
  56212. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56213. * pended until a worker has completed its action.
  56214. * @param action The action to perform. Call onComplete when the action is complete.
  56215. */
  56216. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56217. private _execute;
  56218. }
  56219. }
  56220. declare module "babylonjs/Misc/screenshotTools" {
  56221. import { Camera } from "babylonjs/Cameras/camera";
  56222. import { Engine } from "babylonjs/Engines/engine";
  56223. /**
  56224. * Class containing a set of static utilities functions for screenshots
  56225. */
  56226. export class ScreenshotTools {
  56227. /**
  56228. * Captures a screenshot of the current rendering
  56229. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56230. * @param engine defines the rendering engine
  56231. * @param camera defines the source camera
  56232. * @param size This parameter can be set to a single number or to an object with the
  56233. * following (optional) properties: precision, width, height. If a single number is passed,
  56234. * it will be used for both width and height. If an object is passed, the screenshot size
  56235. * will be derived from the parameters. The precision property is a multiplier allowing
  56236. * rendering at a higher or lower resolution
  56237. * @param successCallback defines the callback receives a single parameter which contains the
  56238. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56239. * src parameter of an <img> to display it
  56240. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56241. * Check your browser for supported MIME types
  56242. */
  56243. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56244. /**
  56245. * Generates an image screenshot from the specified camera.
  56246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56247. * @param engine The engine to use for rendering
  56248. * @param camera The camera to use for rendering
  56249. * @param size This parameter can be set to a single number or to an object with the
  56250. * following (optional) properties: precision, width, height. If a single number is passed,
  56251. * it will be used for both width and height. If an object is passed, the screenshot size
  56252. * will be derived from the parameters. The precision property is a multiplier allowing
  56253. * rendering at a higher or lower resolution
  56254. * @param successCallback The callback receives a single parameter which contains the
  56255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56256. * src parameter of an <img> to display it
  56257. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56258. * Check your browser for supported MIME types
  56259. * @param samples Texture samples (default: 1)
  56260. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56261. * @param fileName A name for for the downloaded file.
  56262. */
  56263. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56264. }
  56265. }
  56266. declare module "babylonjs/Misc/index" {
  56267. export * from "babylonjs/Misc/andOrNotEvaluator";
  56268. export * from "babylonjs/Misc/assetsManager";
  56269. export * from "babylonjs/Misc/dds";
  56270. export * from "babylonjs/Misc/decorators";
  56271. export * from "babylonjs/Misc/deferred";
  56272. export * from "babylonjs/Misc/environmentTextureTools";
  56273. export * from "babylonjs/Misc/filesInput";
  56274. export * from "babylonjs/Misc/HighDynamicRange/index";
  56275. export * from "babylonjs/Misc/khronosTextureContainer";
  56276. export * from "babylonjs/Misc/observable";
  56277. export * from "babylonjs/Misc/performanceMonitor";
  56278. export * from "babylonjs/Misc/promise";
  56279. export * from "babylonjs/Misc/sceneOptimizer";
  56280. export * from "babylonjs/Misc/sceneSerializer";
  56281. export * from "babylonjs/Misc/smartArray";
  56282. export * from "babylonjs/Misc/stringDictionary";
  56283. export * from "babylonjs/Misc/tags";
  56284. export * from "babylonjs/Misc/textureTools";
  56285. export * from "babylonjs/Misc/tga";
  56286. export * from "babylonjs/Misc/tools";
  56287. export * from "babylonjs/Misc/videoRecorder";
  56288. export * from "babylonjs/Misc/virtualJoystick";
  56289. export * from "babylonjs/Misc/workerPool";
  56290. export * from "babylonjs/Misc/logger";
  56291. export * from "babylonjs/Misc/typeStore";
  56292. export * from "babylonjs/Misc/filesInputStore";
  56293. export * from "babylonjs/Misc/deepCopier";
  56294. export * from "babylonjs/Misc/pivotTools";
  56295. export * from "babylonjs/Misc/precisionDate";
  56296. export * from "babylonjs/Misc/screenshotTools";
  56297. export * from "babylonjs/Misc/typeStore";
  56298. }
  56299. declare module "babylonjs/index" {
  56300. export * from "babylonjs/abstractScene";
  56301. export * from "babylonjs/Actions/index";
  56302. export * from "babylonjs/Animations/index";
  56303. export * from "babylonjs/assetContainer";
  56304. export * from "babylonjs/Audio/index";
  56305. export * from "babylonjs/Behaviors/index";
  56306. export * from "babylonjs/Bones/index";
  56307. export * from "babylonjs/Cameras/index";
  56308. export * from "babylonjs/Collisions/index";
  56309. export * from "babylonjs/Culling/index";
  56310. export * from "babylonjs/Debug/index";
  56311. export * from "babylonjs/Engines/index";
  56312. export * from "babylonjs/Events/index";
  56313. export * from "babylonjs/Gamepads/index";
  56314. export * from "babylonjs/Gizmos/index";
  56315. export * from "babylonjs/Helpers/index";
  56316. export * from "babylonjs/Instrumentation/index";
  56317. export * from "babylonjs/Layers/index";
  56318. export * from "babylonjs/LensFlares/index";
  56319. export * from "babylonjs/Lights/index";
  56320. export * from "babylonjs/Loading/index";
  56321. export * from "babylonjs/Materials/index";
  56322. export * from "babylonjs/Maths/index";
  56323. export * from "babylonjs/Meshes/index";
  56324. export * from "babylonjs/Morph/index";
  56325. export * from "babylonjs/node";
  56326. export * from "babylonjs/Offline/index";
  56327. export * from "babylonjs/Particles/index";
  56328. export * from "babylonjs/Physics/index";
  56329. export * from "babylonjs/PostProcesses/index";
  56330. export * from "babylonjs/Probes/index";
  56331. export * from "babylonjs/Rendering/index";
  56332. export * from "babylonjs/scene";
  56333. export * from "babylonjs/sceneComponent";
  56334. export * from "babylonjs/Sprites/index";
  56335. export * from "babylonjs/States/index";
  56336. export * from "babylonjs/Misc/index";
  56337. export * from "babylonjs/types";
  56338. }
  56339. declare module "babylonjs/Animations/pathCursor" {
  56340. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56341. /**
  56342. * A cursor which tracks a point on a path
  56343. */
  56344. export class PathCursor {
  56345. private path;
  56346. /**
  56347. * Stores path cursor callbacks for when an onchange event is triggered
  56348. */
  56349. private _onchange;
  56350. /**
  56351. * The value of the path cursor
  56352. */
  56353. value: number;
  56354. /**
  56355. * The animation array of the path cursor
  56356. */
  56357. animations: Animation[];
  56358. /**
  56359. * Initializes the path cursor
  56360. * @param path The path to track
  56361. */
  56362. constructor(path: Path2);
  56363. /**
  56364. * Gets the cursor point on the path
  56365. * @returns A point on the path cursor at the cursor location
  56366. */
  56367. getPoint(): Vector3;
  56368. /**
  56369. * Moves the cursor ahead by the step amount
  56370. * @param step The amount to move the cursor forward
  56371. * @returns This path cursor
  56372. */
  56373. moveAhead(step?: number): PathCursor;
  56374. /**
  56375. * Moves the cursor behind by the step amount
  56376. * @param step The amount to move the cursor back
  56377. * @returns This path cursor
  56378. */
  56379. moveBack(step?: number): PathCursor;
  56380. /**
  56381. * Moves the cursor by the step amount
  56382. * If the step amount is greater than one, an exception is thrown
  56383. * @param step The amount to move the cursor
  56384. * @returns This path cursor
  56385. */
  56386. move(step: number): PathCursor;
  56387. /**
  56388. * Ensures that the value is limited between zero and one
  56389. * @returns This path cursor
  56390. */
  56391. private ensureLimits;
  56392. /**
  56393. * Runs onchange callbacks on change (used by the animation engine)
  56394. * @returns This path cursor
  56395. */
  56396. private raiseOnChange;
  56397. /**
  56398. * Executes a function on change
  56399. * @param f A path cursor onchange callback
  56400. * @returns This path cursor
  56401. */
  56402. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56403. }
  56404. }
  56405. declare module "babylonjs/Legacy/legacy" {
  56406. export * from "babylonjs/index";
  56407. }
  56408. declare module "babylonjs/Shaders/blur.fragment" {
  56409. /** @hidden */
  56410. export var blurPixelShader: {
  56411. name: string;
  56412. shader: string;
  56413. };
  56414. }
  56415. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56416. /** @hidden */
  56417. export var bones300Declaration: {
  56418. name: string;
  56419. shader: string;
  56420. };
  56421. }
  56422. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56423. /** @hidden */
  56424. export var instances300Declaration: {
  56425. name: string;
  56426. shader: string;
  56427. };
  56428. }
  56429. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56430. /** @hidden */
  56431. export var pointCloudVertexDeclaration: {
  56432. name: string;
  56433. shader: string;
  56434. };
  56435. }
  56436. // Mixins
  56437. interface Window {
  56438. mozIndexedDB: IDBFactory;
  56439. webkitIndexedDB: IDBFactory;
  56440. msIndexedDB: IDBFactory;
  56441. webkitURL: typeof URL;
  56442. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56443. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56444. WebGLRenderingContext: WebGLRenderingContext;
  56445. MSGesture: MSGesture;
  56446. CANNON: any;
  56447. AudioContext: AudioContext;
  56448. webkitAudioContext: AudioContext;
  56449. PointerEvent: any;
  56450. Math: Math;
  56451. Uint8Array: Uint8ArrayConstructor;
  56452. Float32Array: Float32ArrayConstructor;
  56453. mozURL: typeof URL;
  56454. msURL: typeof URL;
  56455. VRFrameData: any; // WebVR, from specs 1.1
  56456. DracoDecoderModule: any;
  56457. setImmediate(handler: (...args: any[]) => void): number;
  56458. }
  56459. interface Document {
  56460. mozCancelFullScreen(): void;
  56461. msCancelFullScreen(): void;
  56462. webkitCancelFullScreen(): void;
  56463. requestPointerLock(): void;
  56464. exitPointerLock(): void;
  56465. mozFullScreen: boolean;
  56466. msIsFullScreen: boolean;
  56467. readonly webkitIsFullScreen: boolean;
  56468. readonly pointerLockElement: Element;
  56469. mozPointerLockElement: HTMLElement;
  56470. msPointerLockElement: HTMLElement;
  56471. webkitPointerLockElement: HTMLElement;
  56472. }
  56473. interface HTMLCanvasElement {
  56474. requestPointerLock(): void;
  56475. msRequestPointerLock?(): void;
  56476. mozRequestPointerLock?(): void;
  56477. webkitRequestPointerLock?(): void;
  56478. /** Track wether a record is in progress */
  56479. isRecording: boolean;
  56480. /** Capture Stream method defined by some browsers */
  56481. captureStream(fps?: number): MediaStream;
  56482. }
  56483. interface CanvasRenderingContext2D {
  56484. msImageSmoothingEnabled: boolean;
  56485. }
  56486. interface MouseEvent {
  56487. mozMovementX: number;
  56488. mozMovementY: number;
  56489. webkitMovementX: number;
  56490. webkitMovementY: number;
  56491. msMovementX: number;
  56492. msMovementY: number;
  56493. }
  56494. interface Navigator {
  56495. mozGetVRDevices: (any: any) => any;
  56496. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56497. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56498. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56499. webkitGetGamepads(): Gamepad[];
  56500. msGetGamepads(): Gamepad[];
  56501. webkitGamepads(): Gamepad[];
  56502. }
  56503. interface HTMLVideoElement {
  56504. mozSrcObject: any;
  56505. }
  56506. interface Math {
  56507. fround(x: number): number;
  56508. imul(a: number, b: number): number;
  56509. }
  56510. interface WebGLProgram {
  56511. context?: WebGLRenderingContext;
  56512. vertexShader?: WebGLShader;
  56513. fragmentShader?: WebGLShader;
  56514. isParallelCompiled: boolean;
  56515. onCompiled?: () => void;
  56516. }
  56517. interface WebGLRenderingContext {
  56518. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56519. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56520. vertexAttribDivisor(index: number, divisor: number): void;
  56521. createVertexArray(): any;
  56522. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56523. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56524. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56525. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56526. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56527. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56528. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56529. // Queries
  56530. createQuery(): WebGLQuery;
  56531. deleteQuery(query: WebGLQuery): void;
  56532. beginQuery(target: number, query: WebGLQuery): void;
  56533. endQuery(target: number): void;
  56534. getQueryParameter(query: WebGLQuery, pname: number): any;
  56535. getQuery(target: number, pname: number): any;
  56536. MAX_SAMPLES: number;
  56537. RGBA8: number;
  56538. READ_FRAMEBUFFER: number;
  56539. DRAW_FRAMEBUFFER: number;
  56540. UNIFORM_BUFFER: number;
  56541. HALF_FLOAT_OES: number;
  56542. RGBA16F: number;
  56543. RGBA32F: number;
  56544. R32F: number;
  56545. RG32F: number;
  56546. RGB32F: number;
  56547. R16F: number;
  56548. RG16F: number;
  56549. RGB16F: number;
  56550. RED: number;
  56551. RG: number;
  56552. R8: number;
  56553. RG8: number;
  56554. UNSIGNED_INT_24_8: number;
  56555. DEPTH24_STENCIL8: number;
  56556. /* Multiple Render Targets */
  56557. drawBuffers(buffers: number[]): void;
  56558. readBuffer(src: number): void;
  56559. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56560. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56561. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56562. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56563. // Occlusion Query
  56564. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56565. ANY_SAMPLES_PASSED: number;
  56566. QUERY_RESULT_AVAILABLE: number;
  56567. QUERY_RESULT: number;
  56568. }
  56569. interface WebGLBuffer {
  56570. references: number;
  56571. capacity: number;
  56572. is32Bits: boolean;
  56573. }
  56574. interface WebGLProgram {
  56575. transformFeedback?: WebGLTransformFeedback | null;
  56576. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56577. }
  56578. interface EXT_disjoint_timer_query {
  56579. QUERY_COUNTER_BITS_EXT: number;
  56580. TIME_ELAPSED_EXT: number;
  56581. TIMESTAMP_EXT: number;
  56582. GPU_DISJOINT_EXT: number;
  56583. QUERY_RESULT_EXT: number;
  56584. QUERY_RESULT_AVAILABLE_EXT: number;
  56585. queryCounterEXT(query: WebGLQuery, target: number): void;
  56586. createQueryEXT(): WebGLQuery;
  56587. beginQueryEXT(target: number, query: WebGLQuery): void;
  56588. endQueryEXT(target: number): void;
  56589. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56590. deleteQueryEXT(query: WebGLQuery): void;
  56591. }
  56592. interface WebGLUniformLocation {
  56593. _currentState: any;
  56594. }
  56595. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56596. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56597. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56598. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56599. interface WebGLRenderingContext {
  56600. readonly RASTERIZER_DISCARD: number;
  56601. readonly DEPTH_COMPONENT24: number;
  56602. readonly TEXTURE_3D: number;
  56603. readonly TEXTURE_2D_ARRAY: number;
  56604. readonly TEXTURE_COMPARE_FUNC: number;
  56605. readonly TEXTURE_COMPARE_MODE: number;
  56606. readonly COMPARE_REF_TO_TEXTURE: number;
  56607. readonly TEXTURE_WRAP_R: number;
  56608. readonly HALF_FLOAT: number;
  56609. readonly RGB8: number;
  56610. readonly RED_INTEGER: number;
  56611. readonly RG_INTEGER: number;
  56612. readonly RGB_INTEGER: number;
  56613. readonly RGBA_INTEGER: number;
  56614. readonly R8_SNORM: number;
  56615. readonly RG8_SNORM: number;
  56616. readonly RGB8_SNORM: number;
  56617. readonly RGBA8_SNORM: number;
  56618. readonly R8I: number;
  56619. readonly RG8I: number;
  56620. readonly RGB8I: number;
  56621. readonly RGBA8I: number;
  56622. readonly R8UI: number;
  56623. readonly RG8UI: number;
  56624. readonly RGB8UI: number;
  56625. readonly RGBA8UI: number;
  56626. readonly R16I: number;
  56627. readonly RG16I: number;
  56628. readonly RGB16I: number;
  56629. readonly RGBA16I: number;
  56630. readonly R16UI: number;
  56631. readonly RG16UI: number;
  56632. readonly RGB16UI: number;
  56633. readonly RGBA16UI: number;
  56634. readonly R32I: number;
  56635. readonly RG32I: number;
  56636. readonly RGB32I: number;
  56637. readonly RGBA32I: number;
  56638. readonly R32UI: number;
  56639. readonly RG32UI: number;
  56640. readonly RGB32UI: number;
  56641. readonly RGBA32UI: number;
  56642. readonly RGB10_A2UI: number;
  56643. readonly R11F_G11F_B10F: number;
  56644. readonly RGB9_E5: number;
  56645. readonly RGB10_A2: number;
  56646. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56647. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56648. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56649. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56650. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56652. 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;
  56653. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56654. readonly TRANSFORM_FEEDBACK: number;
  56655. readonly INTERLEAVED_ATTRIBS: number;
  56656. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56657. createTransformFeedback(): WebGLTransformFeedback;
  56658. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56659. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56660. beginTransformFeedback(primitiveMode: number): void;
  56661. endTransformFeedback(): void;
  56662. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56663. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56664. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56665. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56666. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56667. }
  56668. interface ImageBitmap {
  56669. readonly width: number;
  56670. readonly height: number;
  56671. close(): void;
  56672. }
  56673. interface WebGLQuery extends WebGLObject {
  56674. }
  56675. declare var WebGLQuery: {
  56676. prototype: WebGLQuery;
  56677. new(): WebGLQuery;
  56678. };
  56679. interface WebGLSampler extends WebGLObject {
  56680. }
  56681. declare var WebGLSampler: {
  56682. prototype: WebGLSampler;
  56683. new(): WebGLSampler;
  56684. };
  56685. interface WebGLSync extends WebGLObject {
  56686. }
  56687. declare var WebGLSync: {
  56688. prototype: WebGLSync;
  56689. new(): WebGLSync;
  56690. };
  56691. interface WebGLTransformFeedback extends WebGLObject {
  56692. }
  56693. declare var WebGLTransformFeedback: {
  56694. prototype: WebGLTransformFeedback;
  56695. new(): WebGLTransformFeedback;
  56696. };
  56697. interface WebGLVertexArrayObject extends WebGLObject {
  56698. }
  56699. declare var WebGLVertexArrayObject: {
  56700. prototype: WebGLVertexArrayObject;
  56701. new(): WebGLVertexArrayObject;
  56702. };
  56703. // Type definitions for WebVR API
  56704. // Project: https://w3c.github.io/webvr/
  56705. // Definitions by: six a <https://github.com/lostfictions>
  56706. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56707. interface VRDisplay extends EventTarget {
  56708. /**
  56709. * Dictionary of capabilities describing the VRDisplay.
  56710. */
  56711. readonly capabilities: VRDisplayCapabilities;
  56712. /**
  56713. * z-depth defining the far plane of the eye view frustum
  56714. * enables mapping of values in the render target depth
  56715. * attachment to scene coordinates. Initially set to 10000.0.
  56716. */
  56717. depthFar: number;
  56718. /**
  56719. * z-depth defining the near plane of the eye view frustum
  56720. * enables mapping of values in the render target depth
  56721. * attachment to scene coordinates. Initially set to 0.01.
  56722. */
  56723. depthNear: number;
  56724. /**
  56725. * An identifier for this distinct VRDisplay. Used as an
  56726. * association point in the Gamepad API.
  56727. */
  56728. readonly displayId: number;
  56729. /**
  56730. * A display name, a user-readable name identifying it.
  56731. */
  56732. readonly displayName: string;
  56733. readonly isConnected: boolean;
  56734. readonly isPresenting: boolean;
  56735. /**
  56736. * If this VRDisplay supports room-scale experiences, the optional
  56737. * stage attribute contains details on the room-scale parameters.
  56738. */
  56739. readonly stageParameters: VRStageParameters | null;
  56740. /**
  56741. * Passing the value returned by `requestAnimationFrame` to
  56742. * `cancelAnimationFrame` will unregister the callback.
  56743. * @param handle Define the hanle of the request to cancel
  56744. */
  56745. cancelAnimationFrame(handle: number): void;
  56746. /**
  56747. * Stops presenting to the VRDisplay.
  56748. * @returns a promise to know when it stopped
  56749. */
  56750. exitPresent(): Promise<void>;
  56751. /**
  56752. * Return the current VREyeParameters for the given eye.
  56753. * @param whichEye Define the eye we want the parameter for
  56754. * @returns the eye parameters
  56755. */
  56756. getEyeParameters(whichEye: string): VREyeParameters;
  56757. /**
  56758. * Populates the passed VRFrameData with the information required to render
  56759. * the current frame.
  56760. * @param frameData Define the data structure to populate
  56761. * @returns true if ok otherwise false
  56762. */
  56763. getFrameData(frameData: VRFrameData): boolean;
  56764. /**
  56765. * Get the layers currently being presented.
  56766. * @returns the list of VR layers
  56767. */
  56768. getLayers(): VRLayer[];
  56769. /**
  56770. * Return a VRPose containing the future predicted pose of the VRDisplay
  56771. * when the current frame will be presented. The value returned will not
  56772. * change until JavaScript has returned control to the browser.
  56773. *
  56774. * The VRPose will contain the position, orientation, velocity,
  56775. * and acceleration of each of these properties.
  56776. * @returns the pose object
  56777. */
  56778. getPose(): VRPose;
  56779. /**
  56780. * Return the current instantaneous pose of the VRDisplay, with no
  56781. * prediction applied.
  56782. * @returns the current instantaneous pose
  56783. */
  56784. getImmediatePose(): VRPose;
  56785. /**
  56786. * The callback passed to `requestAnimationFrame` will be called
  56787. * any time a new frame should be rendered. When the VRDisplay is
  56788. * presenting the callback will be called at the native refresh
  56789. * rate of the HMD. When not presenting this function acts
  56790. * identically to how window.requestAnimationFrame acts. Content should
  56791. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56792. * asynchronously from other displays and at differing refresh rates.
  56793. * @param callback Define the eaction to run next frame
  56794. * @returns the request handle it
  56795. */
  56796. requestAnimationFrame(callback: FrameRequestCallback): number;
  56797. /**
  56798. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56799. * Repeat calls while already presenting will update the VRLayers being displayed.
  56800. * @param layers Define the list of layer to present
  56801. * @returns a promise to know when the request has been fulfilled
  56802. */
  56803. requestPresent(layers: VRLayer[]): Promise<void>;
  56804. /**
  56805. * Reset the pose for this display, treating its current position and
  56806. * orientation as the "origin/zero" values. VRPose.position,
  56807. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56808. * updated when calling resetPose(). This should be called in only
  56809. * sitting-space experiences.
  56810. */
  56811. resetPose(): void;
  56812. /**
  56813. * The VRLayer provided to the VRDisplay will be captured and presented
  56814. * in the HMD. Calling this function has the same effect on the source
  56815. * canvas as any other operation that uses its source image, and canvases
  56816. * created without preserveDrawingBuffer set to true will be cleared.
  56817. * @param pose Define the pose to submit
  56818. */
  56819. submitFrame(pose?: VRPose): void;
  56820. }
  56821. declare var VRDisplay: {
  56822. prototype: VRDisplay;
  56823. new(): VRDisplay;
  56824. };
  56825. interface VRLayer {
  56826. leftBounds?: number[] | Float32Array | null;
  56827. rightBounds?: number[] | Float32Array | null;
  56828. source?: HTMLCanvasElement | null;
  56829. }
  56830. interface VRDisplayCapabilities {
  56831. readonly canPresent: boolean;
  56832. readonly hasExternalDisplay: boolean;
  56833. readonly hasOrientation: boolean;
  56834. readonly hasPosition: boolean;
  56835. readonly maxLayers: number;
  56836. }
  56837. interface VREyeParameters {
  56838. /** @deprecated */
  56839. readonly fieldOfView: VRFieldOfView;
  56840. readonly offset: Float32Array;
  56841. readonly renderHeight: number;
  56842. readonly renderWidth: number;
  56843. }
  56844. interface VRFieldOfView {
  56845. readonly downDegrees: number;
  56846. readonly leftDegrees: number;
  56847. readonly rightDegrees: number;
  56848. readonly upDegrees: number;
  56849. }
  56850. interface VRFrameData {
  56851. readonly leftProjectionMatrix: Float32Array;
  56852. readonly leftViewMatrix: Float32Array;
  56853. readonly pose: VRPose;
  56854. readonly rightProjectionMatrix: Float32Array;
  56855. readonly rightViewMatrix: Float32Array;
  56856. readonly timestamp: number;
  56857. }
  56858. interface VRPose {
  56859. readonly angularAcceleration: Float32Array | null;
  56860. readonly angularVelocity: Float32Array | null;
  56861. readonly linearAcceleration: Float32Array | null;
  56862. readonly linearVelocity: Float32Array | null;
  56863. readonly orientation: Float32Array | null;
  56864. readonly position: Float32Array | null;
  56865. readonly timestamp: number;
  56866. }
  56867. interface VRStageParameters {
  56868. sittingToStandingTransform?: Float32Array;
  56869. sizeX?: number;
  56870. sizeY?: number;
  56871. }
  56872. interface Navigator {
  56873. getVRDisplays(): Promise<VRDisplay[]>;
  56874. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56875. }
  56876. interface Window {
  56877. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56878. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56879. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56880. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56881. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56882. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56883. }
  56884. interface Gamepad {
  56885. readonly displayId: number;
  56886. }
  56887. interface XRDevice {
  56888. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56889. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56890. }
  56891. interface XRSession {
  56892. getInputSources(): Array<any>;
  56893. baseLayer: XRWebGLLayer;
  56894. requestFrameOfReference(type: string): Promise<void>;
  56895. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56896. end(): Promise<void>;
  56897. requestAnimationFrame: Function;
  56898. addEventListener: Function;
  56899. }
  56900. interface XRSessionCreationOptions {
  56901. outputContext?: WebGLRenderingContext | null;
  56902. immersive?: boolean;
  56903. environmentIntegration?: boolean;
  56904. }
  56905. interface XRLayer {
  56906. getViewport: Function;
  56907. framebufferWidth: number;
  56908. framebufferHeight: number;
  56909. }
  56910. interface XRView {
  56911. projectionMatrix: Float32Array;
  56912. }
  56913. interface XRFrame {
  56914. getDevicePose: Function;
  56915. getInputPose: Function;
  56916. views: Array<XRView>;
  56917. baseLayer: XRLayer;
  56918. }
  56919. interface XRFrameOfReference {
  56920. }
  56921. interface XRWebGLLayer extends XRLayer {
  56922. framebuffer: WebGLFramebuffer;
  56923. }
  56924. declare var XRWebGLLayer: {
  56925. prototype: XRWebGLLayer;
  56926. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56927. };
  56928. declare module "babylonjs" {
  56929. export * from "babylonjs/Legacy/legacy";
  56930. }
  56931. declare module BABYLON {
  56932. /** Alias type for value that can be null */
  56933. export type Nullable<T> = T | null;
  56934. /**
  56935. * Alias type for number that are floats
  56936. * @ignorenaming
  56937. */
  56938. export type float = number;
  56939. /**
  56940. * Alias type for number that are doubles.
  56941. * @ignorenaming
  56942. */
  56943. export type double = number;
  56944. /**
  56945. * Alias type for number that are integer
  56946. * @ignorenaming
  56947. */
  56948. export type int = number;
  56949. /** Alias type for number array or Float32Array */
  56950. export type FloatArray = number[] | Float32Array;
  56951. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56952. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56953. /**
  56954. * Alias for types that can be used by a Buffer or VertexBuffer.
  56955. */
  56956. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56957. /**
  56958. * Alias type for primitive types
  56959. * @ignorenaming
  56960. */
  56961. type Primitive = undefined | null | boolean | string | number | Function;
  56962. /**
  56963. * Type modifier to make all the properties of an object Readonly
  56964. */
  56965. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56966. /**
  56967. * Type modifier to make all the properties of an object Readonly recursively
  56968. */
  56969. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56970. /** @hidden */
  56971. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56972. }
  56973. /** @hidden */
  56974. /** @hidden */
  56975. type DeepImmutableObject<T> = {
  56976. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56977. };
  56978. }
  56979. declare module BABYLON {
  56980. /**
  56981. * Class containing a set of static utilities functions for arrays.
  56982. */
  56983. export class ArrayTools {
  56984. /**
  56985. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56986. * @param size the number of element to construct and put in the array
  56987. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56988. * @returns a new array filled with new objects
  56989. */
  56990. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56991. }
  56992. }
  56993. declare module BABYLON {
  56994. /**
  56995. * Scalar computation library
  56996. */
  56997. export class Scalar {
  56998. /**
  56999. * Two pi constants convenient for computation.
  57000. */
  57001. static TwoPi: number;
  57002. /**
  57003. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57004. * @param a number
  57005. * @param b number
  57006. * @param epsilon (default = 1.401298E-45)
  57007. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57008. */
  57009. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57010. /**
  57011. * Returns a string : the upper case translation of the number i to hexadecimal.
  57012. * @param i number
  57013. * @returns the upper case translation of the number i to hexadecimal.
  57014. */
  57015. static ToHex(i: number): string;
  57016. /**
  57017. * Returns -1 if value is negative and +1 is value is positive.
  57018. * @param value the value
  57019. * @returns the value itself if it's equal to zero.
  57020. */
  57021. static Sign(value: number): number;
  57022. /**
  57023. * Returns the value itself if it's between min and max.
  57024. * Returns min if the value is lower than min.
  57025. * Returns max if the value is greater than max.
  57026. * @param value the value to clmap
  57027. * @param min the min value to clamp to (default: 0)
  57028. * @param max the max value to clamp to (default: 1)
  57029. * @returns the clamped value
  57030. */
  57031. static Clamp(value: number, min?: number, max?: number): number;
  57032. /**
  57033. * the log2 of value.
  57034. * @param value the value to compute log2 of
  57035. * @returns the log2 of value.
  57036. */
  57037. static Log2(value: number): number;
  57038. /**
  57039. * Loops the value, so that it is never larger than length and never smaller than 0.
  57040. *
  57041. * This is similar to the modulo operator but it works with floating point numbers.
  57042. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57043. * With t = 5 and length = 2.5, the result would be 0.0.
  57044. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57045. * @param value the value
  57046. * @param length the length
  57047. * @returns the looped value
  57048. */
  57049. static Repeat(value: number, length: number): number;
  57050. /**
  57051. * Normalize the value between 0.0 and 1.0 using min and max values
  57052. * @param value value to normalize
  57053. * @param min max to normalize between
  57054. * @param max min to normalize between
  57055. * @returns the normalized value
  57056. */
  57057. static Normalize(value: number, min: number, max: number): number;
  57058. /**
  57059. * Denormalize the value from 0.0 and 1.0 using min and max values
  57060. * @param normalized value to denormalize
  57061. * @param min max to denormalize between
  57062. * @param max min to denormalize between
  57063. * @returns the denormalized value
  57064. */
  57065. static Denormalize(normalized: number, min: number, max: number): number;
  57066. /**
  57067. * Calculates the shortest difference between two given angles given in degrees.
  57068. * @param current current angle in degrees
  57069. * @param target target angle in degrees
  57070. * @returns the delta
  57071. */
  57072. static DeltaAngle(current: number, target: number): number;
  57073. /**
  57074. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57075. * @param tx value
  57076. * @param length length
  57077. * @returns The returned value will move back and forth between 0 and length
  57078. */
  57079. static PingPong(tx: number, length: number): number;
  57080. /**
  57081. * Interpolates between min and max with smoothing at the limits.
  57082. *
  57083. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57084. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57085. * @param from from
  57086. * @param to to
  57087. * @param tx value
  57088. * @returns the smooth stepped value
  57089. */
  57090. static SmoothStep(from: number, to: number, tx: number): number;
  57091. /**
  57092. * Moves a value current towards target.
  57093. *
  57094. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57095. * Negative values of maxDelta pushes the value away from target.
  57096. * @param current current value
  57097. * @param target target value
  57098. * @param maxDelta max distance to move
  57099. * @returns resulting value
  57100. */
  57101. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57102. /**
  57103. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57104. *
  57105. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57106. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57107. * @param current current value
  57108. * @param target target value
  57109. * @param maxDelta max distance to move
  57110. * @returns resulting angle
  57111. */
  57112. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57113. /**
  57114. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57115. * @param start start value
  57116. * @param end target value
  57117. * @param amount amount to lerp between
  57118. * @returns the lerped value
  57119. */
  57120. static Lerp(start: number, end: number, amount: number): number;
  57121. /**
  57122. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57123. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57124. * @param start start value
  57125. * @param end target value
  57126. * @param amount amount to lerp between
  57127. * @returns the lerped value
  57128. */
  57129. static LerpAngle(start: number, end: number, amount: number): number;
  57130. /**
  57131. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57132. * @param a start value
  57133. * @param b target value
  57134. * @param value value between a and b
  57135. * @returns the inverseLerp value
  57136. */
  57137. static InverseLerp(a: number, b: number, value: number): number;
  57138. /**
  57139. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57140. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57141. * @param value1 spline value
  57142. * @param tangent1 spline value
  57143. * @param value2 spline value
  57144. * @param tangent2 spline value
  57145. * @param amount input value
  57146. * @returns hermite result
  57147. */
  57148. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57149. /**
  57150. * Returns a random float number between and min and max values
  57151. * @param min min value of random
  57152. * @param max max value of random
  57153. * @returns random value
  57154. */
  57155. static RandomRange(min: number, max: number): number;
  57156. /**
  57157. * This function returns percentage of a number in a given range.
  57158. *
  57159. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57160. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57161. * @param number to convert to percentage
  57162. * @param min min range
  57163. * @param max max range
  57164. * @returns the percentage
  57165. */
  57166. static RangeToPercent(number: number, min: number, max: number): number;
  57167. /**
  57168. * This function returns number that corresponds to the percentage in a given range.
  57169. *
  57170. * PercentToRange(0.34,0,100) will return 34.
  57171. * @param percent to convert to number
  57172. * @param min min range
  57173. * @param max max range
  57174. * @returns the number
  57175. */
  57176. static PercentToRange(percent: number, min: number, max: number): number;
  57177. /**
  57178. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57179. * @param angle The angle to normalize in radian.
  57180. * @return The converted angle.
  57181. */
  57182. static NormalizeRadians(angle: number): number;
  57183. }
  57184. }
  57185. declare module BABYLON {
  57186. /**
  57187. * Constant used to convert a value to gamma space
  57188. * @ignorenaming
  57189. */
  57190. export const ToGammaSpace: number;
  57191. /**
  57192. * Constant used to convert a value to linear space
  57193. * @ignorenaming
  57194. */
  57195. export const ToLinearSpace = 2.2;
  57196. /**
  57197. * Constant used to define the minimal number value in Babylon.js
  57198. * @ignorenaming
  57199. */
  57200. export const Epsilon = 0.001;
  57201. /**
  57202. * Class used to hold a RBG color
  57203. */
  57204. export class Color3 {
  57205. /**
  57206. * Defines the red component (between 0 and 1, default is 0)
  57207. */
  57208. r: number;
  57209. /**
  57210. * Defines the green component (between 0 and 1, default is 0)
  57211. */
  57212. g: number;
  57213. /**
  57214. * Defines the blue component (between 0 and 1, default is 0)
  57215. */
  57216. b: number;
  57217. /**
  57218. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57219. * @param r defines the red component (between 0 and 1, default is 0)
  57220. * @param g defines the green component (between 0 and 1, default is 0)
  57221. * @param b defines the blue component (between 0 and 1, default is 0)
  57222. */
  57223. constructor(
  57224. /**
  57225. * Defines the red component (between 0 and 1, default is 0)
  57226. */
  57227. r?: number,
  57228. /**
  57229. * Defines the green component (between 0 and 1, default is 0)
  57230. */
  57231. g?: number,
  57232. /**
  57233. * Defines the blue component (between 0 and 1, default is 0)
  57234. */
  57235. b?: number);
  57236. /**
  57237. * Creates a string with the Color3 current values
  57238. * @returns the string representation of the Color3 object
  57239. */
  57240. toString(): string;
  57241. /**
  57242. * Returns the string "Color3"
  57243. * @returns "Color3"
  57244. */
  57245. getClassName(): string;
  57246. /**
  57247. * Compute the Color3 hash code
  57248. * @returns an unique number that can be used to hash Color3 objects
  57249. */
  57250. getHashCode(): number;
  57251. /**
  57252. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57253. * @param array defines the array where to store the r,g,b components
  57254. * @param index defines an optional index in the target array to define where to start storing values
  57255. * @returns the current Color3 object
  57256. */
  57257. toArray(array: FloatArray, index?: number): Color3;
  57258. /**
  57259. * Returns a new Color4 object from the current Color3 and the given alpha
  57260. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57261. * @returns a new Color4 object
  57262. */
  57263. toColor4(alpha?: number): Color4;
  57264. /**
  57265. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57266. * @returns the new array
  57267. */
  57268. asArray(): number[];
  57269. /**
  57270. * Returns the luminance value
  57271. * @returns a float value
  57272. */
  57273. toLuminance(): number;
  57274. /**
  57275. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57276. * @param otherColor defines the second operand
  57277. * @returns the new Color3 object
  57278. */
  57279. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57280. /**
  57281. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57282. * @param otherColor defines the second operand
  57283. * @param result defines the Color3 object where to store the result
  57284. * @returns the current Color3
  57285. */
  57286. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57287. /**
  57288. * Determines equality between Color3 objects
  57289. * @param otherColor defines the second operand
  57290. * @returns true if the rgb values are equal to the given ones
  57291. */
  57292. equals(otherColor: DeepImmutable<Color3>): boolean;
  57293. /**
  57294. * Determines equality between the current Color3 object and a set of r,b,g values
  57295. * @param r defines the red component to check
  57296. * @param g defines the green component to check
  57297. * @param b defines the blue component to check
  57298. * @returns true if the rgb values are equal to the given ones
  57299. */
  57300. equalsFloats(r: number, g: number, b: number): boolean;
  57301. /**
  57302. * Multiplies in place each rgb value by scale
  57303. * @param scale defines the scaling factor
  57304. * @returns the updated Color3
  57305. */
  57306. scale(scale: number): Color3;
  57307. /**
  57308. * Multiplies the rgb values by scale and stores the result into "result"
  57309. * @param scale defines the scaling factor
  57310. * @param result defines the Color3 object where to store the result
  57311. * @returns the unmodified current Color3
  57312. */
  57313. scaleToRef(scale: number, result: Color3): Color3;
  57314. /**
  57315. * Scale the current Color3 values by a factor and add the result to a given Color3
  57316. * @param scale defines the scale factor
  57317. * @param result defines color to store the result into
  57318. * @returns the unmodified current Color3
  57319. */
  57320. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57321. /**
  57322. * Clamps the rgb values by the min and max values and stores the result into "result"
  57323. * @param min defines minimum clamping value (default is 0)
  57324. * @param max defines maximum clamping value (default is 1)
  57325. * @param result defines color to store the result into
  57326. * @returns the original Color3
  57327. */
  57328. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57329. /**
  57330. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57331. * @param otherColor defines the second operand
  57332. * @returns the new Color3
  57333. */
  57334. add(otherColor: DeepImmutable<Color3>): Color3;
  57335. /**
  57336. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57337. * @param otherColor defines the second operand
  57338. * @param result defines Color3 object to store the result into
  57339. * @returns the unmodified current Color3
  57340. */
  57341. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57342. /**
  57343. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57344. * @param otherColor defines the second operand
  57345. * @returns the new Color3
  57346. */
  57347. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57348. /**
  57349. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57350. * @param otherColor defines the second operand
  57351. * @param result defines Color3 object to store the result into
  57352. * @returns the unmodified current Color3
  57353. */
  57354. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57355. /**
  57356. * Copy the current object
  57357. * @returns a new Color3 copied the current one
  57358. */
  57359. clone(): Color3;
  57360. /**
  57361. * Copies the rgb values from the source in the current Color3
  57362. * @param source defines the source Color3 object
  57363. * @returns the updated Color3 object
  57364. */
  57365. copyFrom(source: DeepImmutable<Color3>): Color3;
  57366. /**
  57367. * Updates the Color3 rgb values from the given floats
  57368. * @param r defines the red component to read from
  57369. * @param g defines the green component to read from
  57370. * @param b defines the blue component to read from
  57371. * @returns the current Color3 object
  57372. */
  57373. copyFromFloats(r: number, g: number, b: number): Color3;
  57374. /**
  57375. * Updates the Color3 rgb values from the given floats
  57376. * @param r defines the red component to read from
  57377. * @param g defines the green component to read from
  57378. * @param b defines the blue component to read from
  57379. * @returns the current Color3 object
  57380. */
  57381. set(r: number, g: number, b: number): Color3;
  57382. /**
  57383. * Compute the Color3 hexadecimal code as a string
  57384. * @returns a string containing the hexadecimal representation of the Color3 object
  57385. */
  57386. toHexString(): string;
  57387. /**
  57388. * Computes a new Color3 converted from the current one to linear space
  57389. * @returns a new Color3 object
  57390. */
  57391. toLinearSpace(): Color3;
  57392. /**
  57393. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57394. * @param convertedColor defines the Color3 object where to store the linear space version
  57395. * @returns the unmodified Color3
  57396. */
  57397. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57398. /**
  57399. * Computes a new Color3 converted from the current one to gamma space
  57400. * @returns a new Color3 object
  57401. */
  57402. toGammaSpace(): Color3;
  57403. /**
  57404. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57405. * @param convertedColor defines the Color3 object where to store the gamma space version
  57406. * @returns the unmodified Color3
  57407. */
  57408. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57409. private static _BlackReadOnly;
  57410. /**
  57411. * Creates a new Color3 from the string containing valid hexadecimal values
  57412. * @param hex defines a string containing valid hexadecimal values
  57413. * @returns a new Color3 object
  57414. */
  57415. static FromHexString(hex: string): Color3;
  57416. /**
  57417. * Creates a new Vector3 from the starting index of the given array
  57418. * @param array defines the source array
  57419. * @param offset defines an offset in the source array
  57420. * @returns a new Color3 object
  57421. */
  57422. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57423. /**
  57424. * Creates a new Color3 from integer values (< 256)
  57425. * @param r defines the red component to read from (value between 0 and 255)
  57426. * @param g defines the green component to read from (value between 0 and 255)
  57427. * @param b defines the blue component to read from (value between 0 and 255)
  57428. * @returns a new Color3 object
  57429. */
  57430. static FromInts(r: number, g: number, b: number): Color3;
  57431. /**
  57432. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57433. * @param start defines the start Color3 value
  57434. * @param end defines the end Color3 value
  57435. * @param amount defines the gradient value between start and end
  57436. * @returns a new Color3 object
  57437. */
  57438. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57439. /**
  57440. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57441. * @param left defines the start value
  57442. * @param right defines the end value
  57443. * @param amount defines the gradient factor
  57444. * @param result defines the Color3 object where to store the result
  57445. */
  57446. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57447. /**
  57448. * Returns a Color3 value containing a red color
  57449. * @returns a new Color3 object
  57450. */
  57451. static Red(): Color3;
  57452. /**
  57453. * Returns a Color3 value containing a green color
  57454. * @returns a new Color3 object
  57455. */
  57456. static Green(): Color3;
  57457. /**
  57458. * Returns a Color3 value containing a blue color
  57459. * @returns a new Color3 object
  57460. */
  57461. static Blue(): Color3;
  57462. /**
  57463. * Returns a Color3 value containing a black color
  57464. * @returns a new Color3 object
  57465. */
  57466. static Black(): Color3;
  57467. /**
  57468. * Gets a Color3 value containing a black color that must not be updated
  57469. */
  57470. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57471. /**
  57472. * Returns a Color3 value containing a white color
  57473. * @returns a new Color3 object
  57474. */
  57475. static White(): Color3;
  57476. /**
  57477. * Returns a Color3 value containing a purple color
  57478. * @returns a new Color3 object
  57479. */
  57480. static Purple(): Color3;
  57481. /**
  57482. * Returns a Color3 value containing a magenta color
  57483. * @returns a new Color3 object
  57484. */
  57485. static Magenta(): Color3;
  57486. /**
  57487. * Returns a Color3 value containing a yellow color
  57488. * @returns a new Color3 object
  57489. */
  57490. static Yellow(): Color3;
  57491. /**
  57492. * Returns a Color3 value containing a gray color
  57493. * @returns a new Color3 object
  57494. */
  57495. static Gray(): Color3;
  57496. /**
  57497. * Returns a Color3 value containing a teal color
  57498. * @returns a new Color3 object
  57499. */
  57500. static Teal(): Color3;
  57501. /**
  57502. * Returns a Color3 value containing a random color
  57503. * @returns a new Color3 object
  57504. */
  57505. static Random(): Color3;
  57506. }
  57507. /**
  57508. * Class used to hold a RBGA color
  57509. */
  57510. export class Color4 {
  57511. /**
  57512. * Defines the red component (between 0 and 1, default is 0)
  57513. */
  57514. r: number;
  57515. /**
  57516. * Defines the green component (between 0 and 1, default is 0)
  57517. */
  57518. g: number;
  57519. /**
  57520. * Defines the blue component (between 0 and 1, default is 0)
  57521. */
  57522. b: number;
  57523. /**
  57524. * Defines the alpha component (between 0 and 1, default is 1)
  57525. */
  57526. a: number;
  57527. /**
  57528. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57529. * @param r defines the red component (between 0 and 1, default is 0)
  57530. * @param g defines the green component (between 0 and 1, default is 0)
  57531. * @param b defines the blue component (between 0 and 1, default is 0)
  57532. * @param a defines the alpha component (between 0 and 1, default is 1)
  57533. */
  57534. constructor(
  57535. /**
  57536. * Defines the red component (between 0 and 1, default is 0)
  57537. */
  57538. r?: number,
  57539. /**
  57540. * Defines the green component (between 0 and 1, default is 0)
  57541. */
  57542. g?: number,
  57543. /**
  57544. * Defines the blue component (between 0 and 1, default is 0)
  57545. */
  57546. b?: number,
  57547. /**
  57548. * Defines the alpha component (between 0 and 1, default is 1)
  57549. */
  57550. a?: number);
  57551. /**
  57552. * Adds in place the given Color4 values to the current Color4 object
  57553. * @param right defines the second operand
  57554. * @returns the current updated Color4 object
  57555. */
  57556. addInPlace(right: DeepImmutable<Color4>): Color4;
  57557. /**
  57558. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57559. * @returns the new array
  57560. */
  57561. asArray(): number[];
  57562. /**
  57563. * Stores from the starting index in the given array the Color4 successive values
  57564. * @param array defines the array where to store the r,g,b components
  57565. * @param index defines an optional index in the target array to define where to start storing values
  57566. * @returns the current Color4 object
  57567. */
  57568. toArray(array: number[], index?: number): Color4;
  57569. /**
  57570. * Determines equality between Color4 objects
  57571. * @param otherColor defines the second operand
  57572. * @returns true if the rgba values are equal to the given ones
  57573. */
  57574. equals(otherColor: DeepImmutable<Color4>): boolean;
  57575. /**
  57576. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57577. * @param right defines the second operand
  57578. * @returns a new Color4 object
  57579. */
  57580. add(right: DeepImmutable<Color4>): Color4;
  57581. /**
  57582. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57583. * @param right defines the second operand
  57584. * @returns a new Color4 object
  57585. */
  57586. subtract(right: DeepImmutable<Color4>): Color4;
  57587. /**
  57588. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57589. * @param right defines the second operand
  57590. * @param result defines the Color4 object where to store the result
  57591. * @returns the current Color4 object
  57592. */
  57593. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57594. /**
  57595. * Creates a new Color4 with the current Color4 values multiplied by scale
  57596. * @param scale defines the scaling factor to apply
  57597. * @returns a new Color4 object
  57598. */
  57599. scale(scale: number): Color4;
  57600. /**
  57601. * Multiplies the current Color4 values by scale and stores the result in "result"
  57602. * @param scale defines the scaling factor to apply
  57603. * @param result defines the Color4 object where to store the result
  57604. * @returns the current unmodified Color4
  57605. */
  57606. scaleToRef(scale: number, result: Color4): Color4;
  57607. /**
  57608. * Scale the current Color4 values by a factor and add the result to a given Color4
  57609. * @param scale defines the scale factor
  57610. * @param result defines the Color4 object where to store the result
  57611. * @returns the unmodified current Color4
  57612. */
  57613. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57614. /**
  57615. * Clamps the rgb values by the min and max values and stores the result into "result"
  57616. * @param min defines minimum clamping value (default is 0)
  57617. * @param max defines maximum clamping value (default is 1)
  57618. * @param result defines color to store the result into.
  57619. * @returns the cuurent Color4
  57620. */
  57621. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57622. /**
  57623. * Multipy an Color4 value by another and return a new Color4 object
  57624. * @param color defines the Color4 value to multiply by
  57625. * @returns a new Color4 object
  57626. */
  57627. multiply(color: Color4): Color4;
  57628. /**
  57629. * Multipy a Color4 value by another and push the result in a reference value
  57630. * @param color defines the Color4 value to multiply by
  57631. * @param result defines the Color4 to fill the result in
  57632. * @returns the result Color4
  57633. */
  57634. multiplyToRef(color: Color4, result: Color4): Color4;
  57635. /**
  57636. * Creates a string with the Color4 current values
  57637. * @returns the string representation of the Color4 object
  57638. */
  57639. toString(): string;
  57640. /**
  57641. * Returns the string "Color4"
  57642. * @returns "Color4"
  57643. */
  57644. getClassName(): string;
  57645. /**
  57646. * Compute the Color4 hash code
  57647. * @returns an unique number that can be used to hash Color4 objects
  57648. */
  57649. getHashCode(): number;
  57650. /**
  57651. * Creates a new Color4 copied from the current one
  57652. * @returns a new Color4 object
  57653. */
  57654. clone(): Color4;
  57655. /**
  57656. * Copies the given Color4 values into the current one
  57657. * @param source defines the source Color4 object
  57658. * @returns the current updated Color4 object
  57659. */
  57660. copyFrom(source: Color4): Color4;
  57661. /**
  57662. * Copies the given float values into the current one
  57663. * @param r defines the red component to read from
  57664. * @param g defines the green component to read from
  57665. * @param b defines the blue component to read from
  57666. * @param a defines the alpha component to read from
  57667. * @returns the current updated Color4 object
  57668. */
  57669. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57670. /**
  57671. * Copies the given float values into the current one
  57672. * @param r defines the red component to read from
  57673. * @param g defines the green component to read from
  57674. * @param b defines the blue component to read from
  57675. * @param a defines the alpha component to read from
  57676. * @returns the current updated Color4 object
  57677. */
  57678. set(r: number, g: number, b: number, a: number): Color4;
  57679. /**
  57680. * Compute the Color4 hexadecimal code as a string
  57681. * @returns a string containing the hexadecimal representation of the Color4 object
  57682. */
  57683. toHexString(): string;
  57684. /**
  57685. * Computes a new Color4 converted from the current one to linear space
  57686. * @returns a new Color4 object
  57687. */
  57688. toLinearSpace(): Color4;
  57689. /**
  57690. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57691. * @param convertedColor defines the Color4 object where to store the linear space version
  57692. * @returns the unmodified Color4
  57693. */
  57694. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57695. /**
  57696. * Computes a new Color4 converted from the current one to gamma space
  57697. * @returns a new Color4 object
  57698. */
  57699. toGammaSpace(): Color4;
  57700. /**
  57701. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57702. * @param convertedColor defines the Color4 object where to store the gamma space version
  57703. * @returns the unmodified Color4
  57704. */
  57705. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57706. /**
  57707. * Creates a new Color4 from the string containing valid hexadecimal values
  57708. * @param hex defines a string containing valid hexadecimal values
  57709. * @returns a new Color4 object
  57710. */
  57711. static FromHexString(hex: string): Color4;
  57712. /**
  57713. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57714. * @param left defines the start value
  57715. * @param right defines the end value
  57716. * @param amount defines the gradient factor
  57717. * @returns a new Color4 object
  57718. */
  57719. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57720. /**
  57721. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57722. * @param left defines the start value
  57723. * @param right defines the end value
  57724. * @param amount defines the gradient factor
  57725. * @param result defines the Color4 object where to store data
  57726. */
  57727. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57728. /**
  57729. * Creates a new Color4 from a Color3 and an alpha value
  57730. * @param color3 defines the source Color3 to read from
  57731. * @param alpha defines the alpha component (1.0 by default)
  57732. * @returns a new Color4 object
  57733. */
  57734. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57735. /**
  57736. * Creates a new Color4 from the starting index element of the given array
  57737. * @param array defines the source array to read from
  57738. * @param offset defines the offset in the source array
  57739. * @returns a new Color4 object
  57740. */
  57741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57742. /**
  57743. * Creates a new Color3 from integer values (< 256)
  57744. * @param r defines the red component to read from (value between 0 and 255)
  57745. * @param g defines the green component to read from (value between 0 and 255)
  57746. * @param b defines the blue component to read from (value between 0 and 255)
  57747. * @param a defines the alpha component to read from (value between 0 and 255)
  57748. * @returns a new Color3 object
  57749. */
  57750. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57751. /**
  57752. * Check the content of a given array and convert it to an array containing RGBA data
  57753. * If the original array was already containing count * 4 values then it is returned directly
  57754. * @param colors defines the array to check
  57755. * @param count defines the number of RGBA data to expect
  57756. * @returns an array containing count * 4 values (RGBA)
  57757. */
  57758. static CheckColors4(colors: number[], count: number): number[];
  57759. }
  57760. /**
  57761. * Class representing a vector containing 2 coordinates
  57762. */
  57763. export class Vector2 {
  57764. /** defines the first coordinate */
  57765. x: number;
  57766. /** defines the second coordinate */
  57767. y: number;
  57768. /**
  57769. * Creates a new Vector2 from the given x and y coordinates
  57770. * @param x defines the first coordinate
  57771. * @param y defines the second coordinate
  57772. */
  57773. constructor(
  57774. /** defines the first coordinate */
  57775. x?: number,
  57776. /** defines the second coordinate */
  57777. y?: number);
  57778. /**
  57779. * Gets a string with the Vector2 coordinates
  57780. * @returns a string with the Vector2 coordinates
  57781. */
  57782. toString(): string;
  57783. /**
  57784. * Gets class name
  57785. * @returns the string "Vector2"
  57786. */
  57787. getClassName(): string;
  57788. /**
  57789. * Gets current vector hash code
  57790. * @returns the Vector2 hash code as a number
  57791. */
  57792. getHashCode(): number;
  57793. /**
  57794. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57795. * @param array defines the source array
  57796. * @param index defines the offset in source array
  57797. * @returns the current Vector2
  57798. */
  57799. toArray(array: FloatArray, index?: number): Vector2;
  57800. /**
  57801. * Copy the current vector to an array
  57802. * @returns a new array with 2 elements: the Vector2 coordinates.
  57803. */
  57804. asArray(): number[];
  57805. /**
  57806. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57807. * @param source defines the source Vector2
  57808. * @returns the current updated Vector2
  57809. */
  57810. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57811. /**
  57812. * Sets the Vector2 coordinates with the given floats
  57813. * @param x defines the first coordinate
  57814. * @param y defines the second coordinate
  57815. * @returns the current updated Vector2
  57816. */
  57817. copyFromFloats(x: number, y: number): Vector2;
  57818. /**
  57819. * Sets the Vector2 coordinates with the given floats
  57820. * @param x defines the first coordinate
  57821. * @param y defines the second coordinate
  57822. * @returns the current updated Vector2
  57823. */
  57824. set(x: number, y: number): Vector2;
  57825. /**
  57826. * Add another vector with the current one
  57827. * @param otherVector defines the other vector
  57828. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57829. */
  57830. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57831. /**
  57832. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57833. * @param otherVector defines the other vector
  57834. * @param result defines the target vector
  57835. * @returns the unmodified current Vector2
  57836. */
  57837. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57838. /**
  57839. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57840. * @param otherVector defines the other vector
  57841. * @returns the current updated Vector2
  57842. */
  57843. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57844. /**
  57845. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57846. * @param otherVector defines the other vector
  57847. * @returns a new Vector2
  57848. */
  57849. addVector3(otherVector: Vector3): Vector2;
  57850. /**
  57851. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57852. * @param otherVector defines the other vector
  57853. * @returns a new Vector2
  57854. */
  57855. subtract(otherVector: Vector2): Vector2;
  57856. /**
  57857. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57858. * @param otherVector defines the other vector
  57859. * @param result defines the target vector
  57860. * @returns the unmodified current Vector2
  57861. */
  57862. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57863. /**
  57864. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57865. * @param otherVector defines the other vector
  57866. * @returns the current updated Vector2
  57867. */
  57868. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57869. /**
  57870. * Multiplies in place the current Vector2 coordinates by the given ones
  57871. * @param otherVector defines the other vector
  57872. * @returns the current updated Vector2
  57873. */
  57874. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57875. /**
  57876. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57877. * @param otherVector defines the other vector
  57878. * @returns a new Vector2
  57879. */
  57880. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57881. /**
  57882. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57883. * @param otherVector defines the other vector
  57884. * @param result defines the target vector
  57885. * @returns the unmodified current Vector2
  57886. */
  57887. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57888. /**
  57889. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57890. * @param x defines the first coordinate
  57891. * @param y defines the second coordinate
  57892. * @returns a new Vector2
  57893. */
  57894. multiplyByFloats(x: number, y: number): Vector2;
  57895. /**
  57896. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57897. * @param otherVector defines the other vector
  57898. * @returns a new Vector2
  57899. */
  57900. divide(otherVector: Vector2): Vector2;
  57901. /**
  57902. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57903. * @param otherVector defines the other vector
  57904. * @param result defines the target vector
  57905. * @returns the unmodified current Vector2
  57906. */
  57907. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57908. /**
  57909. * Divides the current Vector2 coordinates by the given ones
  57910. * @param otherVector defines the other vector
  57911. * @returns the current updated Vector2
  57912. */
  57913. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57914. /**
  57915. * Gets a new Vector2 with current Vector2 negated coordinates
  57916. * @returns a new Vector2
  57917. */
  57918. negate(): Vector2;
  57919. /**
  57920. * Multiply the Vector2 coordinates by scale
  57921. * @param scale defines the scaling factor
  57922. * @returns the current updated Vector2
  57923. */
  57924. scaleInPlace(scale: number): Vector2;
  57925. /**
  57926. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57927. * @param scale defines the scaling factor
  57928. * @returns a new Vector2
  57929. */
  57930. scale(scale: number): Vector2;
  57931. /**
  57932. * Scale the current Vector2 values by a factor to a given Vector2
  57933. * @param scale defines the scale factor
  57934. * @param result defines the Vector2 object where to store the result
  57935. * @returns the unmodified current Vector2
  57936. */
  57937. scaleToRef(scale: number, result: Vector2): Vector2;
  57938. /**
  57939. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57940. * @param scale defines the scale factor
  57941. * @param result defines the Vector2 object where to store the result
  57942. * @returns the unmodified current Vector2
  57943. */
  57944. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57945. /**
  57946. * Gets a boolean if two vectors are equals
  57947. * @param otherVector defines the other vector
  57948. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57949. */
  57950. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57951. /**
  57952. * Gets a boolean if two vectors are equals (using an epsilon value)
  57953. * @param otherVector defines the other vector
  57954. * @param epsilon defines the minimal distance to consider equality
  57955. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57956. */
  57957. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57958. /**
  57959. * Gets a new Vector2 from current Vector2 floored values
  57960. * @returns a new Vector2
  57961. */
  57962. floor(): Vector2;
  57963. /**
  57964. * Gets a new Vector2 from current Vector2 floored values
  57965. * @returns a new Vector2
  57966. */
  57967. fract(): Vector2;
  57968. /**
  57969. * Gets the length of the vector
  57970. * @returns the vector length (float)
  57971. */
  57972. length(): number;
  57973. /**
  57974. * Gets the vector squared length
  57975. * @returns the vector squared length (float)
  57976. */
  57977. lengthSquared(): number;
  57978. /**
  57979. * Normalize the vector
  57980. * @returns the current updated Vector2
  57981. */
  57982. normalize(): Vector2;
  57983. /**
  57984. * Gets a new Vector2 copied from the Vector2
  57985. * @returns a new Vector2
  57986. */
  57987. clone(): Vector2;
  57988. /**
  57989. * Gets a new Vector2(0, 0)
  57990. * @returns a new Vector2
  57991. */
  57992. static Zero(): Vector2;
  57993. /**
  57994. * Gets a new Vector2(1, 1)
  57995. * @returns a new Vector2
  57996. */
  57997. static One(): Vector2;
  57998. /**
  57999. * Gets a new Vector2 set from the given index element of the given array
  58000. * @param array defines the data source
  58001. * @param offset defines the offset in the data source
  58002. * @returns a new Vector2
  58003. */
  58004. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58005. /**
  58006. * Sets "result" from the given index element of the given array
  58007. * @param array defines the data source
  58008. * @param offset defines the offset in the data source
  58009. * @param result defines the target vector
  58010. */
  58011. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58012. /**
  58013. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58014. * @param value1 defines 1st point of control
  58015. * @param value2 defines 2nd point of control
  58016. * @param value3 defines 3rd point of control
  58017. * @param value4 defines 4th point of control
  58018. * @param amount defines the interpolation factor
  58019. * @returns a new Vector2
  58020. */
  58021. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58022. /**
  58023. * 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".
  58024. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58025. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58026. * @param value defines the value to clamp
  58027. * @param min defines the lower limit
  58028. * @param max defines the upper limit
  58029. * @returns a new Vector2
  58030. */
  58031. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58032. /**
  58033. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58034. * @param value1 defines the 1st control point
  58035. * @param tangent1 defines the outgoing tangent
  58036. * @param value2 defines the 2nd control point
  58037. * @param tangent2 defines the incoming tangent
  58038. * @param amount defines the interpolation factor
  58039. * @returns a new Vector2
  58040. */
  58041. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58042. /**
  58043. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58044. * @param start defines the start vector
  58045. * @param end defines the end vector
  58046. * @param amount defines the interpolation factor
  58047. * @returns a new Vector2
  58048. */
  58049. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58050. /**
  58051. * Gets the dot product of the vector "left" and the vector "right"
  58052. * @param left defines first vector
  58053. * @param right defines second vector
  58054. * @returns the dot product (float)
  58055. */
  58056. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58057. /**
  58058. * Returns a new Vector2 equal to the normalized given vector
  58059. * @param vector defines the vector to normalize
  58060. * @returns a new Vector2
  58061. */
  58062. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58063. /**
  58064. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58065. * @param left defines 1st vector
  58066. * @param right defines 2nd vector
  58067. * @returns a new Vector2
  58068. */
  58069. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58070. /**
  58071. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58072. * @param left defines 1st vector
  58073. * @param right defines 2nd vector
  58074. * @returns a new Vector2
  58075. */
  58076. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58077. /**
  58078. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58079. * @param vector defines the vector to transform
  58080. * @param transformation defines the matrix to apply
  58081. * @returns a new Vector2
  58082. */
  58083. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58084. /**
  58085. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58086. * @param vector defines the vector to transform
  58087. * @param transformation defines the matrix to apply
  58088. * @param result defines the target vector
  58089. */
  58090. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58091. /**
  58092. * Determines if a given vector is included in a triangle
  58093. * @param p defines the vector to test
  58094. * @param p0 defines 1st triangle point
  58095. * @param p1 defines 2nd triangle point
  58096. * @param p2 defines 3rd triangle point
  58097. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58098. */
  58099. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58100. /**
  58101. * Gets the distance between the vectors "value1" and "value2"
  58102. * @param value1 defines first vector
  58103. * @param value2 defines second vector
  58104. * @returns the distance between vectors
  58105. */
  58106. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58107. /**
  58108. * Returns the squared distance between the vectors "value1" and "value2"
  58109. * @param value1 defines first vector
  58110. * @param value2 defines second vector
  58111. * @returns the squared distance between vectors
  58112. */
  58113. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58114. /**
  58115. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58116. * @param value1 defines first vector
  58117. * @param value2 defines second vector
  58118. * @returns a new Vector2
  58119. */
  58120. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58121. /**
  58122. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58123. * @param p defines the middle point
  58124. * @param segA defines one point of the segment
  58125. * @param segB defines the other point of the segment
  58126. * @returns the shortest distance
  58127. */
  58128. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58129. }
  58130. /**
  58131. * Classed used to store (x,y,z) vector representation
  58132. * A Vector3 is the main object used in 3D geometry
  58133. * It can represent etiher the coordinates of a point the space, either a direction
  58134. * Reminder: js uses a left handed forward facing system
  58135. */
  58136. export class Vector3 {
  58137. /**
  58138. * Defines the first coordinates (on X axis)
  58139. */
  58140. x: number;
  58141. /**
  58142. * Defines the second coordinates (on Y axis)
  58143. */
  58144. y: number;
  58145. /**
  58146. * Defines the third coordinates (on Z axis)
  58147. */
  58148. z: number;
  58149. private static _UpReadOnly;
  58150. /**
  58151. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58152. * @param x defines the first coordinates (on X axis)
  58153. * @param y defines the second coordinates (on Y axis)
  58154. * @param z defines the third coordinates (on Z axis)
  58155. */
  58156. constructor(
  58157. /**
  58158. * Defines the first coordinates (on X axis)
  58159. */
  58160. x?: number,
  58161. /**
  58162. * Defines the second coordinates (on Y axis)
  58163. */
  58164. y?: number,
  58165. /**
  58166. * Defines the third coordinates (on Z axis)
  58167. */
  58168. z?: number);
  58169. /**
  58170. * Creates a string representation of the Vector3
  58171. * @returns a string with the Vector3 coordinates.
  58172. */
  58173. toString(): string;
  58174. /**
  58175. * Gets the class name
  58176. * @returns the string "Vector3"
  58177. */
  58178. getClassName(): string;
  58179. /**
  58180. * Creates the Vector3 hash code
  58181. * @returns a number which tends to be unique between Vector3 instances
  58182. */
  58183. getHashCode(): number;
  58184. /**
  58185. * Creates an array containing three elements : the coordinates of the Vector3
  58186. * @returns a new array of numbers
  58187. */
  58188. asArray(): number[];
  58189. /**
  58190. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58191. * @param array defines the destination array
  58192. * @param index defines the offset in the destination array
  58193. * @returns the current Vector3
  58194. */
  58195. toArray(array: FloatArray, index?: number): Vector3;
  58196. /**
  58197. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58198. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58199. */
  58200. toQuaternion(): Quaternion;
  58201. /**
  58202. * Adds the given vector to the current Vector3
  58203. * @param otherVector defines the second operand
  58204. * @returns the current updated Vector3
  58205. */
  58206. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58207. /**
  58208. * Adds the given coordinates to the current Vector3
  58209. * @param x defines the x coordinate of the operand
  58210. * @param y defines the y coordinate of the operand
  58211. * @param z defines the z coordinate of the operand
  58212. * @returns the current updated Vector3
  58213. */
  58214. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58215. /**
  58216. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58217. * @param otherVector defines the second operand
  58218. * @returns the resulting Vector3
  58219. */
  58220. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58221. /**
  58222. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58223. * @param otherVector defines the second operand
  58224. * @param result defines the Vector3 object where to store the result
  58225. * @returns the current Vector3
  58226. */
  58227. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58228. /**
  58229. * Subtract the given vector from the current Vector3
  58230. * @param otherVector defines the second operand
  58231. * @returns the current updated Vector3
  58232. */
  58233. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58234. /**
  58235. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58236. * @param otherVector defines the second operand
  58237. * @returns the resulting Vector3
  58238. */
  58239. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58240. /**
  58241. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58242. * @param otherVector defines the second operand
  58243. * @param result defines the Vector3 object where to store the result
  58244. * @returns the current Vector3
  58245. */
  58246. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58247. /**
  58248. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58249. * @param x defines the x coordinate of the operand
  58250. * @param y defines the y coordinate of the operand
  58251. * @param z defines the z coordinate of the operand
  58252. * @returns the resulting Vector3
  58253. */
  58254. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58255. /**
  58256. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58257. * @param x defines the x coordinate of the operand
  58258. * @param y defines the y coordinate of the operand
  58259. * @param z defines the z coordinate of the operand
  58260. * @param result defines the Vector3 object where to store the result
  58261. * @returns the current Vector3
  58262. */
  58263. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58264. /**
  58265. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58266. * @returns a new Vector3
  58267. */
  58268. negate(): Vector3;
  58269. /**
  58270. * Multiplies the Vector3 coordinates by the float "scale"
  58271. * @param scale defines the multiplier factor
  58272. * @returns the current updated Vector3
  58273. */
  58274. scaleInPlace(scale: number): Vector3;
  58275. /**
  58276. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58277. * @param scale defines the multiplier factor
  58278. * @returns a new Vector3
  58279. */
  58280. scale(scale: number): Vector3;
  58281. /**
  58282. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58283. * @param scale defines the multiplier factor
  58284. * @param result defines the Vector3 object where to store the result
  58285. * @returns the current Vector3
  58286. */
  58287. scaleToRef(scale: number, result: Vector3): Vector3;
  58288. /**
  58289. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58290. * @param scale defines the scale factor
  58291. * @param result defines the Vector3 object where to store the result
  58292. * @returns the unmodified current Vector3
  58293. */
  58294. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58295. /**
  58296. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58297. * @param otherVector defines the second operand
  58298. * @returns true if both vectors are equals
  58299. */
  58300. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58301. /**
  58302. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58303. * @param otherVector defines the second operand
  58304. * @param epsilon defines the minimal distance to define values as equals
  58305. * @returns true if both vectors are distant less than epsilon
  58306. */
  58307. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58308. /**
  58309. * Returns true if the current Vector3 coordinates equals the given floats
  58310. * @param x defines the x coordinate of the operand
  58311. * @param y defines the y coordinate of the operand
  58312. * @param z defines the z coordinate of the operand
  58313. * @returns true if both vectors are equals
  58314. */
  58315. equalsToFloats(x: number, y: number, z: number): boolean;
  58316. /**
  58317. * Multiplies the current Vector3 coordinates by the given ones
  58318. * @param otherVector defines the second operand
  58319. * @returns the current updated Vector3
  58320. */
  58321. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58322. /**
  58323. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58324. * @param otherVector defines the second operand
  58325. * @returns the new Vector3
  58326. */
  58327. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58328. /**
  58329. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58330. * @param otherVector defines the second operand
  58331. * @param result defines the Vector3 object where to store the result
  58332. * @returns the current Vector3
  58333. */
  58334. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58335. /**
  58336. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58337. * @param x defines the x coordinate of the operand
  58338. * @param y defines the y coordinate of the operand
  58339. * @param z defines the z coordinate of the operand
  58340. * @returns the new Vector3
  58341. */
  58342. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58343. /**
  58344. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58345. * @param otherVector defines the second operand
  58346. * @returns the new Vector3
  58347. */
  58348. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58349. /**
  58350. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58351. * @param otherVector defines the second operand
  58352. * @param result defines the Vector3 object where to store the result
  58353. * @returns the current Vector3
  58354. */
  58355. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58356. /**
  58357. * Divides the current Vector3 coordinates by the given ones.
  58358. * @param otherVector defines the second operand
  58359. * @returns the current updated Vector3
  58360. */
  58361. divideInPlace(otherVector: Vector3): Vector3;
  58362. /**
  58363. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58364. * @param other defines the second operand
  58365. * @returns the current updated Vector3
  58366. */
  58367. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58368. /**
  58369. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58370. * @param other defines the second operand
  58371. * @returns the current updated Vector3
  58372. */
  58373. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58374. /**
  58375. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58376. * @param x defines the x coordinate of the operand
  58377. * @param y defines the y coordinate of the operand
  58378. * @param z defines the z coordinate of the operand
  58379. * @returns the current updated Vector3
  58380. */
  58381. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58382. /**
  58383. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58384. * @param x defines the x coordinate of the operand
  58385. * @param y defines the y coordinate of the operand
  58386. * @param z defines the z coordinate of the operand
  58387. * @returns the current updated Vector3
  58388. */
  58389. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58390. /**
  58391. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58392. * Check if is non uniform within a certain amount of decimal places to account for this
  58393. * @param epsilon the amount the values can differ
  58394. * @returns if the the vector is non uniform to a certain number of decimal places
  58395. */
  58396. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58397. /**
  58398. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58399. */
  58400. readonly isNonUniform: boolean;
  58401. /**
  58402. * Gets a new Vector3 from current Vector3 floored values
  58403. * @returns a new Vector3
  58404. */
  58405. floor(): Vector3;
  58406. /**
  58407. * Gets a new Vector3 from current Vector3 floored values
  58408. * @returns a new Vector3
  58409. */
  58410. fract(): Vector3;
  58411. /**
  58412. * Gets the length of the Vector3
  58413. * @returns the length of the Vecto3
  58414. */
  58415. length(): number;
  58416. /**
  58417. * Gets the squared length of the Vector3
  58418. * @returns squared length of the Vector3
  58419. */
  58420. lengthSquared(): number;
  58421. /**
  58422. * Normalize the current Vector3.
  58423. * Please note that this is an in place operation.
  58424. * @returns the current updated Vector3
  58425. */
  58426. normalize(): Vector3;
  58427. /**
  58428. * Reorders the x y z properties of the vector in place
  58429. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58430. * @returns the current updated vector
  58431. */
  58432. reorderInPlace(order: string): this;
  58433. /**
  58434. * Rotates the vector around 0,0,0 by a quaternion
  58435. * @param quaternion the rotation quaternion
  58436. * @param result vector to store the result
  58437. * @returns the resulting vector
  58438. */
  58439. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58440. /**
  58441. * Rotates a vector around a given point
  58442. * @param quaternion the rotation quaternion
  58443. * @param point the point to rotate around
  58444. * @param result vector to store the result
  58445. * @returns the resulting vector
  58446. */
  58447. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58448. /**
  58449. * Normalize the current Vector3 with the given input length.
  58450. * Please note that this is an in place operation.
  58451. * @param len the length of the vector
  58452. * @returns the current updated Vector3
  58453. */
  58454. normalizeFromLength(len: number): Vector3;
  58455. /**
  58456. * Normalize the current Vector3 to a new vector
  58457. * @returns the new Vector3
  58458. */
  58459. normalizeToNew(): Vector3;
  58460. /**
  58461. * Normalize the current Vector3 to the reference
  58462. * @param reference define the Vector3 to update
  58463. * @returns the updated Vector3
  58464. */
  58465. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58466. /**
  58467. * Creates a new Vector3 copied from the current Vector3
  58468. * @returns the new Vector3
  58469. */
  58470. clone(): Vector3;
  58471. /**
  58472. * Copies the given vector coordinates to the current Vector3 ones
  58473. * @param source defines the source Vector3
  58474. * @returns the current updated Vector3
  58475. */
  58476. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58477. /**
  58478. * Copies the given floats to the current Vector3 coordinates
  58479. * @param x defines the x coordinate of the operand
  58480. * @param y defines the y coordinate of the operand
  58481. * @param z defines the z coordinate of the operand
  58482. * @returns the current updated Vector3
  58483. */
  58484. copyFromFloats(x: number, y: number, z: number): Vector3;
  58485. /**
  58486. * Copies the given floats to the current Vector3 coordinates
  58487. * @param x defines the x coordinate of the operand
  58488. * @param y defines the y coordinate of the operand
  58489. * @param z defines the z coordinate of the operand
  58490. * @returns the current updated Vector3
  58491. */
  58492. set(x: number, y: number, z: number): Vector3;
  58493. /**
  58494. * Copies the given float to the current Vector3 coordinates
  58495. * @param v defines the x, y and z coordinates of the operand
  58496. * @returns the current updated Vector3
  58497. */
  58498. setAll(v: number): Vector3;
  58499. /**
  58500. * Get the clip factor between two vectors
  58501. * @param vector0 defines the first operand
  58502. * @param vector1 defines the second operand
  58503. * @param axis defines the axis to use
  58504. * @param size defines the size along the axis
  58505. * @returns the clip factor
  58506. */
  58507. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58508. /**
  58509. * Get angle between two vectors
  58510. * @param vector0 angle between vector0 and vector1
  58511. * @param vector1 angle between vector0 and vector1
  58512. * @param normal direction of the normal
  58513. * @return the angle between vector0 and vector1
  58514. */
  58515. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58516. /**
  58517. * Returns a new Vector3 set from the index "offset" of the given array
  58518. * @param array defines the source array
  58519. * @param offset defines the offset in the source array
  58520. * @returns the new Vector3
  58521. */
  58522. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58523. /**
  58524. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58525. * This function is deprecated. Use FromArray instead
  58526. * @param array defines the source array
  58527. * @param offset defines the offset in the source array
  58528. * @returns the new Vector3
  58529. */
  58530. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58531. /**
  58532. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58533. * @param array defines the source array
  58534. * @param offset defines the offset in the source array
  58535. * @param result defines the Vector3 where to store the result
  58536. */
  58537. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58538. /**
  58539. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58540. * This function is deprecated. Use FromArrayToRef instead.
  58541. * @param array defines the source array
  58542. * @param offset defines the offset in the source array
  58543. * @param result defines the Vector3 where to store the result
  58544. */
  58545. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58546. /**
  58547. * Sets the given vector "result" with the given floats.
  58548. * @param x defines the x coordinate of the source
  58549. * @param y defines the y coordinate of the source
  58550. * @param z defines the z coordinate of the source
  58551. * @param result defines the Vector3 where to store the result
  58552. */
  58553. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58554. /**
  58555. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58556. * @returns a new empty Vector3
  58557. */
  58558. static Zero(): Vector3;
  58559. /**
  58560. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58561. * @returns a new unit Vector3
  58562. */
  58563. static One(): Vector3;
  58564. /**
  58565. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58566. * @returns a new up Vector3
  58567. */
  58568. static Up(): Vector3;
  58569. /**
  58570. * Gets a up Vector3 that must not be updated
  58571. */
  58572. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58573. /**
  58574. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58575. * @returns a new down Vector3
  58576. */
  58577. static Down(): Vector3;
  58578. /**
  58579. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58580. * @returns a new forward Vector3
  58581. */
  58582. static Forward(): Vector3;
  58583. /**
  58584. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58585. * @returns a new forward Vector3
  58586. */
  58587. static Backward(): Vector3;
  58588. /**
  58589. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58590. * @returns a new right Vector3
  58591. */
  58592. static Right(): Vector3;
  58593. /**
  58594. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58595. * @returns a new left Vector3
  58596. */
  58597. static Left(): Vector3;
  58598. /**
  58599. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58600. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58601. * @param vector defines the Vector3 to transform
  58602. * @param transformation defines the transformation matrix
  58603. * @returns the transformed Vector3
  58604. */
  58605. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58606. /**
  58607. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58608. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58609. * @param vector defines the Vector3 to transform
  58610. * @param transformation defines the transformation matrix
  58611. * @param result defines the Vector3 where to store the result
  58612. */
  58613. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58614. /**
  58615. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58616. * This method computes tranformed coordinates only, not transformed direction vectors
  58617. * @param x define the x coordinate of the source vector
  58618. * @param y define the y coordinate of the source vector
  58619. * @param z define the z coordinate of the source vector
  58620. * @param transformation defines the transformation matrix
  58621. * @param result defines the Vector3 where to store the result
  58622. */
  58623. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58624. /**
  58625. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58626. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58627. * @param vector defines the Vector3 to transform
  58628. * @param transformation defines the transformation matrix
  58629. * @returns the new Vector3
  58630. */
  58631. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58632. /**
  58633. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58634. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58635. * @param vector defines the Vector3 to transform
  58636. * @param transformation defines the transformation matrix
  58637. * @param result defines the Vector3 where to store the result
  58638. */
  58639. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58640. /**
  58641. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58642. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58643. * @param x define the x coordinate of the source vector
  58644. * @param y define the y coordinate of the source vector
  58645. * @param z define the z coordinate of the source vector
  58646. * @param transformation defines the transformation matrix
  58647. * @param result defines the Vector3 where to store the result
  58648. */
  58649. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58650. /**
  58651. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58652. * @param value1 defines the first control point
  58653. * @param value2 defines the second control point
  58654. * @param value3 defines the third control point
  58655. * @param value4 defines the fourth control point
  58656. * @param amount defines the amount on the spline to use
  58657. * @returns the new Vector3
  58658. */
  58659. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58660. /**
  58661. * 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"
  58662. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58663. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58664. * @param value defines the current value
  58665. * @param min defines the lower range value
  58666. * @param max defines the upper range value
  58667. * @returns the new Vector3
  58668. */
  58669. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58670. /**
  58671. * 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"
  58672. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58673. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58674. * @param value defines the current value
  58675. * @param min defines the lower range value
  58676. * @param max defines the upper range value
  58677. * @param result defines the Vector3 where to store the result
  58678. */
  58679. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58680. /**
  58681. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58682. * @param value1 defines the first control point
  58683. * @param tangent1 defines the first tangent vector
  58684. * @param value2 defines the second control point
  58685. * @param tangent2 defines the second tangent vector
  58686. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58687. * @returns the new Vector3
  58688. */
  58689. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58690. /**
  58691. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58692. * @param start defines the start value
  58693. * @param end defines the end value
  58694. * @param amount max defines amount between both (between 0 and 1)
  58695. * @returns the new Vector3
  58696. */
  58697. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58698. /**
  58699. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58700. * @param start defines the start value
  58701. * @param end defines the end value
  58702. * @param amount max defines amount between both (between 0 and 1)
  58703. * @param result defines the Vector3 where to store the result
  58704. */
  58705. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58706. /**
  58707. * Returns the dot product (float) between the vectors "left" and "right"
  58708. * @param left defines the left operand
  58709. * @param right defines the right operand
  58710. * @returns the dot product
  58711. */
  58712. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58713. /**
  58714. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58715. * The cross product is then orthogonal to both "left" and "right"
  58716. * @param left defines the left operand
  58717. * @param right defines the right operand
  58718. * @returns the cross product
  58719. */
  58720. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58721. /**
  58722. * Sets the given vector "result" with the cross product of "left" and "right"
  58723. * The cross product is then orthogonal to both "left" and "right"
  58724. * @param left defines the left operand
  58725. * @param right defines the right operand
  58726. * @param result defines the Vector3 where to store the result
  58727. */
  58728. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58729. /**
  58730. * Returns a new Vector3 as the normalization of the given vector
  58731. * @param vector defines the Vector3 to normalize
  58732. * @returns the new Vector3
  58733. */
  58734. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58735. /**
  58736. * Sets the given vector "result" with the normalization of the given first vector
  58737. * @param vector defines the Vector3 to normalize
  58738. * @param result defines the Vector3 where to store the result
  58739. */
  58740. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58741. /**
  58742. * Project a Vector3 onto screen space
  58743. * @param vector defines the Vector3 to project
  58744. * @param world defines the world matrix to use
  58745. * @param transform defines the transform (view x projection) matrix to use
  58746. * @param viewport defines the screen viewport to use
  58747. * @returns the new Vector3
  58748. */
  58749. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58750. /** @hidden */
  58751. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58752. /**
  58753. * Unproject from screen space to object space
  58754. * @param source defines the screen space Vector3 to use
  58755. * @param viewportWidth defines the current width of the viewport
  58756. * @param viewportHeight defines the current height of the viewport
  58757. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58758. * @param transform defines the transform (view x projection) matrix to use
  58759. * @returns the new Vector3
  58760. */
  58761. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58762. /**
  58763. * Unproject from screen space to object space
  58764. * @param source defines the screen space Vector3 to use
  58765. * @param viewportWidth defines the current width of the viewport
  58766. * @param viewportHeight defines the current height of the viewport
  58767. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58768. * @param view defines the view matrix to use
  58769. * @param projection defines the projection matrix to use
  58770. * @returns the new Vector3
  58771. */
  58772. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58773. /**
  58774. * Unproject from screen space to object space
  58775. * @param source defines the screen space Vector3 to use
  58776. * @param viewportWidth defines the current width of the viewport
  58777. * @param viewportHeight defines the current height of the viewport
  58778. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58779. * @param view defines the view matrix to use
  58780. * @param projection defines the projection matrix to use
  58781. * @param result defines the Vector3 where to store the result
  58782. */
  58783. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58784. /**
  58785. * Unproject from screen space to object space
  58786. * @param sourceX defines the screen space x coordinate to use
  58787. * @param sourceY defines the screen space y coordinate to use
  58788. * @param sourceZ defines the screen space z coordinate to use
  58789. * @param viewportWidth defines the current width of the viewport
  58790. * @param viewportHeight defines the current height of the viewport
  58791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58792. * @param view defines the view matrix to use
  58793. * @param projection defines the projection matrix to use
  58794. * @param result defines the Vector3 where to store the result
  58795. */
  58796. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58797. /**
  58798. * Gets the minimal coordinate values between two Vector3
  58799. * @param left defines the first operand
  58800. * @param right defines the second operand
  58801. * @returns the new Vector3
  58802. */
  58803. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58804. /**
  58805. * Gets the maximal coordinate values between two Vector3
  58806. * @param left defines the first operand
  58807. * @param right defines the second operand
  58808. * @returns the new Vector3
  58809. */
  58810. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58811. /**
  58812. * Returns the distance between the vectors "value1" and "value2"
  58813. * @param value1 defines the first operand
  58814. * @param value2 defines the second operand
  58815. * @returns the distance
  58816. */
  58817. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58818. /**
  58819. * Returns the squared distance between the vectors "value1" and "value2"
  58820. * @param value1 defines the first operand
  58821. * @param value2 defines the second operand
  58822. * @returns the squared distance
  58823. */
  58824. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58825. /**
  58826. * Returns a new Vector3 located at the center between "value1" and "value2"
  58827. * @param value1 defines the first operand
  58828. * @param value2 defines the second operand
  58829. * @returns the new Vector3
  58830. */
  58831. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58832. /**
  58833. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58834. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58835. * to something in order to rotate it from its local system to the given target system
  58836. * Note: axis1, axis2 and axis3 are normalized during this operation
  58837. * @param axis1 defines the first axis
  58838. * @param axis2 defines the second axis
  58839. * @param axis3 defines the third axis
  58840. * @returns a new Vector3
  58841. */
  58842. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58843. /**
  58844. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58845. * @param axis1 defines the first axis
  58846. * @param axis2 defines the second axis
  58847. * @param axis3 defines the third axis
  58848. * @param ref defines the Vector3 where to store the result
  58849. */
  58850. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58851. }
  58852. /**
  58853. * Vector4 class created for EulerAngle class conversion to Quaternion
  58854. */
  58855. export class Vector4 {
  58856. /** x value of the vector */
  58857. x: number;
  58858. /** y value of the vector */
  58859. y: number;
  58860. /** z value of the vector */
  58861. z: number;
  58862. /** w value of the vector */
  58863. w: number;
  58864. /**
  58865. * Creates a Vector4 object from the given floats.
  58866. * @param x x value of the vector
  58867. * @param y y value of the vector
  58868. * @param z z value of the vector
  58869. * @param w w value of the vector
  58870. */
  58871. constructor(
  58872. /** x value of the vector */
  58873. x: number,
  58874. /** y value of the vector */
  58875. y: number,
  58876. /** z value of the vector */
  58877. z: number,
  58878. /** w value of the vector */
  58879. w: number);
  58880. /**
  58881. * Returns the string with the Vector4 coordinates.
  58882. * @returns a string containing all the vector values
  58883. */
  58884. toString(): string;
  58885. /**
  58886. * Returns the string "Vector4".
  58887. * @returns "Vector4"
  58888. */
  58889. getClassName(): string;
  58890. /**
  58891. * Returns the Vector4 hash code.
  58892. * @returns a unique hash code
  58893. */
  58894. getHashCode(): number;
  58895. /**
  58896. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58897. * @returns the resulting array
  58898. */
  58899. asArray(): number[];
  58900. /**
  58901. * Populates the given array from the given index with the Vector4 coordinates.
  58902. * @param array array to populate
  58903. * @param index index of the array to start at (default: 0)
  58904. * @returns the Vector4.
  58905. */
  58906. toArray(array: FloatArray, index?: number): Vector4;
  58907. /**
  58908. * Adds the given vector to the current Vector4.
  58909. * @param otherVector the vector to add
  58910. * @returns the updated Vector4.
  58911. */
  58912. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58913. /**
  58914. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58915. * @param otherVector the vector to add
  58916. * @returns the resulting vector
  58917. */
  58918. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58919. /**
  58920. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58921. * @param otherVector the vector to add
  58922. * @param result the vector to store the result
  58923. * @returns the current Vector4.
  58924. */
  58925. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58926. /**
  58927. * Subtract in place the given vector from the current Vector4.
  58928. * @param otherVector the vector to subtract
  58929. * @returns the updated Vector4.
  58930. */
  58931. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58932. /**
  58933. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58934. * @param otherVector the vector to add
  58935. * @returns the new vector with the result
  58936. */
  58937. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58938. /**
  58939. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58940. * @param otherVector the vector to subtract
  58941. * @param result the vector to store the result
  58942. * @returns the current Vector4.
  58943. */
  58944. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58945. /**
  58946. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58947. */
  58948. /**
  58949. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58950. * @param x value to subtract
  58951. * @param y value to subtract
  58952. * @param z value to subtract
  58953. * @param w value to subtract
  58954. * @returns new vector containing the result
  58955. */
  58956. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58957. /**
  58958. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58959. * @param x value to subtract
  58960. * @param y value to subtract
  58961. * @param z value to subtract
  58962. * @param w value to subtract
  58963. * @param result the vector to store the result in
  58964. * @returns the current Vector4.
  58965. */
  58966. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58967. /**
  58968. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58969. * @returns a new vector with the negated values
  58970. */
  58971. negate(): Vector4;
  58972. /**
  58973. * Multiplies the current Vector4 coordinates by scale (float).
  58974. * @param scale the number to scale with
  58975. * @returns the updated Vector4.
  58976. */
  58977. scaleInPlace(scale: number): Vector4;
  58978. /**
  58979. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58980. * @param scale the number to scale with
  58981. * @returns a new vector with the result
  58982. */
  58983. scale(scale: number): Vector4;
  58984. /**
  58985. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58986. * @param scale the number to scale with
  58987. * @param result a vector to store the result in
  58988. * @returns the current Vector4.
  58989. */
  58990. scaleToRef(scale: number, result: Vector4): Vector4;
  58991. /**
  58992. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58993. * @param scale defines the scale factor
  58994. * @param result defines the Vector4 object where to store the result
  58995. * @returns the unmodified current Vector4
  58996. */
  58997. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58998. /**
  58999. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59000. * @param otherVector the vector to compare against
  59001. * @returns true if they are equal
  59002. */
  59003. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59004. /**
  59005. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59006. * @param otherVector vector to compare against
  59007. * @param epsilon (Default: very small number)
  59008. * @returns true if they are equal
  59009. */
  59010. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59011. /**
  59012. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59013. * @param x x value to compare against
  59014. * @param y y value to compare against
  59015. * @param z z value to compare against
  59016. * @param w w value to compare against
  59017. * @returns true if equal
  59018. */
  59019. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59020. /**
  59021. * Multiplies in place the current Vector4 by the given one.
  59022. * @param otherVector vector to multiple with
  59023. * @returns the updated Vector4.
  59024. */
  59025. multiplyInPlace(otherVector: Vector4): Vector4;
  59026. /**
  59027. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59028. * @param otherVector vector to multiple with
  59029. * @returns resulting new vector
  59030. */
  59031. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59032. /**
  59033. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59034. * @param otherVector vector to multiple with
  59035. * @param result vector to store the result
  59036. * @returns the current Vector4.
  59037. */
  59038. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59039. /**
  59040. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59041. * @param x x value multiply with
  59042. * @param y y value multiply with
  59043. * @param z z value multiply with
  59044. * @param w w value multiply with
  59045. * @returns resulting new vector
  59046. */
  59047. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59048. /**
  59049. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59050. * @param otherVector vector to devide with
  59051. * @returns resulting new vector
  59052. */
  59053. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59054. /**
  59055. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59056. * @param otherVector vector to devide with
  59057. * @param result vector to store the result
  59058. * @returns the current Vector4.
  59059. */
  59060. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59061. /**
  59062. * Divides the current Vector3 coordinates by the given ones.
  59063. * @param otherVector vector to devide with
  59064. * @returns the updated Vector3.
  59065. */
  59066. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59067. /**
  59068. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59069. * @param other defines the second operand
  59070. * @returns the current updated Vector4
  59071. */
  59072. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59073. /**
  59074. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59075. * @param other defines the second operand
  59076. * @returns the current updated Vector4
  59077. */
  59078. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59079. /**
  59080. * Gets a new Vector4 from current Vector4 floored values
  59081. * @returns a new Vector4
  59082. */
  59083. floor(): Vector4;
  59084. /**
  59085. * Gets a new Vector4 from current Vector3 floored values
  59086. * @returns a new Vector4
  59087. */
  59088. fract(): Vector4;
  59089. /**
  59090. * Returns the Vector4 length (float).
  59091. * @returns the length
  59092. */
  59093. length(): number;
  59094. /**
  59095. * Returns the Vector4 squared length (float).
  59096. * @returns the length squared
  59097. */
  59098. lengthSquared(): number;
  59099. /**
  59100. * Normalizes in place the Vector4.
  59101. * @returns the updated Vector4.
  59102. */
  59103. normalize(): Vector4;
  59104. /**
  59105. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59106. * @returns this converted to a new vector3
  59107. */
  59108. toVector3(): Vector3;
  59109. /**
  59110. * Returns a new Vector4 copied from the current one.
  59111. * @returns the new cloned vector
  59112. */
  59113. clone(): Vector4;
  59114. /**
  59115. * Updates the current Vector4 with the given one coordinates.
  59116. * @param source the source vector to copy from
  59117. * @returns the updated Vector4.
  59118. */
  59119. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59120. /**
  59121. * Updates the current Vector4 coordinates with the given floats.
  59122. * @param x float to copy from
  59123. * @param y float to copy from
  59124. * @param z float to copy from
  59125. * @param w float to copy from
  59126. * @returns the updated Vector4.
  59127. */
  59128. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59129. /**
  59130. * Updates the current Vector4 coordinates with the given floats.
  59131. * @param x float to set from
  59132. * @param y float to set from
  59133. * @param z float to set from
  59134. * @param w float to set from
  59135. * @returns the updated Vector4.
  59136. */
  59137. set(x: number, y: number, z: number, w: number): Vector4;
  59138. /**
  59139. * Copies the given float to the current Vector3 coordinates
  59140. * @param v defines the x, y, z and w coordinates of the operand
  59141. * @returns the current updated Vector3
  59142. */
  59143. setAll(v: number): Vector4;
  59144. /**
  59145. * Returns a new Vector4 set from the starting index of the given array.
  59146. * @param array the array to pull values from
  59147. * @param offset the offset into the array to start at
  59148. * @returns the new vector
  59149. */
  59150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59151. /**
  59152. * Updates the given vector "result" from the starting index of the given array.
  59153. * @param array the array to pull values from
  59154. * @param offset the offset into the array to start at
  59155. * @param result the vector to store the result in
  59156. */
  59157. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59158. /**
  59159. * Updates the given vector "result" from the starting index of the given Float32Array.
  59160. * @param array the array to pull values from
  59161. * @param offset the offset into the array to start at
  59162. * @param result the vector to store the result in
  59163. */
  59164. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59165. /**
  59166. * Updates the given vector "result" coordinates from the given floats.
  59167. * @param x float to set from
  59168. * @param y float to set from
  59169. * @param z float to set from
  59170. * @param w float to set from
  59171. * @param result the vector to the floats in
  59172. */
  59173. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59174. /**
  59175. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59176. * @returns the new vector
  59177. */
  59178. static Zero(): Vector4;
  59179. /**
  59180. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59181. * @returns the new vector
  59182. */
  59183. static One(): Vector4;
  59184. /**
  59185. * Returns a new normalized Vector4 from the given one.
  59186. * @param vector the vector to normalize
  59187. * @returns the vector
  59188. */
  59189. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59190. /**
  59191. * Updates the given vector "result" from the normalization of the given one.
  59192. * @param vector the vector to normalize
  59193. * @param result the vector to store the result in
  59194. */
  59195. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59196. /**
  59197. * Returns a vector with the minimum values from the left and right vectors
  59198. * @param left left vector to minimize
  59199. * @param right right vector to minimize
  59200. * @returns a new vector with the minimum of the left and right vector values
  59201. */
  59202. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59203. /**
  59204. * Returns a vector with the maximum values from the left and right vectors
  59205. * @param left left vector to maximize
  59206. * @param right right vector to maximize
  59207. * @returns a new vector with the maximum of the left and right vector values
  59208. */
  59209. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59210. /**
  59211. * Returns the distance (float) between the vectors "value1" and "value2".
  59212. * @param value1 value to calulate the distance between
  59213. * @param value2 value to calulate the distance between
  59214. * @return the distance between the two vectors
  59215. */
  59216. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59217. /**
  59218. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59219. * @param value1 value to calulate the distance between
  59220. * @param value2 value to calulate the distance between
  59221. * @return the distance between the two vectors squared
  59222. */
  59223. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59224. /**
  59225. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59226. * @param value1 value to calulate the center between
  59227. * @param value2 value to calulate the center between
  59228. * @return the center between the two vectors
  59229. */
  59230. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59231. /**
  59232. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59233. * This methods computes transformed normalized direction vectors only.
  59234. * @param vector the vector to transform
  59235. * @param transformation the transformation matrix to apply
  59236. * @returns the new vector
  59237. */
  59238. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59239. /**
  59240. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59241. * This methods computes transformed normalized direction vectors only.
  59242. * @param vector the vector to transform
  59243. * @param transformation the transformation matrix to apply
  59244. * @param result the vector to store the result in
  59245. */
  59246. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59247. /**
  59248. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59249. * This methods computes transformed normalized direction vectors only.
  59250. * @param x value to transform
  59251. * @param y value to transform
  59252. * @param z value to transform
  59253. * @param w value to transform
  59254. * @param transformation the transformation matrix to apply
  59255. * @param result the vector to store the results in
  59256. */
  59257. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59258. /**
  59259. * Creates a new Vector4 from a Vector3
  59260. * @param source defines the source data
  59261. * @param w defines the 4th component (default is 0)
  59262. * @returns a new Vector4
  59263. */
  59264. static FromVector3(source: Vector3, w?: number): Vector4;
  59265. }
  59266. /**
  59267. * Interface for the size containing width and height
  59268. */
  59269. export interface ISize {
  59270. /**
  59271. * Width
  59272. */
  59273. width: number;
  59274. /**
  59275. * Heighht
  59276. */
  59277. height: number;
  59278. }
  59279. /**
  59280. * Size containing widht and height
  59281. */
  59282. export class Size implements ISize {
  59283. /**
  59284. * Width
  59285. */
  59286. width: number;
  59287. /**
  59288. * Height
  59289. */
  59290. height: number;
  59291. /**
  59292. * Creates a Size object from the given width and height (floats).
  59293. * @param width width of the new size
  59294. * @param height height of the new size
  59295. */
  59296. constructor(width: number, height: number);
  59297. /**
  59298. * Returns a string with the Size width and height
  59299. * @returns a string with the Size width and height
  59300. */
  59301. toString(): string;
  59302. /**
  59303. * "Size"
  59304. * @returns the string "Size"
  59305. */
  59306. getClassName(): string;
  59307. /**
  59308. * Returns the Size hash code.
  59309. * @returns a hash code for a unique width and height
  59310. */
  59311. getHashCode(): number;
  59312. /**
  59313. * Updates the current size from the given one.
  59314. * @param src the given size
  59315. */
  59316. copyFrom(src: Size): void;
  59317. /**
  59318. * Updates in place the current Size from the given floats.
  59319. * @param width width of the new size
  59320. * @param height height of the new size
  59321. * @returns the updated Size.
  59322. */
  59323. copyFromFloats(width: number, height: number): Size;
  59324. /**
  59325. * Updates in place the current Size from the given floats.
  59326. * @param width width to set
  59327. * @param height height to set
  59328. * @returns the updated Size.
  59329. */
  59330. set(width: number, height: number): Size;
  59331. /**
  59332. * Multiplies the width and height by numbers
  59333. * @param w factor to multiple the width by
  59334. * @param h factor to multiple the height by
  59335. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59336. */
  59337. multiplyByFloats(w: number, h: number): Size;
  59338. /**
  59339. * Clones the size
  59340. * @returns a new Size copied from the given one.
  59341. */
  59342. clone(): Size;
  59343. /**
  59344. * True if the current Size and the given one width and height are strictly equal.
  59345. * @param other the other size to compare against
  59346. * @returns True if the current Size and the given one width and height are strictly equal.
  59347. */
  59348. equals(other: Size): boolean;
  59349. /**
  59350. * The surface of the Size : width * height (float).
  59351. */
  59352. readonly surface: number;
  59353. /**
  59354. * Create a new size of zero
  59355. * @returns a new Size set to (0.0, 0.0)
  59356. */
  59357. static Zero(): Size;
  59358. /**
  59359. * Sums the width and height of two sizes
  59360. * @param otherSize size to add to this size
  59361. * @returns a new Size set as the addition result of the current Size and the given one.
  59362. */
  59363. add(otherSize: Size): Size;
  59364. /**
  59365. * Subtracts the width and height of two
  59366. * @param otherSize size to subtract to this size
  59367. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59368. */
  59369. subtract(otherSize: Size): Size;
  59370. /**
  59371. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59372. * @param start starting size to lerp between
  59373. * @param end end size to lerp between
  59374. * @param amount amount to lerp between the start and end values
  59375. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59376. */
  59377. static Lerp(start: Size, end: Size, amount: number): Size;
  59378. }
  59379. /**
  59380. * Class used to store quaternion data
  59381. * @see https://en.wikipedia.org/wiki/Quaternion
  59382. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59383. */
  59384. export class Quaternion {
  59385. /** defines the first component (0 by default) */
  59386. x: number;
  59387. /** defines the second component (0 by default) */
  59388. y: number;
  59389. /** defines the third component (0 by default) */
  59390. z: number;
  59391. /** defines the fourth component (1.0 by default) */
  59392. w: number;
  59393. /**
  59394. * Creates a new Quaternion from the given floats
  59395. * @param x defines the first component (0 by default)
  59396. * @param y defines the second component (0 by default)
  59397. * @param z defines the third component (0 by default)
  59398. * @param w defines the fourth component (1.0 by default)
  59399. */
  59400. constructor(
  59401. /** defines the first component (0 by default) */
  59402. x?: number,
  59403. /** defines the second component (0 by default) */
  59404. y?: number,
  59405. /** defines the third component (0 by default) */
  59406. z?: number,
  59407. /** defines the fourth component (1.0 by default) */
  59408. w?: number);
  59409. /**
  59410. * Gets a string representation for the current quaternion
  59411. * @returns a string with the Quaternion coordinates
  59412. */
  59413. toString(): string;
  59414. /**
  59415. * Gets the class name of the quaternion
  59416. * @returns the string "Quaternion"
  59417. */
  59418. getClassName(): string;
  59419. /**
  59420. * Gets a hash code for this quaternion
  59421. * @returns the quaternion hash code
  59422. */
  59423. getHashCode(): number;
  59424. /**
  59425. * Copy the quaternion to an array
  59426. * @returns a new array populated with 4 elements from the quaternion coordinates
  59427. */
  59428. asArray(): number[];
  59429. /**
  59430. * Check if two quaternions are equals
  59431. * @param otherQuaternion defines the second operand
  59432. * @return true if the current quaternion and the given one coordinates are strictly equals
  59433. */
  59434. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59435. /**
  59436. * Clone the current quaternion
  59437. * @returns a new quaternion copied from the current one
  59438. */
  59439. clone(): Quaternion;
  59440. /**
  59441. * Copy a quaternion to the current one
  59442. * @param other defines the other quaternion
  59443. * @returns the updated current quaternion
  59444. */
  59445. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59446. /**
  59447. * Updates the current quaternion with the given float coordinates
  59448. * @param x defines the x coordinate
  59449. * @param y defines the y coordinate
  59450. * @param z defines the z coordinate
  59451. * @param w defines the w coordinate
  59452. * @returns the updated current quaternion
  59453. */
  59454. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59455. /**
  59456. * Updates the current quaternion from the given float coordinates
  59457. * @param x defines the x coordinate
  59458. * @param y defines the y coordinate
  59459. * @param z defines the z coordinate
  59460. * @param w defines the w coordinate
  59461. * @returns the updated current quaternion
  59462. */
  59463. set(x: number, y: number, z: number, w: number): Quaternion;
  59464. /**
  59465. * Adds two quaternions
  59466. * @param other defines the second operand
  59467. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59468. */
  59469. add(other: DeepImmutable<Quaternion>): Quaternion;
  59470. /**
  59471. * Add a quaternion to the current one
  59472. * @param other defines the quaternion to add
  59473. * @returns the current quaternion
  59474. */
  59475. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59476. /**
  59477. * Subtract two quaternions
  59478. * @param other defines the second operand
  59479. * @returns a new quaternion as the subtraction result of the given one from the current one
  59480. */
  59481. subtract(other: Quaternion): Quaternion;
  59482. /**
  59483. * Multiplies the current quaternion by a scale factor
  59484. * @param value defines the scale factor
  59485. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59486. */
  59487. scale(value: number): Quaternion;
  59488. /**
  59489. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59490. * @param scale defines the scale factor
  59491. * @param result defines the Quaternion object where to store the result
  59492. * @returns the unmodified current quaternion
  59493. */
  59494. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59495. /**
  59496. * Multiplies in place the current quaternion by a scale factor
  59497. * @param value defines the scale factor
  59498. * @returns the current modified quaternion
  59499. */
  59500. scaleInPlace(value: number): Quaternion;
  59501. /**
  59502. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59503. * @param scale defines the scale factor
  59504. * @param result defines the Quaternion object where to store the result
  59505. * @returns the unmodified current quaternion
  59506. */
  59507. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59508. /**
  59509. * Multiplies two quaternions
  59510. * @param q1 defines the second operand
  59511. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59512. */
  59513. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59514. /**
  59515. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59516. * @param q1 defines the second operand
  59517. * @param result defines the target quaternion
  59518. * @returns the current quaternion
  59519. */
  59520. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59521. /**
  59522. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59523. * @param q1 defines the second operand
  59524. * @returns the currentupdated quaternion
  59525. */
  59526. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59527. /**
  59528. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59529. * @param ref defines the target quaternion
  59530. * @returns the current quaternion
  59531. */
  59532. conjugateToRef(ref: Quaternion): Quaternion;
  59533. /**
  59534. * Conjugates in place (1-q) the current quaternion
  59535. * @returns the current updated quaternion
  59536. */
  59537. conjugateInPlace(): Quaternion;
  59538. /**
  59539. * Conjugates in place (1-q) the current quaternion
  59540. * @returns a new quaternion
  59541. */
  59542. conjugate(): Quaternion;
  59543. /**
  59544. * Gets length of current quaternion
  59545. * @returns the quaternion length (float)
  59546. */
  59547. length(): number;
  59548. /**
  59549. * Normalize in place the current quaternion
  59550. * @returns the current updated quaternion
  59551. */
  59552. normalize(): Quaternion;
  59553. /**
  59554. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59555. * @param order is a reserved parameter and is ignore for now
  59556. * @returns a new Vector3 containing the Euler angles
  59557. */
  59558. toEulerAngles(order?: string): Vector3;
  59559. /**
  59560. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59561. * @param result defines the vector which will be filled with the Euler angles
  59562. * @param order is a reserved parameter and is ignore for now
  59563. * @returns the current unchanged quaternion
  59564. */
  59565. toEulerAnglesToRef(result: Vector3): Quaternion;
  59566. /**
  59567. * Updates the given rotation matrix with the current quaternion values
  59568. * @param result defines the target matrix
  59569. * @returns the current unchanged quaternion
  59570. */
  59571. toRotationMatrix(result: Matrix): Quaternion;
  59572. /**
  59573. * Updates the current quaternion from the given rotation matrix values
  59574. * @param matrix defines the source matrix
  59575. * @returns the current updated quaternion
  59576. */
  59577. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59578. /**
  59579. * Creates a new quaternion from a rotation matrix
  59580. * @param matrix defines the source matrix
  59581. * @returns a new quaternion created from the given rotation matrix values
  59582. */
  59583. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59584. /**
  59585. * Updates the given quaternion with the given rotation matrix values
  59586. * @param matrix defines the source matrix
  59587. * @param result defines the target quaternion
  59588. */
  59589. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59590. /**
  59591. * Returns the dot product (float) between the quaternions "left" and "right"
  59592. * @param left defines the left operand
  59593. * @param right defines the right operand
  59594. * @returns the dot product
  59595. */
  59596. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59597. /**
  59598. * Checks if the two quaternions are close to each other
  59599. * @param quat0 defines the first quaternion to check
  59600. * @param quat1 defines the second quaternion to check
  59601. * @returns true if the two quaternions are close to each other
  59602. */
  59603. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59604. /**
  59605. * Creates an empty quaternion
  59606. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59607. */
  59608. static Zero(): Quaternion;
  59609. /**
  59610. * Inverse a given quaternion
  59611. * @param q defines the source quaternion
  59612. * @returns a new quaternion as the inverted current quaternion
  59613. */
  59614. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59615. /**
  59616. * Inverse a given quaternion
  59617. * @param q defines the source quaternion
  59618. * @param result the quaternion the result will be stored in
  59619. * @returns the result quaternion
  59620. */
  59621. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59622. /**
  59623. * Creates an identity quaternion
  59624. * @returns the identity quaternion
  59625. */
  59626. static Identity(): Quaternion;
  59627. /**
  59628. * Gets a boolean indicating if the given quaternion is identity
  59629. * @param quaternion defines the quaternion to check
  59630. * @returns true if the quaternion is identity
  59631. */
  59632. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59633. /**
  59634. * Creates a quaternion from a rotation around an axis
  59635. * @param axis defines the axis to use
  59636. * @param angle defines the angle to use
  59637. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59638. */
  59639. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59640. /**
  59641. * Creates a rotation around an axis and stores it into the given quaternion
  59642. * @param axis defines the axis to use
  59643. * @param angle defines the angle to use
  59644. * @param result defines the target quaternion
  59645. * @returns the target quaternion
  59646. */
  59647. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59648. /**
  59649. * Creates a new quaternion from data stored into an array
  59650. * @param array defines the data source
  59651. * @param offset defines the offset in the source array where the data starts
  59652. * @returns a new quaternion
  59653. */
  59654. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59655. /**
  59656. * Create a quaternion from Euler rotation angles
  59657. * @param x Pitch
  59658. * @param y Yaw
  59659. * @param z Roll
  59660. * @returns the new Quaternion
  59661. */
  59662. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59663. /**
  59664. * Updates a quaternion from Euler rotation angles
  59665. * @param x Pitch
  59666. * @param y Yaw
  59667. * @param z Roll
  59668. * @param result the quaternion to store the result
  59669. * @returns the updated quaternion
  59670. */
  59671. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59672. /**
  59673. * Create a quaternion from Euler rotation vector
  59674. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59675. * @returns the new Quaternion
  59676. */
  59677. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59678. /**
  59679. * Updates a quaternion from Euler rotation vector
  59680. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59681. * @param result the quaternion to store the result
  59682. * @returns the updated quaternion
  59683. */
  59684. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59685. /**
  59686. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59687. * @param yaw defines the rotation around Y axis
  59688. * @param pitch defines the rotation around X axis
  59689. * @param roll defines the rotation around Z axis
  59690. * @returns the new quaternion
  59691. */
  59692. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59693. /**
  59694. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59695. * @param yaw defines the rotation around Y axis
  59696. * @param pitch defines the rotation around X axis
  59697. * @param roll defines the rotation around Z axis
  59698. * @param result defines the target quaternion
  59699. */
  59700. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59701. /**
  59702. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59703. * @param alpha defines the rotation around first axis
  59704. * @param beta defines the rotation around second axis
  59705. * @param gamma defines the rotation around third axis
  59706. * @returns the new quaternion
  59707. */
  59708. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59709. /**
  59710. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59711. * @param alpha defines the rotation around first axis
  59712. * @param beta defines the rotation around second axis
  59713. * @param gamma defines the rotation around third axis
  59714. * @param result defines the target quaternion
  59715. */
  59716. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59717. /**
  59718. * 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)
  59719. * @param axis1 defines the first axis
  59720. * @param axis2 defines the second axis
  59721. * @param axis3 defines the third axis
  59722. * @returns the new quaternion
  59723. */
  59724. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59725. /**
  59726. * 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
  59727. * @param axis1 defines the first axis
  59728. * @param axis2 defines the second axis
  59729. * @param axis3 defines the third axis
  59730. * @param ref defines the target quaternion
  59731. */
  59732. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59733. /**
  59734. * Interpolates between two quaternions
  59735. * @param left defines first quaternion
  59736. * @param right defines second quaternion
  59737. * @param amount defines the gradient to use
  59738. * @returns the new interpolated quaternion
  59739. */
  59740. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59741. /**
  59742. * Interpolates between two quaternions and stores it into a target quaternion
  59743. * @param left defines first quaternion
  59744. * @param right defines second quaternion
  59745. * @param amount defines the gradient to use
  59746. * @param result defines the target quaternion
  59747. */
  59748. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59749. /**
  59750. * Interpolate between two quaternions using Hermite interpolation
  59751. * @param value1 defines first quaternion
  59752. * @param tangent1 defines the incoming tangent
  59753. * @param value2 defines second quaternion
  59754. * @param tangent2 defines the outgoing tangent
  59755. * @param amount defines the target quaternion
  59756. * @returns the new interpolated quaternion
  59757. */
  59758. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59759. }
  59760. /**
  59761. * Class used to store matrix data (4x4)
  59762. */
  59763. export class Matrix {
  59764. private static _updateFlagSeed;
  59765. private static _identityReadOnly;
  59766. private _isIdentity;
  59767. private _isIdentityDirty;
  59768. private _isIdentity3x2;
  59769. private _isIdentity3x2Dirty;
  59770. /**
  59771. * Gets the update flag of the matrix which is an unique number for the matrix.
  59772. * It will be incremented every time the matrix data change.
  59773. * You can use it to speed the comparison between two versions of the same matrix.
  59774. */
  59775. updateFlag: number;
  59776. private readonly _m;
  59777. /**
  59778. * Gets the internal data of the matrix
  59779. */
  59780. readonly m: DeepImmutable<Float32Array>;
  59781. /** @hidden */
  59782. _markAsUpdated(): void;
  59783. /** @hidden */
  59784. private _updateIdentityStatus;
  59785. /**
  59786. * Creates an empty matrix (filled with zeros)
  59787. */
  59788. constructor();
  59789. /**
  59790. * Check if the current matrix is identity
  59791. * @returns true is the matrix is the identity matrix
  59792. */
  59793. isIdentity(): boolean;
  59794. /**
  59795. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59796. * @returns true is the matrix is the identity matrix
  59797. */
  59798. isIdentityAs3x2(): boolean;
  59799. /**
  59800. * Gets the determinant of the matrix
  59801. * @returns the matrix determinant
  59802. */
  59803. determinant(): number;
  59804. /**
  59805. * Returns the matrix as a Float32Array
  59806. * @returns the matrix underlying array
  59807. */
  59808. toArray(): DeepImmutable<Float32Array>;
  59809. /**
  59810. * Returns the matrix as a Float32Array
  59811. * @returns the matrix underlying array.
  59812. */
  59813. asArray(): DeepImmutable<Float32Array>;
  59814. /**
  59815. * Inverts the current matrix in place
  59816. * @returns the current inverted matrix
  59817. */
  59818. invert(): Matrix;
  59819. /**
  59820. * Sets all the matrix elements to zero
  59821. * @returns the current matrix
  59822. */
  59823. reset(): Matrix;
  59824. /**
  59825. * Adds the current matrix with a second one
  59826. * @param other defines the matrix to add
  59827. * @returns a new matrix as the addition of the current matrix and the given one
  59828. */
  59829. add(other: DeepImmutable<Matrix>): Matrix;
  59830. /**
  59831. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59832. * @param other defines the matrix to add
  59833. * @param result defines the target matrix
  59834. * @returns the current matrix
  59835. */
  59836. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59837. /**
  59838. * Adds in place the given matrix to the current matrix
  59839. * @param other defines the second operand
  59840. * @returns the current updated matrix
  59841. */
  59842. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59843. /**
  59844. * Sets the given matrix to the current inverted Matrix
  59845. * @param other defines the target matrix
  59846. * @returns the unmodified current matrix
  59847. */
  59848. invertToRef(other: Matrix): Matrix;
  59849. /**
  59850. * add a value at the specified position in the current Matrix
  59851. * @param index the index of the value within the matrix. between 0 and 15.
  59852. * @param value the value to be added
  59853. * @returns the current updated matrix
  59854. */
  59855. addAtIndex(index: number, value: number): Matrix;
  59856. /**
  59857. * mutiply the specified position in the current Matrix by a value
  59858. * @param index the index of the value within the matrix. between 0 and 15.
  59859. * @param value the value to be added
  59860. * @returns the current updated matrix
  59861. */
  59862. multiplyAtIndex(index: number, value: number): Matrix;
  59863. /**
  59864. * Inserts the translation vector (using 3 floats) in the current matrix
  59865. * @param x defines the 1st component of the translation
  59866. * @param y defines the 2nd component of the translation
  59867. * @param z defines the 3rd component of the translation
  59868. * @returns the current updated matrix
  59869. */
  59870. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59871. /**
  59872. * Inserts the translation vector in the current matrix
  59873. * @param vector3 defines the translation to insert
  59874. * @returns the current updated matrix
  59875. */
  59876. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59877. /**
  59878. * Gets the translation value of the current matrix
  59879. * @returns a new Vector3 as the extracted translation from the matrix
  59880. */
  59881. getTranslation(): Vector3;
  59882. /**
  59883. * Fill a Vector3 with the extracted translation from the matrix
  59884. * @param result defines the Vector3 where to store the translation
  59885. * @returns the current matrix
  59886. */
  59887. getTranslationToRef(result: Vector3): Matrix;
  59888. /**
  59889. * Remove rotation and scaling part from the matrix
  59890. * @returns the updated matrix
  59891. */
  59892. removeRotationAndScaling(): Matrix;
  59893. /**
  59894. * Multiply two matrices
  59895. * @param other defines the second operand
  59896. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59897. */
  59898. multiply(other: DeepImmutable<Matrix>): Matrix;
  59899. /**
  59900. * Copy the current matrix from the given one
  59901. * @param other defines the source matrix
  59902. * @returns the current updated matrix
  59903. */
  59904. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59905. /**
  59906. * Populates the given array from the starting index with the current matrix values
  59907. * @param array defines the target array
  59908. * @param offset defines the offset in the target array where to start storing values
  59909. * @returns the current matrix
  59910. */
  59911. copyToArray(array: Float32Array, offset?: number): Matrix;
  59912. /**
  59913. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59914. * @param other defines the second operand
  59915. * @param result defines the matrix where to store the multiplication
  59916. * @returns the current matrix
  59917. */
  59918. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59919. /**
  59920. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59921. * @param other defines the second operand
  59922. * @param result defines the array where to store the multiplication
  59923. * @param offset defines the offset in the target array where to start storing values
  59924. * @returns the current matrix
  59925. */
  59926. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59927. /**
  59928. * Check equality between this matrix and a second one
  59929. * @param value defines the second matrix to compare
  59930. * @returns true is the current matrix and the given one values are strictly equal
  59931. */
  59932. equals(value: DeepImmutable<Matrix>): boolean;
  59933. /**
  59934. * Clone the current matrix
  59935. * @returns a new matrix from the current matrix
  59936. */
  59937. clone(): Matrix;
  59938. /**
  59939. * Returns the name of the current matrix class
  59940. * @returns the string "Matrix"
  59941. */
  59942. getClassName(): string;
  59943. /**
  59944. * Gets the hash code of the current matrix
  59945. * @returns the hash code
  59946. */
  59947. getHashCode(): number;
  59948. /**
  59949. * Decomposes the current Matrix into a translation, rotation and scaling components
  59950. * @param scale defines the scale vector3 given as a reference to update
  59951. * @param rotation defines the rotation quaternion given as a reference to update
  59952. * @param translation defines the translation vector3 given as a reference to update
  59953. * @returns true if operation was successful
  59954. */
  59955. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59956. /**
  59957. * Gets specific row of the matrix
  59958. * @param index defines the number of the row to get
  59959. * @returns the index-th row of the current matrix as a new Vector4
  59960. */
  59961. getRow(index: number): Nullable<Vector4>;
  59962. /**
  59963. * Sets the index-th row of the current matrix to the vector4 values
  59964. * @param index defines the number of the row to set
  59965. * @param row defines the target vector4
  59966. * @returns the updated current matrix
  59967. */
  59968. setRow(index: number, row: Vector4): Matrix;
  59969. /**
  59970. * Compute the transpose of the matrix
  59971. * @returns the new transposed matrix
  59972. */
  59973. transpose(): Matrix;
  59974. /**
  59975. * Compute the transpose of the matrix and store it in a given matrix
  59976. * @param result defines the target matrix
  59977. * @returns the current matrix
  59978. */
  59979. transposeToRef(result: Matrix): Matrix;
  59980. /**
  59981. * Sets the index-th row of the current matrix with the given 4 x float values
  59982. * @param index defines the row index
  59983. * @param x defines the x component to set
  59984. * @param y defines the y component to set
  59985. * @param z defines the z component to set
  59986. * @param w defines the w component to set
  59987. * @returns the updated current matrix
  59988. */
  59989. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59990. /**
  59991. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59992. * @param scale defines the scale factor
  59993. * @returns a new matrix
  59994. */
  59995. scale(scale: number): Matrix;
  59996. /**
  59997. * Scale the current matrix values by a factor to a given result matrix
  59998. * @param scale defines the scale factor
  59999. * @param result defines the matrix to store the result
  60000. * @returns the current matrix
  60001. */
  60002. scaleToRef(scale: number, result: Matrix): Matrix;
  60003. /**
  60004. * Scale the current matrix values by a factor and add the result to a given matrix
  60005. * @param scale defines the scale factor
  60006. * @param result defines the Matrix to store the result
  60007. * @returns the current matrix
  60008. */
  60009. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60010. /**
  60011. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60012. * @param ref matrix to store the result
  60013. */
  60014. toNormalMatrix(ref: Matrix): void;
  60015. /**
  60016. * Gets only rotation part of the current matrix
  60017. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60018. */
  60019. getRotationMatrix(): Matrix;
  60020. /**
  60021. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60022. * @param result defines the target matrix to store data to
  60023. * @returns the current matrix
  60024. */
  60025. getRotationMatrixToRef(result: Matrix): Matrix;
  60026. /**
  60027. * Toggles model matrix from being right handed to left handed in place and vice versa
  60028. */
  60029. toggleModelMatrixHandInPlace(): void;
  60030. /**
  60031. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60032. */
  60033. toggleProjectionMatrixHandInPlace(): void;
  60034. /**
  60035. * Creates a matrix from an array
  60036. * @param array defines the source array
  60037. * @param offset defines an offset in the source array
  60038. * @returns a new Matrix set from the starting index of the given array
  60039. */
  60040. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60041. /**
  60042. * Copy the content of an array into a given matrix
  60043. * @param array defines the source array
  60044. * @param offset defines an offset in the source array
  60045. * @param result defines the target matrix
  60046. */
  60047. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60048. /**
  60049. * Stores an array into a matrix after having multiplied each component by a given factor
  60050. * @param array defines the source array
  60051. * @param offset defines the offset in the source array
  60052. * @param scale defines the scaling factor
  60053. * @param result defines the target matrix
  60054. */
  60055. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60056. /**
  60057. * Gets an identity matrix that must not be updated
  60058. */
  60059. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60060. /**
  60061. * Stores a list of values (16) inside a given matrix
  60062. * @param initialM11 defines 1st value of 1st row
  60063. * @param initialM12 defines 2nd value of 1st row
  60064. * @param initialM13 defines 3rd value of 1st row
  60065. * @param initialM14 defines 4th value of 1st row
  60066. * @param initialM21 defines 1st value of 2nd row
  60067. * @param initialM22 defines 2nd value of 2nd row
  60068. * @param initialM23 defines 3rd value of 2nd row
  60069. * @param initialM24 defines 4th value of 2nd row
  60070. * @param initialM31 defines 1st value of 3rd row
  60071. * @param initialM32 defines 2nd value of 3rd row
  60072. * @param initialM33 defines 3rd value of 3rd row
  60073. * @param initialM34 defines 4th value of 3rd row
  60074. * @param initialM41 defines 1st value of 4th row
  60075. * @param initialM42 defines 2nd value of 4th row
  60076. * @param initialM43 defines 3rd value of 4th row
  60077. * @param initialM44 defines 4th value of 4th row
  60078. * @param result defines the target matrix
  60079. */
  60080. 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;
  60081. /**
  60082. * Creates new matrix from a list of values (16)
  60083. * @param initialM11 defines 1st value of 1st row
  60084. * @param initialM12 defines 2nd value of 1st row
  60085. * @param initialM13 defines 3rd value of 1st row
  60086. * @param initialM14 defines 4th value of 1st row
  60087. * @param initialM21 defines 1st value of 2nd row
  60088. * @param initialM22 defines 2nd value of 2nd row
  60089. * @param initialM23 defines 3rd value of 2nd row
  60090. * @param initialM24 defines 4th value of 2nd row
  60091. * @param initialM31 defines 1st value of 3rd row
  60092. * @param initialM32 defines 2nd value of 3rd row
  60093. * @param initialM33 defines 3rd value of 3rd row
  60094. * @param initialM34 defines 4th value of 3rd row
  60095. * @param initialM41 defines 1st value of 4th row
  60096. * @param initialM42 defines 2nd value of 4th row
  60097. * @param initialM43 defines 3rd value of 4th row
  60098. * @param initialM44 defines 4th value of 4th row
  60099. * @returns the new matrix
  60100. */
  60101. 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;
  60102. /**
  60103. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60104. * @param scale defines the scale vector3
  60105. * @param rotation defines the rotation quaternion
  60106. * @param translation defines the translation vector3
  60107. * @returns a new matrix
  60108. */
  60109. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60110. /**
  60111. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60112. * @param scale defines the scale vector3
  60113. * @param rotation defines the rotation quaternion
  60114. * @param translation defines the translation vector3
  60115. * @param result defines the target matrix
  60116. */
  60117. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60118. /**
  60119. * Creates a new identity matrix
  60120. * @returns a new identity matrix
  60121. */
  60122. static Identity(): Matrix;
  60123. /**
  60124. * Creates a new identity matrix and stores the result in a given matrix
  60125. * @param result defines the target matrix
  60126. */
  60127. static IdentityToRef(result: Matrix): void;
  60128. /**
  60129. * Creates a new zero matrix
  60130. * @returns a new zero matrix
  60131. */
  60132. static Zero(): Matrix;
  60133. /**
  60134. * Creates a new rotation matrix for "angle" radians around the X axis
  60135. * @param angle defines the angle (in radians) to use
  60136. * @return the new matrix
  60137. */
  60138. static RotationX(angle: number): Matrix;
  60139. /**
  60140. * Creates a new matrix as the invert of a given matrix
  60141. * @param source defines the source matrix
  60142. * @returns the new matrix
  60143. */
  60144. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60145. /**
  60146. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60147. * @param angle defines the angle (in radians) to use
  60148. * @param result defines the target matrix
  60149. */
  60150. static RotationXToRef(angle: number, result: Matrix): void;
  60151. /**
  60152. * Creates a new rotation matrix for "angle" radians around the Y axis
  60153. * @param angle defines the angle (in radians) to use
  60154. * @return the new matrix
  60155. */
  60156. static RotationY(angle: number): Matrix;
  60157. /**
  60158. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60159. * @param angle defines the angle (in radians) to use
  60160. * @param result defines the target matrix
  60161. */
  60162. static RotationYToRef(angle: number, result: Matrix): void;
  60163. /**
  60164. * Creates a new rotation matrix for "angle" radians around the Z axis
  60165. * @param angle defines the angle (in radians) to use
  60166. * @return the new matrix
  60167. */
  60168. static RotationZ(angle: number): Matrix;
  60169. /**
  60170. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60171. * @param angle defines the angle (in radians) to use
  60172. * @param result defines the target matrix
  60173. */
  60174. static RotationZToRef(angle: number, result: Matrix): void;
  60175. /**
  60176. * Creates a new rotation matrix for "angle" radians around the given axis
  60177. * @param axis defines the axis to use
  60178. * @param angle defines the angle (in radians) to use
  60179. * @return the new matrix
  60180. */
  60181. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60182. /**
  60183. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60184. * @param axis defines the axis to use
  60185. * @param angle defines the angle (in radians) to use
  60186. * @param result defines the target matrix
  60187. */
  60188. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60189. /**
  60190. * Creates a rotation matrix
  60191. * @param yaw defines the yaw angle in radians (Y axis)
  60192. * @param pitch defines the pitch angle in radians (X axis)
  60193. * @param roll defines the roll angle in radians (X axis)
  60194. * @returns the new rotation matrix
  60195. */
  60196. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60197. /**
  60198. * Creates a rotation matrix and stores it in a given matrix
  60199. * @param yaw defines the yaw angle in radians (Y axis)
  60200. * @param pitch defines the pitch angle in radians (X axis)
  60201. * @param roll defines the roll angle in radians (X axis)
  60202. * @param result defines the target matrix
  60203. */
  60204. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60205. /**
  60206. * Creates a scaling matrix
  60207. * @param x defines the scale factor on X axis
  60208. * @param y defines the scale factor on Y axis
  60209. * @param z defines the scale factor on Z axis
  60210. * @returns the new matrix
  60211. */
  60212. static Scaling(x: number, y: number, z: number): Matrix;
  60213. /**
  60214. * Creates a scaling matrix and stores it in a given matrix
  60215. * @param x defines the scale factor on X axis
  60216. * @param y defines the scale factor on Y axis
  60217. * @param z defines the scale factor on Z axis
  60218. * @param result defines the target matrix
  60219. */
  60220. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60221. /**
  60222. * Creates a translation matrix
  60223. * @param x defines the translation on X axis
  60224. * @param y defines the translation on Y axis
  60225. * @param z defines the translationon Z axis
  60226. * @returns the new matrix
  60227. */
  60228. static Translation(x: number, y: number, z: number): Matrix;
  60229. /**
  60230. * Creates a translation matrix and stores it in a given matrix
  60231. * @param x defines the translation on X axis
  60232. * @param y defines the translation on Y axis
  60233. * @param z defines the translationon Z axis
  60234. * @param result defines the target matrix
  60235. */
  60236. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60237. /**
  60238. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60239. * @param startValue defines the start value
  60240. * @param endValue defines the end value
  60241. * @param gradient defines the gradient factor
  60242. * @returns the new matrix
  60243. */
  60244. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60245. /**
  60246. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60247. * @param startValue defines the start value
  60248. * @param endValue defines the end value
  60249. * @param gradient defines the gradient factor
  60250. * @param result defines the Matrix object where to store data
  60251. */
  60252. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60253. /**
  60254. * Builds a new matrix whose values are computed by:
  60255. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60256. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60257. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60258. * @param startValue defines the first matrix
  60259. * @param endValue defines the second matrix
  60260. * @param gradient defines the gradient between the two matrices
  60261. * @returns the new matrix
  60262. */
  60263. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60264. /**
  60265. * Update a matrix to values which are computed by:
  60266. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60267. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60268. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60269. * @param startValue defines the first matrix
  60270. * @param endValue defines the second matrix
  60271. * @param gradient defines the gradient between the two matrices
  60272. * @param result defines the target matrix
  60273. */
  60274. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60275. /**
  60276. * 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"
  60277. * This function works in left handed mode
  60278. * @param eye defines the final position of the entity
  60279. * @param target defines where the entity should look at
  60280. * @param up defines the up vector for the entity
  60281. * @returns the new matrix
  60282. */
  60283. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60284. /**
  60285. * 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".
  60286. * This function works in left handed mode
  60287. * @param eye defines the final position of the entity
  60288. * @param target defines where the entity should look at
  60289. * @param up defines the up vector for the entity
  60290. * @param result defines the target matrix
  60291. */
  60292. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60293. /**
  60294. * 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"
  60295. * This function works in right handed mode
  60296. * @param eye defines the final position of the entity
  60297. * @param target defines where the entity should look at
  60298. * @param up defines the up vector for the entity
  60299. * @returns the new matrix
  60300. */
  60301. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60302. /**
  60303. * 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".
  60304. * This function works in right handed mode
  60305. * @param eye defines the final position of the entity
  60306. * @param target defines where the entity should look at
  60307. * @param up defines the up vector for the entity
  60308. * @param result defines the target matrix
  60309. */
  60310. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60311. /**
  60312. * Create a left-handed orthographic projection matrix
  60313. * @param width defines the viewport width
  60314. * @param height defines the viewport height
  60315. * @param znear defines the near clip plane
  60316. * @param zfar defines the far clip plane
  60317. * @returns a new matrix as a left-handed orthographic projection matrix
  60318. */
  60319. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60320. /**
  60321. * Store a left-handed orthographic projection to a given matrix
  60322. * @param width defines the viewport width
  60323. * @param height defines the viewport height
  60324. * @param znear defines the near clip plane
  60325. * @param zfar defines the far clip plane
  60326. * @param result defines the target matrix
  60327. */
  60328. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60329. /**
  60330. * Create a left-handed orthographic projection matrix
  60331. * @param left defines the viewport left coordinate
  60332. * @param right defines the viewport right coordinate
  60333. * @param bottom defines the viewport bottom coordinate
  60334. * @param top defines the viewport top coordinate
  60335. * @param znear defines the near clip plane
  60336. * @param zfar defines the far clip plane
  60337. * @returns a new matrix as a left-handed orthographic projection matrix
  60338. */
  60339. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60340. /**
  60341. * Stores a left-handed orthographic projection into a given matrix
  60342. * @param left defines the viewport left coordinate
  60343. * @param right defines the viewport right coordinate
  60344. * @param bottom defines the viewport bottom coordinate
  60345. * @param top defines the viewport top coordinate
  60346. * @param znear defines the near clip plane
  60347. * @param zfar defines the far clip plane
  60348. * @param result defines the target matrix
  60349. */
  60350. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60351. /**
  60352. * Creates a right-handed orthographic projection matrix
  60353. * @param left defines the viewport left coordinate
  60354. * @param right defines the viewport right coordinate
  60355. * @param bottom defines the viewport bottom coordinate
  60356. * @param top defines the viewport top coordinate
  60357. * @param znear defines the near clip plane
  60358. * @param zfar defines the far clip plane
  60359. * @returns a new matrix as a right-handed orthographic projection matrix
  60360. */
  60361. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60362. /**
  60363. * Stores a right-handed orthographic projection into a given matrix
  60364. * @param left defines the viewport left coordinate
  60365. * @param right defines the viewport right coordinate
  60366. * @param bottom defines the viewport bottom coordinate
  60367. * @param top defines the viewport top coordinate
  60368. * @param znear defines the near clip plane
  60369. * @param zfar defines the far clip plane
  60370. * @param result defines the target matrix
  60371. */
  60372. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60373. /**
  60374. * Creates a left-handed perspective projection matrix
  60375. * @param width defines the viewport width
  60376. * @param height defines the viewport height
  60377. * @param znear defines the near clip plane
  60378. * @param zfar defines the far clip plane
  60379. * @returns a new matrix as a left-handed perspective projection matrix
  60380. */
  60381. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60382. /**
  60383. * Creates a left-handed perspective projection matrix
  60384. * @param fov defines the horizontal field of view
  60385. * @param aspect defines the aspect ratio
  60386. * @param znear defines the near clip plane
  60387. * @param zfar defines the far clip plane
  60388. * @returns a new matrix as a left-handed perspective projection matrix
  60389. */
  60390. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60391. /**
  60392. * Stores a left-handed perspective projection into a given matrix
  60393. * @param fov defines the horizontal field of view
  60394. * @param aspect defines the aspect ratio
  60395. * @param znear defines the near clip plane
  60396. * @param zfar defines the far clip plane
  60397. * @param result defines the target matrix
  60398. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60399. */
  60400. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60401. /**
  60402. * Creates a right-handed perspective projection matrix
  60403. * @param fov defines the horizontal field of view
  60404. * @param aspect defines the aspect ratio
  60405. * @param znear defines the near clip plane
  60406. * @param zfar defines the far clip plane
  60407. * @returns a new matrix as a right-handed perspective projection matrix
  60408. */
  60409. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60410. /**
  60411. * Stores a right-handed perspective projection into a given matrix
  60412. * @param fov defines the horizontal field of view
  60413. * @param aspect defines the aspect ratio
  60414. * @param znear defines the near clip plane
  60415. * @param zfar defines the far clip plane
  60416. * @param result defines the target matrix
  60417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60418. */
  60419. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60420. /**
  60421. * Stores a perspective projection for WebVR info a given matrix
  60422. * @param fov defines the field of view
  60423. * @param znear defines the near clip plane
  60424. * @param zfar defines the far clip plane
  60425. * @param result defines the target matrix
  60426. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60427. */
  60428. static PerspectiveFovWebVRToRef(fov: {
  60429. upDegrees: number;
  60430. downDegrees: number;
  60431. leftDegrees: number;
  60432. rightDegrees: number;
  60433. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60434. /**
  60435. * Computes a complete transformation matrix
  60436. * @param viewport defines the viewport to use
  60437. * @param world defines the world matrix
  60438. * @param view defines the view matrix
  60439. * @param projection defines the projection matrix
  60440. * @param zmin defines the near clip plane
  60441. * @param zmax defines the far clip plane
  60442. * @returns the transformation matrix
  60443. */
  60444. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60445. /**
  60446. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60447. * @param matrix defines the matrix to use
  60448. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60449. */
  60450. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60451. /**
  60452. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60453. * @param matrix defines the matrix to use
  60454. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60455. */
  60456. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60457. /**
  60458. * Compute the transpose of a given matrix
  60459. * @param matrix defines the matrix to transpose
  60460. * @returns the new matrix
  60461. */
  60462. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60463. /**
  60464. * Compute the transpose of a matrix and store it in a target matrix
  60465. * @param matrix defines the matrix to transpose
  60466. * @param result defines the target matrix
  60467. */
  60468. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60469. /**
  60470. * Computes a reflection matrix from a plane
  60471. * @param plane defines the reflection plane
  60472. * @returns a new matrix
  60473. */
  60474. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60475. /**
  60476. * Computes a reflection matrix from a plane
  60477. * @param plane defines the reflection plane
  60478. * @param result defines the target matrix
  60479. */
  60480. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60481. /**
  60482. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60483. * @param xaxis defines the value of the 1st axis
  60484. * @param yaxis defines the value of the 2nd axis
  60485. * @param zaxis defines the value of the 3rd axis
  60486. * @param result defines the target matrix
  60487. */
  60488. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60489. /**
  60490. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60491. * @param quat defines the quaternion to use
  60492. * @param result defines the target matrix
  60493. */
  60494. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60495. }
  60496. /**
  60497. * Represens a plane by the equation ax + by + cz + d = 0
  60498. */
  60499. export class Plane {
  60500. /**
  60501. * Normal of the plane (a,b,c)
  60502. */
  60503. normal: Vector3;
  60504. /**
  60505. * d component of the plane
  60506. */
  60507. d: number;
  60508. /**
  60509. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60510. * @param a a component of the plane
  60511. * @param b b component of the plane
  60512. * @param c c component of the plane
  60513. * @param d d component of the plane
  60514. */
  60515. constructor(a: number, b: number, c: number, d: number);
  60516. /**
  60517. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60518. */
  60519. asArray(): number[];
  60520. /**
  60521. * @returns a new plane copied from the current Plane.
  60522. */
  60523. clone(): Plane;
  60524. /**
  60525. * @returns the string "Plane".
  60526. */
  60527. getClassName(): string;
  60528. /**
  60529. * @returns the Plane hash code.
  60530. */
  60531. getHashCode(): number;
  60532. /**
  60533. * Normalize the current Plane in place.
  60534. * @returns the updated Plane.
  60535. */
  60536. normalize(): Plane;
  60537. /**
  60538. * Applies a transformation the plane and returns the result
  60539. * @param transformation the transformation matrix to be applied to the plane
  60540. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60541. */
  60542. transform(transformation: DeepImmutable<Matrix>): Plane;
  60543. /**
  60544. * Calcualtte the dot product between the point and the plane normal
  60545. * @param point point to calculate the dot product with
  60546. * @returns the dot product (float) of the point coordinates and the plane normal.
  60547. */
  60548. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60549. /**
  60550. * Updates the current Plane from the plane defined by the three given points.
  60551. * @param point1 one of the points used to contruct the plane
  60552. * @param point2 one of the points used to contruct the plane
  60553. * @param point3 one of the points used to contruct the plane
  60554. * @returns the updated Plane.
  60555. */
  60556. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60557. /**
  60558. * Checks if the plane is facing a given direction
  60559. * @param direction the direction to check if the plane is facing
  60560. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60561. * @returns True is the vector "direction" is the same side than the plane normal.
  60562. */
  60563. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60564. /**
  60565. * Calculates the distance to a point
  60566. * @param point point to calculate distance to
  60567. * @returns the signed distance (float) from the given point to the Plane.
  60568. */
  60569. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60570. /**
  60571. * Creates a plane from an array
  60572. * @param array the array to create a plane from
  60573. * @returns a new Plane from the given array.
  60574. */
  60575. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60576. /**
  60577. * Creates a plane from three points
  60578. * @param point1 point used to create the plane
  60579. * @param point2 point used to create the plane
  60580. * @param point3 point used to create the plane
  60581. * @returns a new Plane defined by the three given points.
  60582. */
  60583. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60584. /**
  60585. * Creates a plane from an origin point and a normal
  60586. * @param origin origin of the plane to be constructed
  60587. * @param normal normal of the plane to be constructed
  60588. * @returns a new Plane the normal vector to this plane at the given origin point.
  60589. * Note : the vector "normal" is updated because normalized.
  60590. */
  60591. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60592. /**
  60593. * Calculates the distance from a plane and a point
  60594. * @param origin origin of the plane to be constructed
  60595. * @param normal normal of the plane to be constructed
  60596. * @param point point to calculate distance to
  60597. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60598. */
  60599. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60600. }
  60601. /**
  60602. * Class used to represent a viewport on screen
  60603. */
  60604. export class Viewport {
  60605. /** viewport left coordinate */
  60606. x: number;
  60607. /** viewport top coordinate */
  60608. y: number;
  60609. /**viewport width */
  60610. width: number;
  60611. /** viewport height */
  60612. height: number;
  60613. /**
  60614. * Creates a Viewport object located at (x, y) and sized (width, height)
  60615. * @param x defines viewport left coordinate
  60616. * @param y defines viewport top coordinate
  60617. * @param width defines the viewport width
  60618. * @param height defines the viewport height
  60619. */
  60620. constructor(
  60621. /** viewport left coordinate */
  60622. x: number,
  60623. /** viewport top coordinate */
  60624. y: number,
  60625. /**viewport width */
  60626. width: number,
  60627. /** viewport height */
  60628. height: number);
  60629. /**
  60630. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60631. * @param renderWidth defines the rendering width
  60632. * @param renderHeight defines the rendering height
  60633. * @returns a new Viewport
  60634. */
  60635. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60636. /**
  60637. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60638. * @param renderWidth defines the rendering width
  60639. * @param renderHeight defines the rendering height
  60640. * @param ref defines the target viewport
  60641. * @returns the current viewport
  60642. */
  60643. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60644. /**
  60645. * Returns a new Viewport copied from the current one
  60646. * @returns a new Viewport
  60647. */
  60648. clone(): Viewport;
  60649. }
  60650. /**
  60651. * Reprasents a camera frustum
  60652. */
  60653. export class Frustum {
  60654. /**
  60655. * Gets the planes representing the frustum
  60656. * @param transform matrix to be applied to the returned planes
  60657. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60658. */
  60659. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60660. /**
  60661. * Gets the near frustum plane transformed by the transform matrix
  60662. * @param transform transformation matrix to be applied to the resulting frustum plane
  60663. * @param frustumPlane the resuling frustum plane
  60664. */
  60665. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60666. /**
  60667. * Gets the far frustum plane transformed by the transform matrix
  60668. * @param transform transformation matrix to be applied to the resulting frustum plane
  60669. * @param frustumPlane the resuling frustum plane
  60670. */
  60671. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60672. /**
  60673. * Gets the left frustum plane transformed by the transform matrix
  60674. * @param transform transformation matrix to be applied to the resulting frustum plane
  60675. * @param frustumPlane the resuling frustum plane
  60676. */
  60677. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60678. /**
  60679. * Gets the right frustum plane transformed by the transform matrix
  60680. * @param transform transformation matrix to be applied to the resulting frustum plane
  60681. * @param frustumPlane the resuling frustum plane
  60682. */
  60683. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60684. /**
  60685. * Gets the top frustum plane transformed by the transform matrix
  60686. * @param transform transformation matrix to be applied to the resulting frustum plane
  60687. * @param frustumPlane the resuling frustum plane
  60688. */
  60689. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60690. /**
  60691. * Gets the bottom frustum plane transformed by the transform matrix
  60692. * @param transform transformation matrix to be applied to the resulting frustum plane
  60693. * @param frustumPlane the resuling frustum plane
  60694. */
  60695. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60696. /**
  60697. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60698. * @param transform transformation matrix to be applied to the resulting frustum planes
  60699. * @param frustumPlanes the resuling frustum planes
  60700. */
  60701. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60702. }
  60703. /** Defines supported spaces */
  60704. export enum Space {
  60705. /** Local (object) space */
  60706. LOCAL = 0,
  60707. /** World space */
  60708. WORLD = 1,
  60709. /** Bone space */
  60710. BONE = 2
  60711. }
  60712. /** Defines the 3 main axes */
  60713. export class Axis {
  60714. /** X axis */
  60715. static X: Vector3;
  60716. /** Y axis */
  60717. static Y: Vector3;
  60718. /** Z axis */
  60719. static Z: Vector3;
  60720. }
  60721. /** Class used to represent a Bezier curve */
  60722. export class BezierCurve {
  60723. /**
  60724. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60725. * @param t defines the time
  60726. * @param x1 defines the left coordinate on X axis
  60727. * @param y1 defines the left coordinate on Y axis
  60728. * @param x2 defines the right coordinate on X axis
  60729. * @param y2 defines the right coordinate on Y axis
  60730. * @returns the interpolated value
  60731. */
  60732. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60733. }
  60734. /**
  60735. * Defines potential orientation for back face culling
  60736. */
  60737. export enum Orientation {
  60738. /**
  60739. * Clockwise
  60740. */
  60741. CW = 0,
  60742. /** Counter clockwise */
  60743. CCW = 1
  60744. }
  60745. /**
  60746. * Defines angle representation
  60747. */
  60748. export class Angle {
  60749. private _radians;
  60750. /**
  60751. * Creates an Angle object of "radians" radians (float).
  60752. * @param radians the angle in radians
  60753. */
  60754. constructor(radians: number);
  60755. /**
  60756. * Get value in degrees
  60757. * @returns the Angle value in degrees (float)
  60758. */
  60759. degrees(): number;
  60760. /**
  60761. * Get value in radians
  60762. * @returns the Angle value in radians (float)
  60763. */
  60764. radians(): number;
  60765. /**
  60766. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60767. * @param a defines first vector
  60768. * @param b defines second vector
  60769. * @returns a new Angle
  60770. */
  60771. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60772. /**
  60773. * Gets a new Angle object from the given float in radians
  60774. * @param radians defines the angle value in radians
  60775. * @returns a new Angle
  60776. */
  60777. static FromRadians(radians: number): Angle;
  60778. /**
  60779. * Gets a new Angle object from the given float in degrees
  60780. * @param degrees defines the angle value in degrees
  60781. * @returns a new Angle
  60782. */
  60783. static FromDegrees(degrees: number): Angle;
  60784. }
  60785. /**
  60786. * This represents an arc in a 2d space.
  60787. */
  60788. export class Arc2 {
  60789. /** Defines the start point of the arc */
  60790. startPoint: Vector2;
  60791. /** Defines the mid point of the arc */
  60792. midPoint: Vector2;
  60793. /** Defines the end point of the arc */
  60794. endPoint: Vector2;
  60795. /**
  60796. * Defines the center point of the arc.
  60797. */
  60798. centerPoint: Vector2;
  60799. /**
  60800. * Defines the radius of the arc.
  60801. */
  60802. radius: number;
  60803. /**
  60804. * Defines the angle of the arc (from mid point to end point).
  60805. */
  60806. angle: Angle;
  60807. /**
  60808. * Defines the start angle of the arc (from start point to middle point).
  60809. */
  60810. startAngle: Angle;
  60811. /**
  60812. * Defines the orientation of the arc (clock wise/counter clock wise).
  60813. */
  60814. orientation: Orientation;
  60815. /**
  60816. * Creates an Arc object from the three given points : start, middle and end.
  60817. * @param startPoint Defines the start point of the arc
  60818. * @param midPoint Defines the midlle point of the arc
  60819. * @param endPoint Defines the end point of the arc
  60820. */
  60821. constructor(
  60822. /** Defines the start point of the arc */
  60823. startPoint: Vector2,
  60824. /** Defines the mid point of the arc */
  60825. midPoint: Vector2,
  60826. /** Defines the end point of the arc */
  60827. endPoint: Vector2);
  60828. }
  60829. /**
  60830. * Represents a 2D path made up of multiple 2D points
  60831. */
  60832. export class Path2 {
  60833. private _points;
  60834. private _length;
  60835. /**
  60836. * If the path start and end point are the same
  60837. */
  60838. closed: boolean;
  60839. /**
  60840. * Creates a Path2 object from the starting 2D coordinates x and y.
  60841. * @param x the starting points x value
  60842. * @param y the starting points y value
  60843. */
  60844. constructor(x: number, y: number);
  60845. /**
  60846. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60847. * @param x the added points x value
  60848. * @param y the added points y value
  60849. * @returns the updated Path2.
  60850. */
  60851. addLineTo(x: number, y: number): Path2;
  60852. /**
  60853. * 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.
  60854. * @param midX middle point x value
  60855. * @param midY middle point y value
  60856. * @param endX end point x value
  60857. * @param endY end point y value
  60858. * @param numberOfSegments (default: 36)
  60859. * @returns the updated Path2.
  60860. */
  60861. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60862. /**
  60863. * Closes the Path2.
  60864. * @returns the Path2.
  60865. */
  60866. close(): Path2;
  60867. /**
  60868. * Gets the sum of the distance between each sequential point in the path
  60869. * @returns the Path2 total length (float).
  60870. */
  60871. length(): number;
  60872. /**
  60873. * Gets the points which construct the path
  60874. * @returns the Path2 internal array of points.
  60875. */
  60876. getPoints(): Vector2[];
  60877. /**
  60878. * Retreives the point at the distance aways from the starting point
  60879. * @param normalizedLengthPosition the length along the path to retreive the point from
  60880. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60881. */
  60882. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60883. /**
  60884. * Creates a new path starting from an x and y position
  60885. * @param x starting x value
  60886. * @param y starting y value
  60887. * @returns a new Path2 starting at the coordinates (x, y).
  60888. */
  60889. static StartingAt(x: number, y: number): Path2;
  60890. }
  60891. /**
  60892. * Represents a 3D path made up of multiple 3D points
  60893. */
  60894. export class Path3D {
  60895. /**
  60896. * an array of Vector3, the curve axis of the Path3D
  60897. */
  60898. path: Vector3[];
  60899. private _curve;
  60900. private _distances;
  60901. private _tangents;
  60902. private _normals;
  60903. private _binormals;
  60904. private _raw;
  60905. /**
  60906. * new Path3D(path, normal, raw)
  60907. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60908. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60909. * @param path an array of Vector3, the curve axis of the Path3D
  60910. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60911. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60912. */
  60913. constructor(
  60914. /**
  60915. * an array of Vector3, the curve axis of the Path3D
  60916. */
  60917. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60918. /**
  60919. * Returns the Path3D array of successive Vector3 designing its curve.
  60920. * @returns the Path3D array of successive Vector3 designing its curve.
  60921. */
  60922. getCurve(): Vector3[];
  60923. /**
  60924. * Returns an array populated with tangent vectors on each Path3D curve point.
  60925. * @returns an array populated with tangent vectors on each Path3D curve point.
  60926. */
  60927. getTangents(): Vector3[];
  60928. /**
  60929. * Returns an array populated with normal vectors on each Path3D curve point.
  60930. * @returns an array populated with normal vectors on each Path3D curve point.
  60931. */
  60932. getNormals(): Vector3[];
  60933. /**
  60934. * Returns an array populated with binormal vectors on each Path3D curve point.
  60935. * @returns an array populated with binormal vectors on each Path3D curve point.
  60936. */
  60937. getBinormals(): Vector3[];
  60938. /**
  60939. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60940. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60941. */
  60942. getDistances(): number[];
  60943. /**
  60944. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60945. * @param path path which all values are copied into the curves points
  60946. * @param firstNormal which should be projected onto the curve
  60947. * @returns the same object updated.
  60948. */
  60949. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60950. private _compute;
  60951. private _getFirstNonNullVector;
  60952. private _getLastNonNullVector;
  60953. private _normalVector;
  60954. }
  60955. /**
  60956. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60957. * A Curve3 is designed from a series of successive Vector3.
  60958. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60959. */
  60960. export class Curve3 {
  60961. private _points;
  60962. private _length;
  60963. /**
  60964. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60965. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60966. * @param v1 (Vector3) the control point
  60967. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60968. * @param nbPoints (integer) the wanted number of points in the curve
  60969. * @returns the created Curve3
  60970. */
  60971. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60972. /**
  60973. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60974. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60975. * @param v1 (Vector3) the first control point
  60976. * @param v2 (Vector3) the second control point
  60977. * @param v3 (Vector3) the end point of the Cubic Bezier
  60978. * @param nbPoints (integer) the wanted number of points in the curve
  60979. * @returns the created Curve3
  60980. */
  60981. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60982. /**
  60983. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60984. * @param p1 (Vector3) the origin point of the Hermite Spline
  60985. * @param t1 (Vector3) the tangent vector at the origin point
  60986. * @param p2 (Vector3) the end point of the Hermite Spline
  60987. * @param t2 (Vector3) the tangent vector at the end point
  60988. * @param nbPoints (integer) the wanted number of points in the curve
  60989. * @returns the created Curve3
  60990. */
  60991. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60992. /**
  60993. * Returns a Curve3 object along a CatmullRom Spline curve :
  60994. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60995. * @param nbPoints (integer) the wanted number of points between each curve control points
  60996. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60997. * @returns the created Curve3
  60998. */
  60999. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61000. /**
  61001. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61002. * A Curve3 is designed from a series of successive Vector3.
  61003. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61004. * @param points points which make up the curve
  61005. */
  61006. constructor(points: Vector3[]);
  61007. /**
  61008. * @returns the Curve3 stored array of successive Vector3
  61009. */
  61010. getPoints(): Vector3[];
  61011. /**
  61012. * @returns the computed length (float) of the curve.
  61013. */
  61014. length(): number;
  61015. /**
  61016. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61017. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61018. * curveA and curveB keep unchanged.
  61019. * @param curve the curve to continue from this curve
  61020. * @returns the newly constructed curve
  61021. */
  61022. continue(curve: DeepImmutable<Curve3>): Curve3;
  61023. private _computeLength;
  61024. }
  61025. /**
  61026. * Contains position and normal vectors for a vertex
  61027. */
  61028. export class PositionNormalVertex {
  61029. /** the position of the vertex (defaut: 0,0,0) */
  61030. position: Vector3;
  61031. /** the normal of the vertex (defaut: 0,1,0) */
  61032. normal: Vector3;
  61033. /**
  61034. * Creates a PositionNormalVertex
  61035. * @param position the position of the vertex (defaut: 0,0,0)
  61036. * @param normal the normal of the vertex (defaut: 0,1,0)
  61037. */
  61038. constructor(
  61039. /** the position of the vertex (defaut: 0,0,0) */
  61040. position?: Vector3,
  61041. /** the normal of the vertex (defaut: 0,1,0) */
  61042. normal?: Vector3);
  61043. /**
  61044. * Clones the PositionNormalVertex
  61045. * @returns the cloned PositionNormalVertex
  61046. */
  61047. clone(): PositionNormalVertex;
  61048. }
  61049. /**
  61050. * Contains position, normal and uv vectors for a vertex
  61051. */
  61052. export class PositionNormalTextureVertex {
  61053. /** the position of the vertex (defaut: 0,0,0) */
  61054. position: Vector3;
  61055. /** the normal of the vertex (defaut: 0,1,0) */
  61056. normal: Vector3;
  61057. /** the uv of the vertex (default: 0,0) */
  61058. uv: Vector2;
  61059. /**
  61060. * Creates a PositionNormalTextureVertex
  61061. * @param position the position of the vertex (defaut: 0,0,0)
  61062. * @param normal the normal of the vertex (defaut: 0,1,0)
  61063. * @param uv the uv of the vertex (default: 0,0)
  61064. */
  61065. constructor(
  61066. /** the position of the vertex (defaut: 0,0,0) */
  61067. position?: Vector3,
  61068. /** the normal of the vertex (defaut: 0,1,0) */
  61069. normal?: Vector3,
  61070. /** the uv of the vertex (default: 0,0) */
  61071. uv?: Vector2);
  61072. /**
  61073. * Clones the PositionNormalTextureVertex
  61074. * @returns the cloned PositionNormalTextureVertex
  61075. */
  61076. clone(): PositionNormalTextureVertex;
  61077. }
  61078. /**
  61079. * @hidden
  61080. */
  61081. export class Tmp {
  61082. static Color3: Color3[];
  61083. static Color4: Color4[];
  61084. static Vector2: Vector2[];
  61085. static Vector3: Vector3[];
  61086. static Vector4: Vector4[];
  61087. static Quaternion: Quaternion[];
  61088. static Matrix: Matrix[];
  61089. }
  61090. }
  61091. declare module BABYLON {
  61092. /**
  61093. * Class used to enable access to offline support
  61094. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61095. */
  61096. export interface IOfflineProvider {
  61097. /**
  61098. * Gets a boolean indicating if scene must be saved in the database
  61099. */
  61100. enableSceneOffline: boolean;
  61101. /**
  61102. * Gets a boolean indicating if textures must be saved in the database
  61103. */
  61104. enableTexturesOffline: boolean;
  61105. /**
  61106. * Open the offline support and make it available
  61107. * @param successCallback defines the callback to call on success
  61108. * @param errorCallback defines the callback to call on error
  61109. */
  61110. open(successCallback: () => void, errorCallback: () => void): void;
  61111. /**
  61112. * Loads an image from the offline support
  61113. * @param url defines the url to load from
  61114. * @param image defines the target DOM image
  61115. */
  61116. loadImage(url: string, image: HTMLImageElement): void;
  61117. /**
  61118. * Loads a file from offline support
  61119. * @param url defines the URL to load from
  61120. * @param sceneLoaded defines a callback to call on success
  61121. * @param progressCallBack defines a callback to call when progress changed
  61122. * @param errorCallback defines a callback to call on error
  61123. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61124. */
  61125. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61126. }
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * A class serves as a medium between the observable and its observers
  61131. */
  61132. export class EventState {
  61133. /**
  61134. * Create a new EventState
  61135. * @param mask defines the mask associated with this state
  61136. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61137. * @param target defines the original target of the state
  61138. * @param currentTarget defines the current target of the state
  61139. */
  61140. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61141. /**
  61142. * Initialize the current event state
  61143. * @param mask defines the mask associated with this state
  61144. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61145. * @param target defines the original target of the state
  61146. * @param currentTarget defines the current target of the state
  61147. * @returns the current event state
  61148. */
  61149. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61150. /**
  61151. * An Observer can set this property to true to prevent subsequent observers of being notified
  61152. */
  61153. skipNextObservers: boolean;
  61154. /**
  61155. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61156. */
  61157. mask: number;
  61158. /**
  61159. * The object that originally notified the event
  61160. */
  61161. target?: any;
  61162. /**
  61163. * The current object in the bubbling phase
  61164. */
  61165. currentTarget?: any;
  61166. /**
  61167. * This will be populated with the return value of the last function that was executed.
  61168. * If it is the first function in the callback chain it will be the event data.
  61169. */
  61170. lastReturnValue?: any;
  61171. }
  61172. /**
  61173. * Represent an Observer registered to a given Observable object.
  61174. */
  61175. export class Observer<T> {
  61176. /**
  61177. * Defines the callback to call when the observer is notified
  61178. */
  61179. callback: (eventData: T, eventState: EventState) => void;
  61180. /**
  61181. * Defines the mask of the observer (used to filter notifications)
  61182. */
  61183. mask: number;
  61184. /**
  61185. * Defines the current scope used to restore the JS context
  61186. */
  61187. scope: any;
  61188. /** @hidden */
  61189. _willBeUnregistered: boolean;
  61190. /**
  61191. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61192. */
  61193. unregisterOnNextCall: boolean;
  61194. /**
  61195. * Creates a new observer
  61196. * @param callback defines the callback to call when the observer is notified
  61197. * @param mask defines the mask of the observer (used to filter notifications)
  61198. * @param scope defines the current scope used to restore the JS context
  61199. */
  61200. constructor(
  61201. /**
  61202. * Defines the callback to call when the observer is notified
  61203. */
  61204. callback: (eventData: T, eventState: EventState) => void,
  61205. /**
  61206. * Defines the mask of the observer (used to filter notifications)
  61207. */
  61208. mask: number,
  61209. /**
  61210. * Defines the current scope used to restore the JS context
  61211. */
  61212. scope?: any);
  61213. }
  61214. /**
  61215. * Represent a list of observers registered to multiple Observables object.
  61216. */
  61217. export class MultiObserver<T> {
  61218. private _observers;
  61219. private _observables;
  61220. /**
  61221. * Release associated resources
  61222. */
  61223. dispose(): void;
  61224. /**
  61225. * Raise a callback when one of the observable will notify
  61226. * @param observables defines a list of observables to watch
  61227. * @param callback defines the callback to call on notification
  61228. * @param mask defines the mask used to filter notifications
  61229. * @param scope defines the current scope used to restore the JS context
  61230. * @returns the new MultiObserver
  61231. */
  61232. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61233. }
  61234. /**
  61235. * The Observable class is a simple implementation of the Observable pattern.
  61236. *
  61237. * 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.
  61238. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61239. * 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).
  61240. * 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.
  61241. */
  61242. export class Observable<T> {
  61243. private _observers;
  61244. private _eventState;
  61245. private _onObserverAdded;
  61246. /**
  61247. * Creates a new observable
  61248. * @param onObserverAdded defines a callback to call when a new observer is added
  61249. */
  61250. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61251. /**
  61252. * Create a new Observer with the specified callback
  61253. * @param callback the callback that will be executed for that Observer
  61254. * @param mask the mask used to filter observers
  61255. * @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.
  61256. * @param scope optional scope for the callback to be called from
  61257. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61258. * @returns the new observer created for the callback
  61259. */
  61260. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61261. /**
  61262. * Create a new Observer with the specified callback and unregisters after the next notification
  61263. * @param callback the callback that will be executed for that Observer
  61264. * @returns the new observer created for the callback
  61265. */
  61266. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61267. /**
  61268. * Remove an Observer from the Observable object
  61269. * @param observer the instance of the Observer to remove
  61270. * @returns false if it doesn't belong to this Observable
  61271. */
  61272. remove(observer: Nullable<Observer<T>>): boolean;
  61273. /**
  61274. * Remove a callback from the Observable object
  61275. * @param callback the callback to remove
  61276. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61277. * @returns false if it doesn't belong to this Observable
  61278. */
  61279. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61280. private _deferUnregister;
  61281. private _remove;
  61282. /**
  61283. * Notify all Observers by calling their respective callback with the given data
  61284. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61285. * @param eventData defines the data to send to all observers
  61286. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61287. * @param target defines the original target of the state
  61288. * @param currentTarget defines the current target of the state
  61289. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61290. */
  61291. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61292. /**
  61293. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61294. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61295. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61296. * and it is crucial that all callbacks will be executed.
  61297. * The order of the callbacks is kept, callbacks are not executed parallel.
  61298. *
  61299. * @param eventData The data to be sent to each callback
  61300. * @param mask is used to filter observers defaults to -1
  61301. * @param target defines the callback target (see EventState)
  61302. * @param currentTarget defines he current object in the bubbling phase
  61303. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61304. */
  61305. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61306. /**
  61307. * Notify a specific observer
  61308. * @param observer defines the observer to notify
  61309. * @param eventData defines the data to be sent to each callback
  61310. * @param mask is used to filter observers defaults to -1
  61311. */
  61312. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61313. /**
  61314. * Gets a boolean indicating if the observable has at least one observer
  61315. * @returns true is the Observable has at least one Observer registered
  61316. */
  61317. hasObservers(): boolean;
  61318. /**
  61319. * Clear the list of observers
  61320. */
  61321. clear(): void;
  61322. /**
  61323. * Clone the current observable
  61324. * @returns a new observable
  61325. */
  61326. clone(): Observable<T>;
  61327. /**
  61328. * Does this observable handles observer registered with a given mask
  61329. * @param mask defines the mask to be tested
  61330. * @return whether or not one observer registered with the given mask is handeled
  61331. **/
  61332. hasSpecificMask(mask?: number): boolean;
  61333. }
  61334. }
  61335. declare module BABYLON {
  61336. /**
  61337. * Class used to help managing file picking and drag'n'drop
  61338. * File Storage
  61339. */
  61340. export class FilesInputStore {
  61341. /**
  61342. * List of files ready to be loaded
  61343. */
  61344. static FilesToLoad: {
  61345. [key: string]: File;
  61346. };
  61347. }
  61348. }
  61349. declare module BABYLON {
  61350. /** Defines the cross module used constants to avoid circular dependncies */
  61351. export class Constants {
  61352. /** Defines that alpha blending is disabled */
  61353. static readonly ALPHA_DISABLE: number;
  61354. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61355. static readonly ALPHA_ADD: number;
  61356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61357. static readonly ALPHA_COMBINE: number;
  61358. /** Defines that alpha blending to DEST - SRC * DEST */
  61359. static readonly ALPHA_SUBTRACT: number;
  61360. /** Defines that alpha blending to SRC * DEST */
  61361. static readonly ALPHA_MULTIPLY: number;
  61362. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61363. static readonly ALPHA_MAXIMIZED: number;
  61364. /** Defines that alpha blending to SRC + DEST */
  61365. static readonly ALPHA_ONEONE: number;
  61366. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61367. static readonly ALPHA_PREMULTIPLIED: number;
  61368. /**
  61369. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61370. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61371. */
  61372. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61373. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61374. static readonly ALPHA_INTERPOLATE: number;
  61375. /**
  61376. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61377. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61378. */
  61379. static readonly ALPHA_SCREENMODE: number;
  61380. /** Defines that the ressource is not delayed*/
  61381. static readonly DELAYLOADSTATE_NONE: number;
  61382. /** Defines that the ressource was successfully delay loaded */
  61383. static readonly DELAYLOADSTATE_LOADED: number;
  61384. /** Defines that the ressource is currently delay loading */
  61385. static readonly DELAYLOADSTATE_LOADING: number;
  61386. /** Defines that the ressource is delayed and has not started loading */
  61387. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61389. static readonly NEVER: number;
  61390. /** 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 */
  61391. static readonly ALWAYS: number;
  61392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61393. static readonly LESS: number;
  61394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61395. static readonly EQUAL: number;
  61396. /** 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 */
  61397. static readonly LEQUAL: number;
  61398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61399. static readonly GREATER: number;
  61400. /** 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 */
  61401. static readonly GEQUAL: number;
  61402. /** 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 */
  61403. static readonly NOTEQUAL: number;
  61404. /** Passed to stencilOperation to specify that stencil value must be kept */
  61405. static readonly KEEP: number;
  61406. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61407. static readonly REPLACE: number;
  61408. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61409. static readonly INCR: number;
  61410. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61411. static readonly DECR: number;
  61412. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61413. static readonly INVERT: number;
  61414. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61415. static readonly INCR_WRAP: number;
  61416. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61417. static readonly DECR_WRAP: number;
  61418. /** Texture is not repeating outside of 0..1 UVs */
  61419. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61420. /** Texture is repeating outside of 0..1 UVs */
  61421. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61422. /** Texture is repeating and mirrored */
  61423. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61424. /** ALPHA */
  61425. static readonly TEXTUREFORMAT_ALPHA: number;
  61426. /** LUMINANCE */
  61427. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61428. /** LUMINANCE_ALPHA */
  61429. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61430. /** RGB */
  61431. static readonly TEXTUREFORMAT_RGB: number;
  61432. /** RGBA */
  61433. static readonly TEXTUREFORMAT_RGBA: number;
  61434. /** RED */
  61435. static readonly TEXTUREFORMAT_RED: number;
  61436. /** RED (2nd reference) */
  61437. static readonly TEXTUREFORMAT_R: number;
  61438. /** RG */
  61439. static readonly TEXTUREFORMAT_RG: number;
  61440. /** RED_INTEGER */
  61441. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61442. /** RED_INTEGER (2nd reference) */
  61443. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61444. /** RG_INTEGER */
  61445. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61446. /** RGB_INTEGER */
  61447. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61448. /** RGBA_INTEGER */
  61449. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61450. /** UNSIGNED_BYTE */
  61451. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61452. /** UNSIGNED_BYTE (2nd reference) */
  61453. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61454. /** FLOAT */
  61455. static readonly TEXTURETYPE_FLOAT: number;
  61456. /** HALF_FLOAT */
  61457. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61458. /** BYTE */
  61459. static readonly TEXTURETYPE_BYTE: number;
  61460. /** SHORT */
  61461. static readonly TEXTURETYPE_SHORT: number;
  61462. /** UNSIGNED_SHORT */
  61463. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61464. /** INT */
  61465. static readonly TEXTURETYPE_INT: number;
  61466. /** UNSIGNED_INT */
  61467. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61468. /** UNSIGNED_SHORT_4_4_4_4 */
  61469. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61470. /** UNSIGNED_SHORT_5_5_5_1 */
  61471. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61472. /** UNSIGNED_SHORT_5_6_5 */
  61473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61474. /** UNSIGNED_INT_2_10_10_10_REV */
  61475. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61476. /** UNSIGNED_INT_24_8 */
  61477. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61478. /** UNSIGNED_INT_10F_11F_11F_REV */
  61479. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61480. /** UNSIGNED_INT_5_9_9_9_REV */
  61481. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61482. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61483. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61484. /** nearest is mag = nearest and min = nearest and mip = linear */
  61485. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61487. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61488. /** Trilinear is mag = linear and min = linear and mip = linear */
  61489. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61490. /** nearest is mag = nearest and min = nearest and mip = linear */
  61491. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61492. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61493. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61494. /** Trilinear is mag = linear and min = linear and mip = linear */
  61495. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61496. /** mag = nearest and min = nearest and mip = nearest */
  61497. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61498. /** mag = nearest and min = linear and mip = nearest */
  61499. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61500. /** mag = nearest and min = linear and mip = linear */
  61501. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61502. /** mag = nearest and min = linear and mip = none */
  61503. static readonly TEXTURE_NEAREST_LINEAR: number;
  61504. /** mag = nearest and min = nearest and mip = none */
  61505. static readonly TEXTURE_NEAREST_NEAREST: number;
  61506. /** mag = linear and min = nearest and mip = nearest */
  61507. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61508. /** mag = linear and min = nearest and mip = linear */
  61509. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61510. /** mag = linear and min = linear and mip = none */
  61511. static readonly TEXTURE_LINEAR_LINEAR: number;
  61512. /** mag = linear and min = nearest and mip = none */
  61513. static readonly TEXTURE_LINEAR_NEAREST: number;
  61514. /** Explicit coordinates mode */
  61515. static readonly TEXTURE_EXPLICIT_MODE: number;
  61516. /** Spherical coordinates mode */
  61517. static readonly TEXTURE_SPHERICAL_MODE: number;
  61518. /** Planar coordinates mode */
  61519. static readonly TEXTURE_PLANAR_MODE: number;
  61520. /** Cubic coordinates mode */
  61521. static readonly TEXTURE_CUBIC_MODE: number;
  61522. /** Projection coordinates mode */
  61523. static readonly TEXTURE_PROJECTION_MODE: number;
  61524. /** Skybox coordinates mode */
  61525. static readonly TEXTURE_SKYBOX_MODE: number;
  61526. /** Inverse Cubic coordinates mode */
  61527. static readonly TEXTURE_INVCUBIC_MODE: number;
  61528. /** Equirectangular coordinates mode */
  61529. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61530. /** Equirectangular Fixed coordinates mode */
  61531. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61532. /** Equirectangular Fixed Mirrored coordinates mode */
  61533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61534. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61535. static readonly SCALEMODE_FLOOR: number;
  61536. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61537. static readonly SCALEMODE_NEAREST: number;
  61538. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61539. static readonly SCALEMODE_CEILING: number;
  61540. /**
  61541. * The dirty texture flag value
  61542. */
  61543. static readonly MATERIAL_TextureDirtyFlag: number;
  61544. /**
  61545. * The dirty light flag value
  61546. */
  61547. static readonly MATERIAL_LightDirtyFlag: number;
  61548. /**
  61549. * The dirty fresnel flag value
  61550. */
  61551. static readonly MATERIAL_FresnelDirtyFlag: number;
  61552. /**
  61553. * The dirty attribute flag value
  61554. */
  61555. static readonly MATERIAL_AttributesDirtyFlag: number;
  61556. /**
  61557. * The dirty misc flag value
  61558. */
  61559. static readonly MATERIAL_MiscDirtyFlag: number;
  61560. /**
  61561. * The all dirty flag value
  61562. */
  61563. static readonly MATERIAL_AllDirtyFlag: number;
  61564. /**
  61565. * Returns the triangle fill mode
  61566. */
  61567. static readonly MATERIAL_TriangleFillMode: number;
  61568. /**
  61569. * Returns the wireframe mode
  61570. */
  61571. static readonly MATERIAL_WireFrameFillMode: number;
  61572. /**
  61573. * Returns the point fill mode
  61574. */
  61575. static readonly MATERIAL_PointFillMode: number;
  61576. /**
  61577. * Returns the point list draw mode
  61578. */
  61579. static readonly MATERIAL_PointListDrawMode: number;
  61580. /**
  61581. * Returns the line list draw mode
  61582. */
  61583. static readonly MATERIAL_LineListDrawMode: number;
  61584. /**
  61585. * Returns the line loop draw mode
  61586. */
  61587. static readonly MATERIAL_LineLoopDrawMode: number;
  61588. /**
  61589. * Returns the line strip draw mode
  61590. */
  61591. static readonly MATERIAL_LineStripDrawMode: number;
  61592. /**
  61593. * Returns the triangle strip draw mode
  61594. */
  61595. static readonly MATERIAL_TriangleStripDrawMode: number;
  61596. /**
  61597. * Returns the triangle fan draw mode
  61598. */
  61599. static readonly MATERIAL_TriangleFanDrawMode: number;
  61600. /**
  61601. * Stores the clock-wise side orientation
  61602. */
  61603. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61604. /**
  61605. * Stores the counter clock-wise side orientation
  61606. */
  61607. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61608. /**
  61609. * Nothing
  61610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61611. */
  61612. static readonly ACTION_NothingTrigger: number;
  61613. /**
  61614. * On pick
  61615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61616. */
  61617. static readonly ACTION_OnPickTrigger: number;
  61618. /**
  61619. * On left pick
  61620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61621. */
  61622. static readonly ACTION_OnLeftPickTrigger: number;
  61623. /**
  61624. * On right pick
  61625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61626. */
  61627. static readonly ACTION_OnRightPickTrigger: number;
  61628. /**
  61629. * On center pick
  61630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61631. */
  61632. static readonly ACTION_OnCenterPickTrigger: number;
  61633. /**
  61634. * On pick down
  61635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61636. */
  61637. static readonly ACTION_OnPickDownTrigger: number;
  61638. /**
  61639. * On double pick
  61640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61641. */
  61642. static readonly ACTION_OnDoublePickTrigger: number;
  61643. /**
  61644. * On pick up
  61645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61646. */
  61647. static readonly ACTION_OnPickUpTrigger: number;
  61648. /**
  61649. * On pick out.
  61650. * This trigger will only be raised if you also declared a OnPickDown
  61651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61652. */
  61653. static readonly ACTION_OnPickOutTrigger: number;
  61654. /**
  61655. * On long press
  61656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61657. */
  61658. static readonly ACTION_OnLongPressTrigger: number;
  61659. /**
  61660. * On pointer over
  61661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61662. */
  61663. static readonly ACTION_OnPointerOverTrigger: number;
  61664. /**
  61665. * On pointer out
  61666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61667. */
  61668. static readonly ACTION_OnPointerOutTrigger: number;
  61669. /**
  61670. * On every frame
  61671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61672. */
  61673. static readonly ACTION_OnEveryFrameTrigger: number;
  61674. /**
  61675. * On intersection enter
  61676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61677. */
  61678. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61679. /**
  61680. * On intersection exit
  61681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61682. */
  61683. static readonly ACTION_OnIntersectionExitTrigger: number;
  61684. /**
  61685. * On key down
  61686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61687. */
  61688. static readonly ACTION_OnKeyDownTrigger: number;
  61689. /**
  61690. * On key up
  61691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61692. */
  61693. static readonly ACTION_OnKeyUpTrigger: number;
  61694. /**
  61695. * Billboard mode will only apply to Y axis
  61696. */
  61697. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61698. /**
  61699. * Billboard mode will apply to all axes
  61700. */
  61701. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61702. /**
  61703. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61704. */
  61705. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61706. /**
  61707. * Gets or sets base Assets URL
  61708. */
  61709. static readonly PARTICLES_BaseAssetsUrl: string;
  61710. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61711. * Test order :
  61712. * Is the bounding sphere outside the frustum ?
  61713. * If not, are the bounding box vertices outside the frustum ?
  61714. * It not, then the cullable object is in the frustum.
  61715. */
  61716. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61717. /** Culling strategy : Bounding Sphere Only.
  61718. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61719. * It's also less accurate than the standard because some not visible objects can still be selected.
  61720. * Test : is the bounding sphere outside the frustum ?
  61721. * If not, then the cullable object is in the frustum.
  61722. */
  61723. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61724. /** Culling strategy : Optimistic Inclusion.
  61725. * This in an inclusion test first, then the standard exclusion test.
  61726. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61727. * 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.
  61728. * Anyway, it's as accurate as the standard strategy.
  61729. * Test :
  61730. * Is the cullable object bounding sphere center in the frustum ?
  61731. * If not, apply the default culling strategy.
  61732. */
  61733. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61734. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61735. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61736. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61737. * 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.
  61738. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61739. * Test :
  61740. * Is the cullable object bounding sphere center in the frustum ?
  61741. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61742. */
  61743. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61744. /**
  61745. * No logging while loading
  61746. */
  61747. static readonly SCENELOADER_NO_LOGGING: number;
  61748. /**
  61749. * Minimal logging while loading
  61750. */
  61751. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61752. /**
  61753. * Summary logging while loading
  61754. */
  61755. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61756. /**
  61757. * Detailled logging while loading
  61758. */
  61759. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61760. }
  61761. }
  61762. declare module BABYLON {
  61763. /**
  61764. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61765. * Babylon.js
  61766. */
  61767. export class DomManagement {
  61768. /**
  61769. * Checks if the window object exists
  61770. * @returns true if the window object exists
  61771. */
  61772. static IsWindowObjectExist(): boolean;
  61773. /**
  61774. * Extracts text content from a DOM element hierarchy
  61775. * @param element defines the root element
  61776. * @returns a string
  61777. */
  61778. static GetDOMTextContent(element: HTMLElement): string;
  61779. }
  61780. }
  61781. declare module BABYLON {
  61782. /**
  61783. * Logger used througouht the application to allow configuration of
  61784. * the log level required for the messages.
  61785. */
  61786. export class Logger {
  61787. /**
  61788. * No log
  61789. */
  61790. static readonly NoneLogLevel: number;
  61791. /**
  61792. * Only message logs
  61793. */
  61794. static readonly MessageLogLevel: number;
  61795. /**
  61796. * Only warning logs
  61797. */
  61798. static readonly WarningLogLevel: number;
  61799. /**
  61800. * Only error logs
  61801. */
  61802. static readonly ErrorLogLevel: number;
  61803. /**
  61804. * All logs
  61805. */
  61806. static readonly AllLogLevel: number;
  61807. private static _LogCache;
  61808. /**
  61809. * Gets a value indicating the number of loading errors
  61810. * @ignorenaming
  61811. */
  61812. static errorsCount: number;
  61813. /**
  61814. * Callback called when a new log is added
  61815. */
  61816. static OnNewCacheEntry: (entry: string) => void;
  61817. private static _AddLogEntry;
  61818. private static _FormatMessage;
  61819. private static _LogDisabled;
  61820. private static _LogEnabled;
  61821. private static _WarnDisabled;
  61822. private static _WarnEnabled;
  61823. private static _ErrorDisabled;
  61824. private static _ErrorEnabled;
  61825. /**
  61826. * Log a message to the console
  61827. */
  61828. static Log: (message: string) => void;
  61829. /**
  61830. * Write a warning message to the console
  61831. */
  61832. static Warn: (message: string) => void;
  61833. /**
  61834. * Write an error message to the console
  61835. */
  61836. static Error: (message: string) => void;
  61837. /**
  61838. * Gets current log cache (list of logs)
  61839. */
  61840. static readonly LogCache: string;
  61841. /**
  61842. * Clears the log cache
  61843. */
  61844. static ClearLogCache(): void;
  61845. /**
  61846. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61847. */
  61848. static LogLevels: number;
  61849. }
  61850. }
  61851. declare module BABYLON {
  61852. /** @hidden */
  61853. export class _TypeStore {
  61854. /** @hidden */
  61855. static RegisteredTypes: {
  61856. [key: string]: Object;
  61857. };
  61858. /** @hidden */
  61859. static GetClass(fqdn: string): any;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /**
  61864. * Class containing a set of static utilities functions for deep copy.
  61865. */
  61866. export class DeepCopier {
  61867. /**
  61868. * Tries to copy an object by duplicating every property
  61869. * @param source defines the source object
  61870. * @param destination defines the target object
  61871. * @param doNotCopyList defines a list of properties to avoid
  61872. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61873. */
  61874. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61875. }
  61876. }
  61877. declare module BABYLON {
  61878. /**
  61879. * Class containing a set of static utilities functions for precision date
  61880. */
  61881. export class PrecisionDate {
  61882. /**
  61883. * Gets either window.performance.now() if supported or Date.now() else
  61884. */
  61885. static readonly Now: number;
  61886. }
  61887. }
  61888. declare module BABYLON {
  61889. /** @hidden */
  61890. export class _DevTools {
  61891. static WarnImport(name: string): string;
  61892. }
  61893. }
  61894. declare module BABYLON {
  61895. /**
  61896. * Class used to evalaute queries containing `and` and `or` operators
  61897. */
  61898. export class AndOrNotEvaluator {
  61899. /**
  61900. * Evaluate a query
  61901. * @param query defines the query to evaluate
  61902. * @param evaluateCallback defines the callback used to filter result
  61903. * @returns true if the query matches
  61904. */
  61905. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61906. private static _HandleParenthesisContent;
  61907. private static _SimplifyNegation;
  61908. }
  61909. }
  61910. declare module BABYLON {
  61911. /**
  61912. * Class used to store custom tags
  61913. */
  61914. export class Tags {
  61915. /**
  61916. * Adds support for tags on the given object
  61917. * @param obj defines the object to use
  61918. */
  61919. static EnableFor(obj: any): void;
  61920. /**
  61921. * Removes tags support
  61922. * @param obj defines the object to use
  61923. */
  61924. static DisableFor(obj: any): void;
  61925. /**
  61926. * Gets a boolean indicating if the given object has tags
  61927. * @param obj defines the object to use
  61928. * @returns a boolean
  61929. */
  61930. static HasTags(obj: any): boolean;
  61931. /**
  61932. * Gets the tags available on a given object
  61933. * @param obj defines the object to use
  61934. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61935. * @returns the tags
  61936. */
  61937. static GetTags(obj: any, asString?: boolean): any;
  61938. /**
  61939. * Adds tags to an object
  61940. * @param obj defines the object to use
  61941. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61942. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61943. */
  61944. static AddTagsTo(obj: any, tagsString: string): void;
  61945. /**
  61946. * @hidden
  61947. */
  61948. static _AddTagTo(obj: any, tag: string): void;
  61949. /**
  61950. * Removes specific tags from a specific object
  61951. * @param obj defines the object to use
  61952. * @param tagsString defines the tags to remove
  61953. */
  61954. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61955. /**
  61956. * @hidden
  61957. */
  61958. static _RemoveTagFrom(obj: any, tag: string): void;
  61959. /**
  61960. * Defines if tags hosted on an object match a given query
  61961. * @param obj defines the object to use
  61962. * @param tagsQuery defines the tag query
  61963. * @returns a boolean
  61964. */
  61965. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61966. }
  61967. }
  61968. declare module BABYLON {
  61969. /**
  61970. * Manages the defines for the Material
  61971. */
  61972. export class MaterialDefines {
  61973. private _keys;
  61974. private _isDirty;
  61975. /** @hidden */
  61976. _renderId: number;
  61977. /** @hidden */
  61978. _areLightsDirty: boolean;
  61979. /** @hidden */
  61980. _areAttributesDirty: boolean;
  61981. /** @hidden */
  61982. _areTexturesDirty: boolean;
  61983. /** @hidden */
  61984. _areFresnelDirty: boolean;
  61985. /** @hidden */
  61986. _areMiscDirty: boolean;
  61987. /** @hidden */
  61988. _areImageProcessingDirty: boolean;
  61989. /** @hidden */
  61990. _normals: boolean;
  61991. /** @hidden */
  61992. _uvs: boolean;
  61993. /** @hidden */
  61994. _needNormals: boolean;
  61995. /** @hidden */
  61996. _needUVs: boolean;
  61997. /**
  61998. * Specifies if the material needs to be re-calculated
  61999. */
  62000. readonly isDirty: boolean;
  62001. /**
  62002. * Marks the material to indicate that it has been re-calculated
  62003. */
  62004. markAsProcessed(): void;
  62005. /**
  62006. * Marks the material to indicate that it needs to be re-calculated
  62007. */
  62008. markAsUnprocessed(): void;
  62009. /**
  62010. * Marks the material to indicate all of its defines need to be re-calculated
  62011. */
  62012. markAllAsDirty(): void;
  62013. /**
  62014. * Marks the material to indicate that image processing needs to be re-calculated
  62015. */
  62016. markAsImageProcessingDirty(): void;
  62017. /**
  62018. * Marks the material to indicate the lights need to be re-calculated
  62019. */
  62020. markAsLightDirty(): void;
  62021. /**
  62022. * Marks the attribute state as changed
  62023. */
  62024. markAsAttributesDirty(): void;
  62025. /**
  62026. * Marks the texture state as changed
  62027. */
  62028. markAsTexturesDirty(): void;
  62029. /**
  62030. * Marks the fresnel state as changed
  62031. */
  62032. markAsFresnelDirty(): void;
  62033. /**
  62034. * Marks the misc state as changed
  62035. */
  62036. markAsMiscDirty(): void;
  62037. /**
  62038. * Rebuilds the material defines
  62039. */
  62040. rebuild(): void;
  62041. /**
  62042. * Specifies if two material defines are equal
  62043. * @param other - A material define instance to compare to
  62044. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62045. */
  62046. isEqual(other: MaterialDefines): boolean;
  62047. /**
  62048. * Clones this instance's defines to another instance
  62049. * @param other - material defines to clone values to
  62050. */
  62051. cloneTo(other: MaterialDefines): void;
  62052. /**
  62053. * Resets the material define values
  62054. */
  62055. reset(): void;
  62056. /**
  62057. * Converts the material define values to a string
  62058. * @returns - String of material define information
  62059. */
  62060. toString(): string;
  62061. }
  62062. }
  62063. declare module BABYLON {
  62064. /**
  62065. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62066. */
  62067. export class PerformanceMonitor {
  62068. private _enabled;
  62069. private _rollingFrameTime;
  62070. private _lastFrameTimeMs;
  62071. /**
  62072. * constructor
  62073. * @param frameSampleSize The number of samples required to saturate the sliding window
  62074. */
  62075. constructor(frameSampleSize?: number);
  62076. /**
  62077. * Samples current frame
  62078. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62079. */
  62080. sampleFrame(timeMs?: number): void;
  62081. /**
  62082. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62083. */
  62084. readonly averageFrameTime: number;
  62085. /**
  62086. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62087. */
  62088. readonly averageFrameTimeVariance: number;
  62089. /**
  62090. * Returns the frame time of the most recent frame
  62091. */
  62092. readonly instantaneousFrameTime: number;
  62093. /**
  62094. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62095. */
  62096. readonly averageFPS: number;
  62097. /**
  62098. * Returns the average framerate in frames per second using the most recent frame time
  62099. */
  62100. readonly instantaneousFPS: number;
  62101. /**
  62102. * Returns true if enough samples have been taken to completely fill the sliding window
  62103. */
  62104. readonly isSaturated: boolean;
  62105. /**
  62106. * Enables contributions to the sliding window sample set
  62107. */
  62108. enable(): void;
  62109. /**
  62110. * Disables contributions to the sliding window sample set
  62111. * Samples will not be interpolated over the disabled period
  62112. */
  62113. disable(): void;
  62114. /**
  62115. * Returns true if sampling is enabled
  62116. */
  62117. readonly isEnabled: boolean;
  62118. /**
  62119. * Resets performance monitor
  62120. */
  62121. reset(): void;
  62122. }
  62123. /**
  62124. * RollingAverage
  62125. *
  62126. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62127. */
  62128. export class RollingAverage {
  62129. /**
  62130. * Current average
  62131. */
  62132. average: number;
  62133. /**
  62134. * Current variance
  62135. */
  62136. variance: number;
  62137. protected _samples: Array<number>;
  62138. protected _sampleCount: number;
  62139. protected _pos: number;
  62140. protected _m2: number;
  62141. /**
  62142. * constructor
  62143. * @param length The number of samples required to saturate the sliding window
  62144. */
  62145. constructor(length: number);
  62146. /**
  62147. * Adds a sample to the sample set
  62148. * @param v The sample value
  62149. */
  62150. add(v: number): void;
  62151. /**
  62152. * Returns previously added values or null if outside of history or outside the sliding window domain
  62153. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62154. * @return Value previously recorded with add() or null if outside of range
  62155. */
  62156. history(i: number): number;
  62157. /**
  62158. * Returns true if enough samples have been taken to completely fill the sliding window
  62159. * @return true if sample-set saturated
  62160. */
  62161. isSaturated(): boolean;
  62162. /**
  62163. * Resets the rolling average (equivalent to 0 samples taken so far)
  62164. */
  62165. reset(): void;
  62166. /**
  62167. * Wraps a value around the sample range boundaries
  62168. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62169. * @return Wrapped position in sample range
  62170. */
  62171. protected _wrapPosition(i: number): number;
  62172. }
  62173. }
  62174. declare module BABYLON {
  62175. /**
  62176. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62177. * The underlying implementation relies on an associative array to ensure the best performances.
  62178. * The value can be anything including 'null' but except 'undefined'
  62179. */
  62180. export class StringDictionary<T> {
  62181. /**
  62182. * This will clear this dictionary and copy the content from the 'source' one.
  62183. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62184. * @param source the dictionary to take the content from and copy to this dictionary
  62185. */
  62186. copyFrom(source: StringDictionary<T>): void;
  62187. /**
  62188. * Get a value based from its key
  62189. * @param key the given key to get the matching value from
  62190. * @return the value if found, otherwise undefined is returned
  62191. */
  62192. get(key: string): T | undefined;
  62193. /**
  62194. * Get a value from its key or add it if it doesn't exist.
  62195. * This method will ensure you that a given key/data will be present in the dictionary.
  62196. * @param key the given key to get the matching value from
  62197. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62198. * The factory will only be invoked if there's no data for the given key.
  62199. * @return the value corresponding to the key.
  62200. */
  62201. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62202. /**
  62203. * Get a value from its key if present in the dictionary otherwise add it
  62204. * @param key the key to get the value from
  62205. * @param val if there's no such key/value pair in the dictionary add it with this value
  62206. * @return the value corresponding to the key
  62207. */
  62208. getOrAdd(key: string, val: T): T;
  62209. /**
  62210. * Check if there's a given key in the dictionary
  62211. * @param key the key to check for
  62212. * @return true if the key is present, false otherwise
  62213. */
  62214. contains(key: string): boolean;
  62215. /**
  62216. * Add a new key and its corresponding value
  62217. * @param key the key to add
  62218. * @param value the value corresponding to the key
  62219. * @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
  62220. */
  62221. add(key: string, value: T): boolean;
  62222. /**
  62223. * Update a specific value associated to a key
  62224. * @param key defines the key to use
  62225. * @param value defines the value to store
  62226. * @returns true if the value was updated (or false if the key was not found)
  62227. */
  62228. set(key: string, value: T): boolean;
  62229. /**
  62230. * Get the element of the given key and remove it from the dictionary
  62231. * @param key defines the key to search
  62232. * @returns the value associated with the key or null if not found
  62233. */
  62234. getAndRemove(key: string): Nullable<T>;
  62235. /**
  62236. * Remove a key/value from the dictionary.
  62237. * @param key the key to remove
  62238. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62239. */
  62240. remove(key: string): boolean;
  62241. /**
  62242. * Clear the whole content of the dictionary
  62243. */
  62244. clear(): void;
  62245. /**
  62246. * Gets the current count
  62247. */
  62248. readonly count: number;
  62249. /**
  62250. * Execute a callback on each key/val of the dictionary.
  62251. * Note that you can remove any element in this dictionary in the callback implementation
  62252. * @param callback the callback to execute on a given key/value pair
  62253. */
  62254. forEach(callback: (key: string, val: T) => void): void;
  62255. /**
  62256. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62257. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62258. * Note that you can remove any element in this dictionary in the callback implementation
  62259. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62260. * @returns the first item
  62261. */
  62262. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62263. private _count;
  62264. private _data;
  62265. }
  62266. }
  62267. declare module BABYLON {
  62268. /**
  62269. * Helper class that provides a small promise polyfill
  62270. */
  62271. export class PromisePolyfill {
  62272. /**
  62273. * Static function used to check if the polyfill is required
  62274. * If this is the case then the function will inject the polyfill to window.Promise
  62275. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62276. */
  62277. static Apply(force?: boolean): void;
  62278. }
  62279. }
  62280. declare module BABYLON {
  62281. /**
  62282. * Class used to store data that will be store in GPU memory
  62283. */
  62284. export class Buffer {
  62285. private _engine;
  62286. private _buffer;
  62287. /** @hidden */
  62288. _data: Nullable<DataArray>;
  62289. private _updatable;
  62290. private _instanced;
  62291. /**
  62292. * Gets the byte stride.
  62293. */
  62294. readonly byteStride: number;
  62295. /**
  62296. * Constructor
  62297. * @param engine the engine
  62298. * @param data the data to use for this buffer
  62299. * @param updatable whether the data is updatable
  62300. * @param stride the stride (optional)
  62301. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62302. * @param instanced whether the buffer is instanced (optional)
  62303. * @param useBytes set to true if the stride in in bytes (optional)
  62304. */
  62305. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62306. /**
  62307. * Create a new VertexBuffer based on the current buffer
  62308. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62309. * @param offset defines offset in the buffer (0 by default)
  62310. * @param size defines the size in floats of attributes (position is 3 for instance)
  62311. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62312. * @param instanced defines if the vertex buffer contains indexed data
  62313. * @param useBytes defines if the offset and stride are in bytes
  62314. * @returns the new vertex buffer
  62315. */
  62316. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62317. /**
  62318. * Gets a boolean indicating if the Buffer is updatable?
  62319. * @returns true if the buffer is updatable
  62320. */
  62321. isUpdatable(): boolean;
  62322. /**
  62323. * Gets current buffer's data
  62324. * @returns a DataArray or null
  62325. */
  62326. getData(): Nullable<DataArray>;
  62327. /**
  62328. * Gets underlying native buffer
  62329. * @returns underlying native buffer
  62330. */
  62331. getBuffer(): Nullable<WebGLBuffer>;
  62332. /**
  62333. * Gets the stride in float32 units (i.e. byte stride / 4).
  62334. * May not be an integer if the byte stride is not divisible by 4.
  62335. * DEPRECATED. Use byteStride instead.
  62336. * @returns the stride in float32 units
  62337. */
  62338. getStrideSize(): number;
  62339. /**
  62340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62341. * @param data defines the data to store
  62342. */
  62343. create(data?: Nullable<DataArray>): void;
  62344. /** @hidden */
  62345. _rebuild(): void;
  62346. /**
  62347. * Update current buffer data
  62348. * @param data defines the data to store
  62349. */
  62350. update(data: DataArray): void;
  62351. /**
  62352. * Updates the data directly.
  62353. * @param data the new data
  62354. * @param offset the new offset
  62355. * @param vertexCount the vertex count (optional)
  62356. * @param useBytes set to true if the offset is in bytes
  62357. */
  62358. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62359. /**
  62360. * Release all resources
  62361. */
  62362. dispose(): void;
  62363. }
  62364. /**
  62365. * Specialized buffer used to store vertex data
  62366. */
  62367. export class VertexBuffer {
  62368. /** @hidden */
  62369. _buffer: Buffer;
  62370. private _kind;
  62371. private _size;
  62372. private _ownsBuffer;
  62373. private _instanced;
  62374. private _instanceDivisor;
  62375. /**
  62376. * The byte type.
  62377. */
  62378. static readonly BYTE: number;
  62379. /**
  62380. * The unsigned byte type.
  62381. */
  62382. static readonly UNSIGNED_BYTE: number;
  62383. /**
  62384. * The short type.
  62385. */
  62386. static readonly SHORT: number;
  62387. /**
  62388. * The unsigned short type.
  62389. */
  62390. static readonly UNSIGNED_SHORT: number;
  62391. /**
  62392. * The integer type.
  62393. */
  62394. static readonly INT: number;
  62395. /**
  62396. * The unsigned integer type.
  62397. */
  62398. static readonly UNSIGNED_INT: number;
  62399. /**
  62400. * The float type.
  62401. */
  62402. static readonly FLOAT: number;
  62403. /**
  62404. * Gets or sets the instance divisor when in instanced mode
  62405. */
  62406. instanceDivisor: number;
  62407. /**
  62408. * Gets the byte stride.
  62409. */
  62410. readonly byteStride: number;
  62411. /**
  62412. * Gets the byte offset.
  62413. */
  62414. readonly byteOffset: number;
  62415. /**
  62416. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62417. */
  62418. readonly normalized: boolean;
  62419. /**
  62420. * Gets the data type of each component in the array.
  62421. */
  62422. readonly type: number;
  62423. /**
  62424. * Constructor
  62425. * @param engine the engine
  62426. * @param data the data to use for this vertex buffer
  62427. * @param kind the vertex buffer kind
  62428. * @param updatable whether the data is updatable
  62429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62430. * @param stride the stride (optional)
  62431. * @param instanced whether the buffer is instanced (optional)
  62432. * @param offset the offset of the data (optional)
  62433. * @param size the number of components (optional)
  62434. * @param type the type of the component (optional)
  62435. * @param normalized whether the data contains normalized data (optional)
  62436. * @param useBytes set to true if stride and offset are in bytes (optional)
  62437. */
  62438. 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);
  62439. /** @hidden */
  62440. _rebuild(): void;
  62441. /**
  62442. * Returns the kind of the VertexBuffer (string)
  62443. * @returns a string
  62444. */
  62445. getKind(): string;
  62446. /**
  62447. * Gets a boolean indicating if the VertexBuffer is updatable?
  62448. * @returns true if the buffer is updatable
  62449. */
  62450. isUpdatable(): boolean;
  62451. /**
  62452. * Gets current buffer's data
  62453. * @returns a DataArray or null
  62454. */
  62455. getData(): Nullable<DataArray>;
  62456. /**
  62457. * Gets underlying native buffer
  62458. * @returns underlying native buffer
  62459. */
  62460. getBuffer(): Nullable<WebGLBuffer>;
  62461. /**
  62462. * Gets the stride in float32 units (i.e. byte stride / 4).
  62463. * May not be an integer if the byte stride is not divisible by 4.
  62464. * DEPRECATED. Use byteStride instead.
  62465. * @returns the stride in float32 units
  62466. */
  62467. getStrideSize(): number;
  62468. /**
  62469. * Returns the offset as a multiple of the type byte length.
  62470. * DEPRECATED. Use byteOffset instead.
  62471. * @returns the offset in bytes
  62472. */
  62473. getOffset(): number;
  62474. /**
  62475. * Returns the number of components per vertex attribute (integer)
  62476. * @returns the size in float
  62477. */
  62478. getSize(): number;
  62479. /**
  62480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62481. * @returns true if this buffer is instanced
  62482. */
  62483. getIsInstanced(): boolean;
  62484. /**
  62485. * Returns the instancing divisor, zero for non-instanced (integer).
  62486. * @returns a number
  62487. */
  62488. getInstanceDivisor(): number;
  62489. /**
  62490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62491. * @param data defines the data to store
  62492. */
  62493. create(data?: DataArray): void;
  62494. /**
  62495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62496. * This function will create a new buffer if the current one is not updatable
  62497. * @param data defines the data to store
  62498. */
  62499. update(data: DataArray): void;
  62500. /**
  62501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62502. * Returns the directly updated WebGLBuffer.
  62503. * @param data the new data
  62504. * @param offset the new offset
  62505. * @param useBytes set to true if the offset is in bytes
  62506. */
  62507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62508. /**
  62509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62510. */
  62511. dispose(): void;
  62512. /**
  62513. * Enumerates each value of this vertex buffer as numbers.
  62514. * @param count the number of values to enumerate
  62515. * @param callback the callback function called for each value
  62516. */
  62517. forEach(count: number, callback: (value: number, index: number) => void): void;
  62518. /**
  62519. * Positions
  62520. */
  62521. static readonly PositionKind: string;
  62522. /**
  62523. * Normals
  62524. */
  62525. static readonly NormalKind: string;
  62526. /**
  62527. * Tangents
  62528. */
  62529. static readonly TangentKind: string;
  62530. /**
  62531. * Texture coordinates
  62532. */
  62533. static readonly UVKind: string;
  62534. /**
  62535. * Texture coordinates 2
  62536. */
  62537. static readonly UV2Kind: string;
  62538. /**
  62539. * Texture coordinates 3
  62540. */
  62541. static readonly UV3Kind: string;
  62542. /**
  62543. * Texture coordinates 4
  62544. */
  62545. static readonly UV4Kind: string;
  62546. /**
  62547. * Texture coordinates 5
  62548. */
  62549. static readonly UV5Kind: string;
  62550. /**
  62551. * Texture coordinates 6
  62552. */
  62553. static readonly UV6Kind: string;
  62554. /**
  62555. * Colors
  62556. */
  62557. static readonly ColorKind: string;
  62558. /**
  62559. * Matrix indices (for bones)
  62560. */
  62561. static readonly MatricesIndicesKind: string;
  62562. /**
  62563. * Matrix weights (for bones)
  62564. */
  62565. static readonly MatricesWeightsKind: string;
  62566. /**
  62567. * Additional matrix indices (for bones)
  62568. */
  62569. static readonly MatricesIndicesExtraKind: string;
  62570. /**
  62571. * Additional matrix weights (for bones)
  62572. */
  62573. static readonly MatricesWeightsExtraKind: string;
  62574. /**
  62575. * Deduces the stride given a kind.
  62576. * @param kind The kind string to deduce
  62577. * @returns The deduced stride
  62578. */
  62579. static DeduceStride(kind: string): number;
  62580. /**
  62581. * Gets the byte length of the given type.
  62582. * @param type the type
  62583. * @returns the number of bytes
  62584. */
  62585. static GetTypeByteLength(type: number): number;
  62586. /**
  62587. * Enumerates each value of the given parameters as numbers.
  62588. * @param data the data to enumerate
  62589. * @param byteOffset the byte offset of the data
  62590. * @param byteStride the byte stride of the data
  62591. * @param componentCount the number of components per element
  62592. * @param componentType the type of the component
  62593. * @param count the total number of components
  62594. * @param normalized whether the data is normalized
  62595. * @param callback the callback function called for each value
  62596. */
  62597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62598. private static _GetFloatValue;
  62599. }
  62600. }
  62601. declare module BABYLON {
  62602. /**
  62603. * Class representing spherical polynomial coefficients to the 3rd degree
  62604. */
  62605. export class SphericalPolynomial {
  62606. /**
  62607. * The x coefficients of the spherical polynomial
  62608. */
  62609. x: Vector3;
  62610. /**
  62611. * The y coefficients of the spherical polynomial
  62612. */
  62613. y: Vector3;
  62614. /**
  62615. * The z coefficients of the spherical polynomial
  62616. */
  62617. z: Vector3;
  62618. /**
  62619. * The xx coefficients of the spherical polynomial
  62620. */
  62621. xx: Vector3;
  62622. /**
  62623. * The yy coefficients of the spherical polynomial
  62624. */
  62625. yy: Vector3;
  62626. /**
  62627. * The zz coefficients of the spherical polynomial
  62628. */
  62629. zz: Vector3;
  62630. /**
  62631. * The xy coefficients of the spherical polynomial
  62632. */
  62633. xy: Vector3;
  62634. /**
  62635. * The yz coefficients of the spherical polynomial
  62636. */
  62637. yz: Vector3;
  62638. /**
  62639. * The zx coefficients of the spherical polynomial
  62640. */
  62641. zx: Vector3;
  62642. /**
  62643. * Adds an ambient color to the spherical polynomial
  62644. * @param color the color to add
  62645. */
  62646. addAmbient(color: Color3): void;
  62647. /**
  62648. * Scales the spherical polynomial by the given amount
  62649. * @param scale the amount to scale
  62650. */
  62651. scale(scale: number): void;
  62652. /**
  62653. * Gets the spherical polynomial from harmonics
  62654. * @param harmonics the spherical harmonics
  62655. * @returns the spherical polynomial
  62656. */
  62657. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62658. /**
  62659. * Constructs a spherical polynomial from an array.
  62660. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62661. * @returns the spherical polynomial
  62662. */
  62663. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62664. }
  62665. /**
  62666. * Class representing spherical harmonics coefficients to the 3rd degree
  62667. */
  62668. export class SphericalHarmonics {
  62669. /**
  62670. * The l0,0 coefficients of the spherical harmonics
  62671. */
  62672. l00: Vector3;
  62673. /**
  62674. * The l1,-1 coefficients of the spherical harmonics
  62675. */
  62676. l1_1: Vector3;
  62677. /**
  62678. * The l1,0 coefficients of the spherical harmonics
  62679. */
  62680. l10: Vector3;
  62681. /**
  62682. * The l1,1 coefficients of the spherical harmonics
  62683. */
  62684. l11: Vector3;
  62685. /**
  62686. * The l2,-2 coefficients of the spherical harmonics
  62687. */
  62688. l2_2: Vector3;
  62689. /**
  62690. * The l2,-1 coefficients of the spherical harmonics
  62691. */
  62692. l2_1: Vector3;
  62693. /**
  62694. * The l2,0 coefficients of the spherical harmonics
  62695. */
  62696. l20: Vector3;
  62697. /**
  62698. * The l2,1 coefficients of the spherical harmonics
  62699. */
  62700. l21: Vector3;
  62701. /**
  62702. * The l2,2 coefficients of the spherical harmonics
  62703. */
  62704. lL22: Vector3;
  62705. /**
  62706. * Adds a light to the spherical harmonics
  62707. * @param direction the direction of the light
  62708. * @param color the color of the light
  62709. * @param deltaSolidAngle the delta solid angle of the light
  62710. */
  62711. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62712. /**
  62713. * Scales the spherical harmonics by the given amount
  62714. * @param scale the amount to scale
  62715. */
  62716. scale(scale: number): void;
  62717. /**
  62718. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62719. *
  62720. * ```
  62721. * E_lm = A_l * L_lm
  62722. * ```
  62723. *
  62724. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62725. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62726. * the scaling factors are given in equation 9.
  62727. */
  62728. convertIncidentRadianceToIrradiance(): void;
  62729. /**
  62730. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62731. *
  62732. * ```
  62733. * L = (1/pi) * E * rho
  62734. * ```
  62735. *
  62736. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62737. */
  62738. convertIrradianceToLambertianRadiance(): void;
  62739. /**
  62740. * Gets the spherical harmonics from polynomial
  62741. * @param polynomial the spherical polynomial
  62742. * @returns the spherical harmonics
  62743. */
  62744. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62745. /**
  62746. * Constructs a spherical harmonics from an array.
  62747. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62748. * @returns the spherical harmonics
  62749. */
  62750. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62751. }
  62752. }
  62753. declare module BABYLON {
  62754. /**
  62755. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62756. */
  62757. export interface CubeMapInfo {
  62758. /**
  62759. * The pixel array for the front face.
  62760. * This is stored in format, left to right, up to down format.
  62761. */
  62762. front: Nullable<ArrayBufferView>;
  62763. /**
  62764. * The pixel array for the back face.
  62765. * This is stored in format, left to right, up to down format.
  62766. */
  62767. back: Nullable<ArrayBufferView>;
  62768. /**
  62769. * The pixel array for the left face.
  62770. * This is stored in format, left to right, up to down format.
  62771. */
  62772. left: Nullable<ArrayBufferView>;
  62773. /**
  62774. * The pixel array for the right face.
  62775. * This is stored in format, left to right, up to down format.
  62776. */
  62777. right: Nullable<ArrayBufferView>;
  62778. /**
  62779. * The pixel array for the up face.
  62780. * This is stored in format, left to right, up to down format.
  62781. */
  62782. up: Nullable<ArrayBufferView>;
  62783. /**
  62784. * The pixel array for the down face.
  62785. * This is stored in format, left to right, up to down format.
  62786. */
  62787. down: Nullable<ArrayBufferView>;
  62788. /**
  62789. * The size of the cubemap stored.
  62790. *
  62791. * Each faces will be size * size pixels.
  62792. */
  62793. size: number;
  62794. /**
  62795. * The format of the texture.
  62796. *
  62797. * RGBA, RGB.
  62798. */
  62799. format: number;
  62800. /**
  62801. * The type of the texture data.
  62802. *
  62803. * UNSIGNED_INT, FLOAT.
  62804. */
  62805. type: number;
  62806. /**
  62807. * Specifies whether the texture is in gamma space.
  62808. */
  62809. gammaSpace: boolean;
  62810. }
  62811. /**
  62812. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62813. */
  62814. export class PanoramaToCubeMapTools {
  62815. private static FACE_FRONT;
  62816. private static FACE_BACK;
  62817. private static FACE_RIGHT;
  62818. private static FACE_LEFT;
  62819. private static FACE_DOWN;
  62820. private static FACE_UP;
  62821. /**
  62822. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62823. *
  62824. * @param float32Array The source data.
  62825. * @param inputWidth The width of the input panorama.
  62826. * @param inputHeight The height of the input panorama.
  62827. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62828. * @return The cubemap data
  62829. */
  62830. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62831. private static CreateCubemapTexture;
  62832. private static CalcProjectionSpherical;
  62833. }
  62834. }
  62835. declare module BABYLON {
  62836. /**
  62837. * Helper class dealing with the extraction of spherical polynomial dataArray
  62838. * from a cube map.
  62839. */
  62840. export class CubeMapToSphericalPolynomialTools {
  62841. private static FileFaces;
  62842. /**
  62843. * Converts a texture to the according Spherical Polynomial data.
  62844. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62845. *
  62846. * @param texture The texture to extract the information from.
  62847. * @return The Spherical Polynomial data.
  62848. */
  62849. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62850. /**
  62851. * Converts a cubemap to the according Spherical Polynomial data.
  62852. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62853. *
  62854. * @param cubeInfo The Cube map to extract the information from.
  62855. * @return The Spherical Polynomial data.
  62856. */
  62857. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62858. }
  62859. }
  62860. declare module BABYLON {
  62861. /**
  62862. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62863. * during the life time of the application.
  62864. */
  62865. export class EngineStore {
  62866. /** Gets the list of created engines */
  62867. static Instances: Engine[];
  62868. /**
  62869. * Gets the latest created engine
  62870. */
  62871. static readonly LastCreatedEngine: Nullable<Engine>;
  62872. /**
  62873. * Gets the latest created scene
  62874. */
  62875. static readonly LastCreatedScene: Nullable<Scene>;
  62876. }
  62877. }
  62878. declare module BABYLON {
  62879. /**
  62880. * Define options used to create a render target texture
  62881. */
  62882. export class RenderTargetCreationOptions {
  62883. /**
  62884. * Specifies is mipmaps must be generated
  62885. */
  62886. generateMipMaps?: boolean;
  62887. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62888. generateDepthBuffer?: boolean;
  62889. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62890. generateStencilBuffer?: boolean;
  62891. /** Defines texture type (int by default) */
  62892. type?: number;
  62893. /** Defines sampling mode (trilinear by default) */
  62894. samplingMode?: number;
  62895. /** Defines format (RGBA by default) */
  62896. format?: number;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * @hidden
  62902. **/
  62903. export class _AlphaState {
  62904. private _isAlphaBlendDirty;
  62905. private _isBlendFunctionParametersDirty;
  62906. private _isBlendEquationParametersDirty;
  62907. private _isBlendConstantsDirty;
  62908. private _alphaBlend;
  62909. private _blendFunctionParameters;
  62910. private _blendEquationParameters;
  62911. private _blendConstants;
  62912. /**
  62913. * Initializes the state.
  62914. */
  62915. constructor();
  62916. readonly isDirty: boolean;
  62917. alphaBlend: boolean;
  62918. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62919. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62920. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62921. reset(): void;
  62922. apply(gl: WebGLRenderingContext): void;
  62923. }
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * @hidden
  62928. **/
  62929. export class _DepthCullingState {
  62930. private _isDepthTestDirty;
  62931. private _isDepthMaskDirty;
  62932. private _isDepthFuncDirty;
  62933. private _isCullFaceDirty;
  62934. private _isCullDirty;
  62935. private _isZOffsetDirty;
  62936. private _isFrontFaceDirty;
  62937. private _depthTest;
  62938. private _depthMask;
  62939. private _depthFunc;
  62940. private _cull;
  62941. private _cullFace;
  62942. private _zOffset;
  62943. private _frontFace;
  62944. /**
  62945. * Initializes the state.
  62946. */
  62947. constructor();
  62948. readonly isDirty: boolean;
  62949. zOffset: number;
  62950. cullFace: Nullable<number>;
  62951. cull: Nullable<boolean>;
  62952. depthFunc: Nullable<number>;
  62953. depthMask: boolean;
  62954. depthTest: boolean;
  62955. frontFace: Nullable<number>;
  62956. reset(): void;
  62957. apply(gl: WebGLRenderingContext): void;
  62958. }
  62959. }
  62960. declare module BABYLON {
  62961. /**
  62962. * @hidden
  62963. **/
  62964. export class _StencilState {
  62965. /** 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 */
  62966. static readonly ALWAYS: number;
  62967. /** Passed to stencilOperation to specify that stencil value must be kept */
  62968. static readonly KEEP: number;
  62969. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62970. static readonly REPLACE: number;
  62971. private _isStencilTestDirty;
  62972. private _isStencilMaskDirty;
  62973. private _isStencilFuncDirty;
  62974. private _isStencilOpDirty;
  62975. private _stencilTest;
  62976. private _stencilMask;
  62977. private _stencilFunc;
  62978. private _stencilFuncRef;
  62979. private _stencilFuncMask;
  62980. private _stencilOpStencilFail;
  62981. private _stencilOpDepthFail;
  62982. private _stencilOpStencilDepthPass;
  62983. readonly isDirty: boolean;
  62984. stencilFunc: number;
  62985. stencilFuncRef: number;
  62986. stencilFuncMask: number;
  62987. stencilOpStencilFail: number;
  62988. stencilOpDepthFail: number;
  62989. stencilOpStencilDepthPass: number;
  62990. stencilMask: number;
  62991. stencilTest: boolean;
  62992. constructor();
  62993. reset(): void;
  62994. apply(gl: WebGLRenderingContext): void;
  62995. }
  62996. }
  62997. declare module BABYLON {
  62998. /**
  62999. * @hidden
  63000. **/
  63001. export class _TimeToken {
  63002. _startTimeQuery: Nullable<WebGLQuery>;
  63003. _endTimeQuery: Nullable<WebGLQuery>;
  63004. _timeElapsedQuery: Nullable<WebGLQuery>;
  63005. _timeElapsedQueryEnded: boolean;
  63006. }
  63007. }
  63008. declare module BABYLON {
  63009. /**
  63010. * Internal interface used to track InternalTexture already bound to the GL context
  63011. */
  63012. export interface IInternalTextureTracker {
  63013. /**
  63014. * Gets or set the previous tracker in the list
  63015. */
  63016. previous: Nullable<IInternalTextureTracker>;
  63017. /**
  63018. * Gets or set the next tracker in the list
  63019. */
  63020. next: Nullable<IInternalTextureTracker>;
  63021. }
  63022. /**
  63023. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63024. */
  63025. export class DummyInternalTextureTracker {
  63026. /**
  63027. * Gets or set the previous tracker in the list
  63028. */
  63029. previous: Nullable<IInternalTextureTracker>;
  63030. /**
  63031. * Gets or set the next tracker in the list
  63032. */
  63033. next: Nullable<IInternalTextureTracker>;
  63034. }
  63035. }
  63036. declare module BABYLON {
  63037. /**
  63038. * Class used to store data associated with WebGL texture data for the engine
  63039. * This class should not be used directly
  63040. */
  63041. export class InternalTexture implements IInternalTextureTracker {
  63042. /** hidden */
  63043. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63044. /**
  63045. * The source of the texture data is unknown
  63046. */
  63047. static DATASOURCE_UNKNOWN: number;
  63048. /**
  63049. * Texture data comes from an URL
  63050. */
  63051. static DATASOURCE_URL: number;
  63052. /**
  63053. * Texture data is only used for temporary storage
  63054. */
  63055. static DATASOURCE_TEMP: number;
  63056. /**
  63057. * Texture data comes from raw data (ArrayBuffer)
  63058. */
  63059. static DATASOURCE_RAW: number;
  63060. /**
  63061. * Texture content is dynamic (video or dynamic texture)
  63062. */
  63063. static DATASOURCE_DYNAMIC: number;
  63064. /**
  63065. * Texture content is generated by rendering to it
  63066. */
  63067. static DATASOURCE_RENDERTARGET: number;
  63068. /**
  63069. * Texture content is part of a multi render target process
  63070. */
  63071. static DATASOURCE_MULTIRENDERTARGET: number;
  63072. /**
  63073. * Texture data comes from a cube data file
  63074. */
  63075. static DATASOURCE_CUBE: number;
  63076. /**
  63077. * Texture data comes from a raw cube data
  63078. */
  63079. static DATASOURCE_CUBERAW: number;
  63080. /**
  63081. * Texture data come from a prefiltered cube data file
  63082. */
  63083. static DATASOURCE_CUBEPREFILTERED: number;
  63084. /**
  63085. * Texture content is raw 3D data
  63086. */
  63087. static DATASOURCE_RAW3D: number;
  63088. /**
  63089. * Texture content is a depth texture
  63090. */
  63091. static DATASOURCE_DEPTHTEXTURE: number;
  63092. /**
  63093. * Texture data comes from a raw cube data encoded with RGBD
  63094. */
  63095. static DATASOURCE_CUBERAW_RGBD: number;
  63096. /**
  63097. * Defines if the texture is ready
  63098. */
  63099. isReady: boolean;
  63100. /**
  63101. * Defines if the texture is a cube texture
  63102. */
  63103. isCube: boolean;
  63104. /**
  63105. * Defines if the texture contains 3D data
  63106. */
  63107. is3D: boolean;
  63108. /**
  63109. * Gets the URL used to load this texture
  63110. */
  63111. url: string;
  63112. /**
  63113. * Gets the sampling mode of the texture
  63114. */
  63115. samplingMode: number;
  63116. /**
  63117. * Gets a boolean indicating if the texture needs mipmaps generation
  63118. */
  63119. generateMipMaps: boolean;
  63120. /**
  63121. * Gets the number of samples used by the texture (WebGL2+ only)
  63122. */
  63123. samples: number;
  63124. /**
  63125. * Gets the type of the texture (int, float...)
  63126. */
  63127. type: number;
  63128. /**
  63129. * Gets the format of the texture (RGB, RGBA...)
  63130. */
  63131. format: number;
  63132. /**
  63133. * Observable called when the texture is loaded
  63134. */
  63135. onLoadedObservable: Observable<InternalTexture>;
  63136. /**
  63137. * Gets the width of the texture
  63138. */
  63139. width: number;
  63140. /**
  63141. * Gets the height of the texture
  63142. */
  63143. height: number;
  63144. /**
  63145. * Gets the depth of the texture
  63146. */
  63147. depth: number;
  63148. /**
  63149. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63150. */
  63151. baseWidth: number;
  63152. /**
  63153. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63154. */
  63155. baseHeight: number;
  63156. /**
  63157. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63158. */
  63159. baseDepth: number;
  63160. /**
  63161. * Gets a boolean indicating if the texture is inverted on Y axis
  63162. */
  63163. invertY: boolean;
  63164. /**
  63165. * Gets or set the previous tracker in the list
  63166. */
  63167. previous: Nullable<IInternalTextureTracker>;
  63168. /**
  63169. * Gets or set the next tracker in the list
  63170. */
  63171. next: Nullable<IInternalTextureTracker>;
  63172. /** @hidden */
  63173. _invertVScale: boolean;
  63174. /** @hidden */
  63175. _initialSlot: number;
  63176. /** @hidden */
  63177. _designatedSlot: number;
  63178. /** @hidden */
  63179. _dataSource: number;
  63180. /** @hidden */
  63181. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63182. /** @hidden */
  63183. _bufferView: Nullable<ArrayBufferView>;
  63184. /** @hidden */
  63185. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63186. /** @hidden */
  63187. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63188. /** @hidden */
  63189. _size: number;
  63190. /** @hidden */
  63191. _extension: string;
  63192. /** @hidden */
  63193. _files: Nullable<string[]>;
  63194. /** @hidden */
  63195. _workingCanvas: HTMLCanvasElement;
  63196. /** @hidden */
  63197. _workingContext: CanvasRenderingContext2D;
  63198. /** @hidden */
  63199. _framebuffer: Nullable<WebGLFramebuffer>;
  63200. /** @hidden */
  63201. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63202. /** @hidden */
  63203. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63204. /** @hidden */
  63205. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63206. /** @hidden */
  63207. _attachments: Nullable<number[]>;
  63208. /** @hidden */
  63209. _cachedCoordinatesMode: Nullable<number>;
  63210. /** @hidden */
  63211. _cachedWrapU: Nullable<number>;
  63212. /** @hidden */
  63213. _cachedWrapV: Nullable<number>;
  63214. /** @hidden */
  63215. _cachedWrapR: Nullable<number>;
  63216. /** @hidden */
  63217. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63218. /** @hidden */
  63219. _isDisabled: boolean;
  63220. /** @hidden */
  63221. _compression: Nullable<string>;
  63222. /** @hidden */
  63223. _generateStencilBuffer: boolean;
  63224. /** @hidden */
  63225. _generateDepthBuffer: boolean;
  63226. /** @hidden */
  63227. _comparisonFunction: number;
  63228. /** @hidden */
  63229. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63230. /** @hidden */
  63231. _lodGenerationScale: number;
  63232. /** @hidden */
  63233. _lodGenerationOffset: number;
  63234. /** @hidden */
  63235. _lodTextureHigh: BaseTexture;
  63236. /** @hidden */
  63237. _lodTextureMid: BaseTexture;
  63238. /** @hidden */
  63239. _lodTextureLow: BaseTexture;
  63240. /** @hidden */
  63241. _isRGBD: boolean;
  63242. /** @hidden */
  63243. _webGLTexture: Nullable<WebGLTexture>;
  63244. /** @hidden */
  63245. _references: number;
  63246. private _engine;
  63247. /**
  63248. * Gets the Engine the texture belongs to.
  63249. * @returns The babylon engine
  63250. */
  63251. getEngine(): Engine;
  63252. /**
  63253. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63254. */
  63255. readonly dataSource: number;
  63256. /**
  63257. * Creates a new InternalTexture
  63258. * @param engine defines the engine to use
  63259. * @param dataSource defines the type of data that will be used
  63260. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63261. */
  63262. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63263. /**
  63264. * Increments the number of references (ie. the number of Texture that point to it)
  63265. */
  63266. incrementReferences(): void;
  63267. /**
  63268. * Change the size of the texture (not the size of the content)
  63269. * @param width defines the new width
  63270. * @param height defines the new height
  63271. * @param depth defines the new depth (1 by default)
  63272. */
  63273. updateSize(width: int, height: int, depth?: int): void;
  63274. /** @hidden */
  63275. _rebuild(): void;
  63276. /** @hidden */
  63277. _swapAndDie(target: InternalTexture): void;
  63278. /**
  63279. * Dispose the current allocated resources
  63280. */
  63281. dispose(): void;
  63282. }
  63283. }
  63284. declare module BABYLON {
  63285. /**
  63286. * This represents the main contract an easing function should follow.
  63287. * Easing functions are used throughout the animation system.
  63288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63289. */
  63290. export interface IEasingFunction {
  63291. /**
  63292. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63293. * of the easing function.
  63294. * The link below provides some of the most common examples of easing functions.
  63295. * @see https://easings.net/
  63296. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63297. * @returns the corresponding value on the curve defined by the easing function
  63298. */
  63299. ease(gradient: number): number;
  63300. }
  63301. /**
  63302. * Base class used for every default easing function.
  63303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63304. */
  63305. export class EasingFunction implements IEasingFunction {
  63306. /**
  63307. * Interpolation follows the mathematical formula associated with the easing function.
  63308. */
  63309. static readonly EASINGMODE_EASEIN: number;
  63310. /**
  63311. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63312. */
  63313. static readonly EASINGMODE_EASEOUT: number;
  63314. /**
  63315. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63316. */
  63317. static readonly EASINGMODE_EASEINOUT: number;
  63318. private _easingMode;
  63319. /**
  63320. * Sets the easing mode of the current function.
  63321. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63322. */
  63323. setEasingMode(easingMode: number): void;
  63324. /**
  63325. * Gets the current easing mode.
  63326. * @returns the easing mode
  63327. */
  63328. getEasingMode(): number;
  63329. /**
  63330. * @hidden
  63331. */
  63332. easeInCore(gradient: number): number;
  63333. /**
  63334. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63335. * of the easing function.
  63336. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63337. * @returns the corresponding value on the curve defined by the easing function
  63338. */
  63339. ease(gradient: number): number;
  63340. }
  63341. /**
  63342. * Easing function with a circle shape (see link below).
  63343. * @see https://easings.net/#easeInCirc
  63344. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63345. */
  63346. export class CircleEase extends EasingFunction implements IEasingFunction {
  63347. /** @hidden */
  63348. easeInCore(gradient: number): number;
  63349. }
  63350. /**
  63351. * Easing function with a ease back shape (see link below).
  63352. * @see https://easings.net/#easeInBack
  63353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63354. */
  63355. export class BackEase extends EasingFunction implements IEasingFunction {
  63356. /** Defines the amplitude of the function */
  63357. amplitude: number;
  63358. /**
  63359. * Instantiates a back ease easing
  63360. * @see https://easings.net/#easeInBack
  63361. * @param amplitude Defines the amplitude of the function
  63362. */
  63363. constructor(
  63364. /** Defines the amplitude of the function */
  63365. amplitude?: number);
  63366. /** @hidden */
  63367. easeInCore(gradient: number): number;
  63368. }
  63369. /**
  63370. * Easing function with a bouncing shape (see link below).
  63371. * @see https://easings.net/#easeInBounce
  63372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63373. */
  63374. export class BounceEase extends EasingFunction implements IEasingFunction {
  63375. /** Defines the number of bounces */
  63376. bounces: number;
  63377. /** Defines the amplitude of the bounce */
  63378. bounciness: number;
  63379. /**
  63380. * Instantiates a bounce easing
  63381. * @see https://easings.net/#easeInBounce
  63382. * @param bounces Defines the number of bounces
  63383. * @param bounciness Defines the amplitude of the bounce
  63384. */
  63385. constructor(
  63386. /** Defines the number of bounces */
  63387. bounces?: number,
  63388. /** Defines the amplitude of the bounce */
  63389. bounciness?: number);
  63390. /** @hidden */
  63391. easeInCore(gradient: number): number;
  63392. }
  63393. /**
  63394. * Easing function with a power of 3 shape (see link below).
  63395. * @see https://easings.net/#easeInCubic
  63396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63397. */
  63398. export class CubicEase extends EasingFunction implements IEasingFunction {
  63399. /** @hidden */
  63400. easeInCore(gradient: number): number;
  63401. }
  63402. /**
  63403. * Easing function with an elastic shape (see link below).
  63404. * @see https://easings.net/#easeInElastic
  63405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63406. */
  63407. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63408. /** Defines the number of oscillations*/
  63409. oscillations: number;
  63410. /** Defines the amplitude of the oscillations*/
  63411. springiness: number;
  63412. /**
  63413. * Instantiates an elastic easing function
  63414. * @see https://easings.net/#easeInElastic
  63415. * @param oscillations Defines the number of oscillations
  63416. * @param springiness Defines the amplitude of the oscillations
  63417. */
  63418. constructor(
  63419. /** Defines the number of oscillations*/
  63420. oscillations?: number,
  63421. /** Defines the amplitude of the oscillations*/
  63422. springiness?: number);
  63423. /** @hidden */
  63424. easeInCore(gradient: number): number;
  63425. }
  63426. /**
  63427. * Easing function with an exponential shape (see link below).
  63428. * @see https://easings.net/#easeInExpo
  63429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63430. */
  63431. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63432. /** Defines the exponent of the function */
  63433. exponent: number;
  63434. /**
  63435. * Instantiates an exponential easing function
  63436. * @see https://easings.net/#easeInExpo
  63437. * @param exponent Defines the exponent of the function
  63438. */
  63439. constructor(
  63440. /** Defines the exponent of the function */
  63441. exponent?: number);
  63442. /** @hidden */
  63443. easeInCore(gradient: number): number;
  63444. }
  63445. /**
  63446. * Easing function with a power shape (see link below).
  63447. * @see https://easings.net/#easeInQuad
  63448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63449. */
  63450. export class PowerEase extends EasingFunction implements IEasingFunction {
  63451. /** Defines the power of the function */
  63452. power: number;
  63453. /**
  63454. * Instantiates an power base easing function
  63455. * @see https://easings.net/#easeInQuad
  63456. * @param power Defines the power of the function
  63457. */
  63458. constructor(
  63459. /** Defines the power of the function */
  63460. power?: number);
  63461. /** @hidden */
  63462. easeInCore(gradient: number): number;
  63463. }
  63464. /**
  63465. * Easing function with a power of 2 shape (see link below).
  63466. * @see https://easings.net/#easeInQuad
  63467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63468. */
  63469. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63470. /** @hidden */
  63471. easeInCore(gradient: number): number;
  63472. }
  63473. /**
  63474. * Easing function with a power of 4 shape (see link below).
  63475. * @see https://easings.net/#easeInQuart
  63476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63477. */
  63478. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63479. /** @hidden */
  63480. easeInCore(gradient: number): number;
  63481. }
  63482. /**
  63483. * Easing function with a power of 5 shape (see link below).
  63484. * @see https://easings.net/#easeInQuint
  63485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63486. */
  63487. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63488. /** @hidden */
  63489. easeInCore(gradient: number): number;
  63490. }
  63491. /**
  63492. * Easing function with a sin shape (see link below).
  63493. * @see https://easings.net/#easeInSine
  63494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63495. */
  63496. export class SineEase extends EasingFunction implements IEasingFunction {
  63497. /** @hidden */
  63498. easeInCore(gradient: number): number;
  63499. }
  63500. /**
  63501. * Easing function with a bezier shape (see link below).
  63502. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63504. */
  63505. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63506. /** Defines the x component of the start tangent in the bezier curve */
  63507. x1: number;
  63508. /** Defines the y component of the start tangent in the bezier curve */
  63509. y1: number;
  63510. /** Defines the x component of the end tangent in the bezier curve */
  63511. x2: number;
  63512. /** Defines the y component of the end tangent in the bezier curve */
  63513. y2: number;
  63514. /**
  63515. * Instantiates a bezier function
  63516. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63517. * @param x1 Defines the x component of the start tangent in the bezier curve
  63518. * @param y1 Defines the y component of the start tangent in the bezier curve
  63519. * @param x2 Defines the x component of the end tangent in the bezier curve
  63520. * @param y2 Defines the y component of the end tangent in the bezier curve
  63521. */
  63522. constructor(
  63523. /** Defines the x component of the start tangent in the bezier curve */
  63524. x1?: number,
  63525. /** Defines the y component of the start tangent in the bezier curve */
  63526. y1?: number,
  63527. /** Defines the x component of the end tangent in the bezier curve */
  63528. x2?: number,
  63529. /** Defines the y component of the end tangent in the bezier curve */
  63530. y2?: number);
  63531. /** @hidden */
  63532. easeInCore(gradient: number): number;
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /**
  63537. * Defines an interface which represents an animation key frame
  63538. */
  63539. export interface IAnimationKey {
  63540. /**
  63541. * Frame of the key frame
  63542. */
  63543. frame: number;
  63544. /**
  63545. * Value at the specifies key frame
  63546. */
  63547. value: any;
  63548. /**
  63549. * The input tangent for the cubic hermite spline
  63550. */
  63551. inTangent?: any;
  63552. /**
  63553. * The output tangent for the cubic hermite spline
  63554. */
  63555. outTangent?: any;
  63556. /**
  63557. * The animation interpolation type
  63558. */
  63559. interpolation?: AnimationKeyInterpolation;
  63560. }
  63561. /**
  63562. * Enum for the animation key frame interpolation type
  63563. */
  63564. export enum AnimationKeyInterpolation {
  63565. /**
  63566. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63567. */
  63568. STEP = 1
  63569. }
  63570. }
  63571. declare module BABYLON {
  63572. /**
  63573. * Represents the range of an animation
  63574. */
  63575. export class AnimationRange {
  63576. /**The name of the animation range**/
  63577. name: string;
  63578. /**The starting frame of the animation */
  63579. from: number;
  63580. /**The ending frame of the animation*/
  63581. to: number;
  63582. /**
  63583. * Initializes the range of an animation
  63584. * @param name The name of the animation range
  63585. * @param from The starting frame of the animation
  63586. * @param to The ending frame of the animation
  63587. */
  63588. constructor(
  63589. /**The name of the animation range**/
  63590. name: string,
  63591. /**The starting frame of the animation */
  63592. from: number,
  63593. /**The ending frame of the animation*/
  63594. to: number);
  63595. /**
  63596. * Makes a copy of the animation range
  63597. * @returns A copy of the animation range
  63598. */
  63599. clone(): AnimationRange;
  63600. }
  63601. }
  63602. declare module BABYLON {
  63603. /**
  63604. * Composed of a frame, and an action function
  63605. */
  63606. export class AnimationEvent {
  63607. /** The frame for which the event is triggered **/
  63608. frame: number;
  63609. /** The event to perform when triggered **/
  63610. action: (currentFrame: number) => void;
  63611. /** Specifies if the event should be triggered only once**/
  63612. onlyOnce?: boolean | undefined;
  63613. /**
  63614. * Specifies if the animation event is done
  63615. */
  63616. isDone: boolean;
  63617. /**
  63618. * Initializes the animation event
  63619. * @param frame The frame for which the event is triggered
  63620. * @param action The event to perform when triggered
  63621. * @param onlyOnce Specifies if the event should be triggered only once
  63622. */
  63623. constructor(
  63624. /** The frame for which the event is triggered **/
  63625. frame: number,
  63626. /** The event to perform when triggered **/
  63627. action: (currentFrame: number) => void,
  63628. /** Specifies if the event should be triggered only once**/
  63629. onlyOnce?: boolean | undefined);
  63630. /** @hidden */
  63631. _clone(): AnimationEvent;
  63632. }
  63633. }
  63634. declare module BABYLON {
  63635. /**
  63636. * Interface used to define a behavior
  63637. */
  63638. export interface Behavior<T> {
  63639. /** gets or sets behavior's name */
  63640. name: string;
  63641. /**
  63642. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63643. */
  63644. init(): void;
  63645. /**
  63646. * Called when the behavior is attached to a target
  63647. * @param target defines the target where the behavior is attached to
  63648. */
  63649. attach(target: T): void;
  63650. /**
  63651. * Called when the behavior is detached from its target
  63652. */
  63653. detach(): void;
  63654. }
  63655. /**
  63656. * Interface implemented by classes supporting behaviors
  63657. */
  63658. export interface IBehaviorAware<T> {
  63659. /**
  63660. * Attach a behavior
  63661. * @param behavior defines the behavior to attach
  63662. * @returns the current host
  63663. */
  63664. addBehavior(behavior: Behavior<T>): T;
  63665. /**
  63666. * Remove a behavior from the current object
  63667. * @param behavior defines the behavior to detach
  63668. * @returns the current host
  63669. */
  63670. removeBehavior(behavior: Behavior<T>): T;
  63671. /**
  63672. * Gets a behavior using its name to search
  63673. * @param name defines the name to search
  63674. * @returns the behavior or null if not found
  63675. */
  63676. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63677. }
  63678. }
  63679. declare module BABYLON {
  63680. /**
  63681. * @hidden
  63682. */
  63683. export class IntersectionInfo {
  63684. bu: Nullable<number>;
  63685. bv: Nullable<number>;
  63686. distance: number;
  63687. faceId: number;
  63688. subMeshId: number;
  63689. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63690. }
  63691. }
  63692. declare module BABYLON {
  63693. /**
  63694. * Class used to store bounding sphere information
  63695. */
  63696. export class BoundingSphere {
  63697. /**
  63698. * Gets the center of the bounding sphere in local space
  63699. */
  63700. readonly center: Vector3;
  63701. /**
  63702. * Radius of the bounding sphere in local space
  63703. */
  63704. radius: number;
  63705. /**
  63706. * Gets the center of the bounding sphere in world space
  63707. */
  63708. readonly centerWorld: Vector3;
  63709. /**
  63710. * Radius of the bounding sphere in world space
  63711. */
  63712. radiusWorld: number;
  63713. /**
  63714. * Gets the minimum vector in local space
  63715. */
  63716. readonly minimum: Vector3;
  63717. /**
  63718. * Gets the maximum vector in local space
  63719. */
  63720. readonly maximum: Vector3;
  63721. private _worldMatrix;
  63722. private static readonly TmpVector3;
  63723. /**
  63724. * Creates a new bounding sphere
  63725. * @param min defines the minimum vector (in local space)
  63726. * @param max defines the maximum vector (in local space)
  63727. * @param worldMatrix defines the new world matrix
  63728. */
  63729. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63730. /**
  63731. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63732. * @param min defines the new minimum vector (in local space)
  63733. * @param max defines the new maximum vector (in local space)
  63734. * @param worldMatrix defines the new world matrix
  63735. */
  63736. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63737. /**
  63738. * Scale the current bounding sphere by applying a scale factor
  63739. * @param factor defines the scale factor to apply
  63740. * @returns the current bounding box
  63741. */
  63742. scale(factor: number): BoundingSphere;
  63743. /**
  63744. * Gets the world matrix of the bounding box
  63745. * @returns a matrix
  63746. */
  63747. getWorldMatrix(): DeepImmutable<Matrix>;
  63748. /** @hidden */
  63749. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63750. /**
  63751. * Tests if the bounding sphere is intersecting the frustum planes
  63752. * @param frustumPlanes defines the frustum planes to test
  63753. * @returns true if there is an intersection
  63754. */
  63755. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63756. /**
  63757. * Tests if the bounding sphere center is in between the frustum planes.
  63758. * Used for optimistic fast inclusion.
  63759. * @param frustumPlanes defines the frustum planes to test
  63760. * @returns true if the sphere center is in between the frustum planes
  63761. */
  63762. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63763. /**
  63764. * Tests if a point is inside the bounding sphere
  63765. * @param point defines the point to test
  63766. * @returns true if the point is inside the bounding sphere
  63767. */
  63768. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63769. /**
  63770. * Checks if two sphere intersct
  63771. * @param sphere0 sphere 0
  63772. * @param sphere1 sphere 1
  63773. * @returns true if the speres intersect
  63774. */
  63775. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63776. }
  63777. }
  63778. declare module BABYLON {
  63779. /**
  63780. * Class used to store bounding box information
  63781. */
  63782. export class BoundingBox implements ICullable {
  63783. /**
  63784. * Gets the 8 vectors representing the bounding box in local space
  63785. */
  63786. readonly vectors: Vector3[];
  63787. /**
  63788. * Gets the center of the bounding box in local space
  63789. */
  63790. readonly center: Vector3;
  63791. /**
  63792. * Gets the center of the bounding box in world space
  63793. */
  63794. readonly centerWorld: Vector3;
  63795. /**
  63796. * Gets the extend size in local space
  63797. */
  63798. readonly extendSize: Vector3;
  63799. /**
  63800. * Gets the extend size in world space
  63801. */
  63802. readonly extendSizeWorld: Vector3;
  63803. /**
  63804. * Gets the OBB (object bounding box) directions
  63805. */
  63806. readonly directions: Vector3[];
  63807. /**
  63808. * Gets the 8 vectors representing the bounding box in world space
  63809. */
  63810. readonly vectorsWorld: Vector3[];
  63811. /**
  63812. * Gets the minimum vector in world space
  63813. */
  63814. readonly minimumWorld: Vector3;
  63815. /**
  63816. * Gets the maximum vector in world space
  63817. */
  63818. readonly maximumWorld: Vector3;
  63819. /**
  63820. * Gets the minimum vector in local space
  63821. */
  63822. readonly minimum: Vector3;
  63823. /**
  63824. * Gets the maximum vector in local space
  63825. */
  63826. readonly maximum: Vector3;
  63827. private _worldMatrix;
  63828. private static readonly TmpVector3;
  63829. /**
  63830. * @hidden
  63831. */
  63832. _tag: number;
  63833. /**
  63834. * Creates a new bounding box
  63835. * @param min defines the minimum vector (in local space)
  63836. * @param max defines the maximum vector (in local space)
  63837. * @param worldMatrix defines the new world matrix
  63838. */
  63839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63840. /**
  63841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63842. * @param min defines the new minimum vector (in local space)
  63843. * @param max defines the new maximum vector (in local space)
  63844. * @param worldMatrix defines the new world matrix
  63845. */
  63846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63847. /**
  63848. * Scale the current bounding box by applying a scale factor
  63849. * @param factor defines the scale factor to apply
  63850. * @returns the current bounding box
  63851. */
  63852. scale(factor: number): BoundingBox;
  63853. /**
  63854. * Gets the world matrix of the bounding box
  63855. * @returns a matrix
  63856. */
  63857. getWorldMatrix(): DeepImmutable<Matrix>;
  63858. /** @hidden */
  63859. _update(world: DeepImmutable<Matrix>): void;
  63860. /**
  63861. * Tests if the bounding box is intersecting the frustum planes
  63862. * @param frustumPlanes defines the frustum planes to test
  63863. * @returns true if there is an intersection
  63864. */
  63865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63866. /**
  63867. * Tests if the bounding box is entirely inside the frustum planes
  63868. * @param frustumPlanes defines the frustum planes to test
  63869. * @returns true if there is an inclusion
  63870. */
  63871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63872. /**
  63873. * Tests if a point is inside the bounding box
  63874. * @param point defines the point to test
  63875. * @returns true if the point is inside the bounding box
  63876. */
  63877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63878. /**
  63879. * Tests if the bounding box intersects with a bounding sphere
  63880. * @param sphere defines the sphere to test
  63881. * @returns true if there is an intersection
  63882. */
  63883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63884. /**
  63885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63886. * @param min defines the min vector to use
  63887. * @param max defines the max vector to use
  63888. * @returns true if there is an intersection
  63889. */
  63890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63891. /**
  63892. * Tests if two bounding boxes are intersections
  63893. * @param box0 defines the first box to test
  63894. * @param box1 defines the second box to test
  63895. * @returns true if there is an intersection
  63896. */
  63897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63898. /**
  63899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63900. * @param minPoint defines the minimum vector of the bounding box
  63901. * @param maxPoint defines the maximum vector of the bounding box
  63902. * @param sphereCenter defines the sphere center
  63903. * @param sphereRadius defines the sphere radius
  63904. * @returns true if there is an intersection
  63905. */
  63906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63907. /**
  63908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63910. * @param frustumPlanes defines the frustum planes to test
  63911. * @return true if there is an inclusion
  63912. */
  63913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63914. /**
  63915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63917. * @param frustumPlanes defines the frustum planes to test
  63918. * @return true if there is an intersection
  63919. */
  63920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /** @hidden */
  63925. export class Collider {
  63926. /** Define if a collision was found */
  63927. collisionFound: boolean;
  63928. /**
  63929. * Define last intersection point in local space
  63930. */
  63931. intersectionPoint: Vector3;
  63932. /**
  63933. * Define last collided mesh
  63934. */
  63935. collidedMesh: Nullable<AbstractMesh>;
  63936. private _collisionPoint;
  63937. private _planeIntersectionPoint;
  63938. private _tempVector;
  63939. private _tempVector2;
  63940. private _tempVector3;
  63941. private _tempVector4;
  63942. private _edge;
  63943. private _baseToVertex;
  63944. private _destinationPoint;
  63945. private _slidePlaneNormal;
  63946. private _displacementVector;
  63947. /** @hidden */
  63948. _radius: Vector3;
  63949. /** @hidden */
  63950. _retry: number;
  63951. private _velocity;
  63952. private _basePoint;
  63953. private _epsilon;
  63954. /** @hidden */
  63955. _velocityWorldLength: number;
  63956. /** @hidden */
  63957. _basePointWorld: Vector3;
  63958. private _velocityWorld;
  63959. private _normalizedVelocity;
  63960. /** @hidden */
  63961. _initialVelocity: Vector3;
  63962. /** @hidden */
  63963. _initialPosition: Vector3;
  63964. private _nearestDistance;
  63965. private _collisionMask;
  63966. collisionMask: number;
  63967. /**
  63968. * Gets the plane normal used to compute the sliding response (in local space)
  63969. */
  63970. readonly slidePlaneNormal: Vector3;
  63971. /** @hidden */
  63972. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63973. /** @hidden */
  63974. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63975. /** @hidden */
  63976. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63977. /** @hidden */
  63978. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63979. /** @hidden */
  63980. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63981. /** @hidden */
  63982. _getResponse(pos: Vector3, vel: Vector3): void;
  63983. }
  63984. }
  63985. declare module BABYLON {
  63986. /**
  63987. * Interface for cullable objects
  63988. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63989. */
  63990. export interface ICullable {
  63991. /**
  63992. * Checks if the object or part of the object is in the frustum
  63993. * @param frustumPlanes Camera near/planes
  63994. * @returns true if the object is in frustum otherwise false
  63995. */
  63996. isInFrustum(frustumPlanes: Plane[]): boolean;
  63997. /**
  63998. * Checks if a cullable object (mesh...) is in the camera frustum
  63999. * Unlike isInFrustum this cheks the full bounding box
  64000. * @param frustumPlanes Camera near/planes
  64001. * @returns true if the object is in frustum otherwise false
  64002. */
  64003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64004. }
  64005. /**
  64006. * Info for a bounding data of a mesh
  64007. */
  64008. export class BoundingInfo implements ICullable {
  64009. /**
  64010. * Bounding box for the mesh
  64011. */
  64012. readonly boundingBox: BoundingBox;
  64013. /**
  64014. * Bounding sphere for the mesh
  64015. */
  64016. readonly boundingSphere: BoundingSphere;
  64017. private _isLocked;
  64018. private static readonly TmpVector3;
  64019. /**
  64020. * Constructs bounding info
  64021. * @param minimum min vector of the bounding box/sphere
  64022. * @param maximum max vector of the bounding box/sphere
  64023. * @param worldMatrix defines the new world matrix
  64024. */
  64025. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64026. /**
  64027. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64028. * @param min defines the new minimum vector (in local space)
  64029. * @param max defines the new maximum vector (in local space)
  64030. * @param worldMatrix defines the new world matrix
  64031. */
  64032. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64033. /**
  64034. * min vector of the bounding box/sphere
  64035. */
  64036. readonly minimum: Vector3;
  64037. /**
  64038. * max vector of the bounding box/sphere
  64039. */
  64040. readonly maximum: Vector3;
  64041. /**
  64042. * If the info is locked and won't be updated to avoid perf overhead
  64043. */
  64044. isLocked: boolean;
  64045. /**
  64046. * Updates the bounding sphere and box
  64047. * @param world world matrix to be used to update
  64048. */
  64049. update(world: DeepImmutable<Matrix>): void;
  64050. /**
  64051. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64052. * @param center New center of the bounding info
  64053. * @param extend New extend of the bounding info
  64054. * @returns the current bounding info
  64055. */
  64056. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64057. /**
  64058. * Scale the current bounding info by applying a scale factor
  64059. * @param factor defines the scale factor to apply
  64060. * @returns the current bounding info
  64061. */
  64062. scale(factor: number): BoundingInfo;
  64063. /**
  64064. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64065. * @param frustumPlanes defines the frustum to test
  64066. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64067. * @returns true if the bounding info is in the frustum planes
  64068. */
  64069. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64070. /**
  64071. * Gets the world distance between the min and max points of the bounding box
  64072. */
  64073. readonly diagonalLength: number;
  64074. /**
  64075. * Checks if a cullable object (mesh...) is in the camera frustum
  64076. * Unlike isInFrustum this cheks the full bounding box
  64077. * @param frustumPlanes Camera near/planes
  64078. * @returns true if the object is in frustum otherwise false
  64079. */
  64080. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64081. /** @hidden */
  64082. _checkCollision(collider: Collider): boolean;
  64083. /**
  64084. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64085. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64086. * @param point the point to check intersection with
  64087. * @returns if the point intersects
  64088. */
  64089. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64090. /**
  64091. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64092. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64093. * @param boundingInfo the bounding info to check intersection with
  64094. * @param precise if the intersection should be done using OBB
  64095. * @returns if the bounding info intersects
  64096. */
  64097. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64098. }
  64099. }
  64100. declare module BABYLON {
  64101. /**
  64102. * Defines an array and its length.
  64103. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64104. */
  64105. export interface ISmartArrayLike<T> {
  64106. /**
  64107. * The data of the array.
  64108. */
  64109. data: Array<T>;
  64110. /**
  64111. * The active length of the array.
  64112. */
  64113. length: number;
  64114. }
  64115. /**
  64116. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64117. */
  64118. export class SmartArray<T> implements ISmartArrayLike<T> {
  64119. /**
  64120. * The full set of data from the array.
  64121. */
  64122. data: Array<T>;
  64123. /**
  64124. * The active length of the array.
  64125. */
  64126. length: number;
  64127. protected _id: number;
  64128. /**
  64129. * Instantiates a Smart Array.
  64130. * @param capacity defines the default capacity of the array.
  64131. */
  64132. constructor(capacity: number);
  64133. /**
  64134. * Pushes a value at the end of the active data.
  64135. * @param value defines the object to push in the array.
  64136. */
  64137. push(value: T): void;
  64138. /**
  64139. * Iterates over the active data and apply the lambda to them.
  64140. * @param func defines the action to apply on each value.
  64141. */
  64142. forEach(func: (content: T) => void): void;
  64143. /**
  64144. * Sorts the full sets of data.
  64145. * @param compareFn defines the comparison function to apply.
  64146. */
  64147. sort(compareFn: (a: T, b: T) => number): void;
  64148. /**
  64149. * Resets the active data to an empty array.
  64150. */
  64151. reset(): void;
  64152. /**
  64153. * Releases all the data from the array as well as the array.
  64154. */
  64155. dispose(): void;
  64156. /**
  64157. * Concats the active data with a given array.
  64158. * @param array defines the data to concatenate with.
  64159. */
  64160. concat(array: any): void;
  64161. /**
  64162. * Returns the position of a value in the active data.
  64163. * @param value defines the value to find the index for
  64164. * @returns the index if found in the active data otherwise -1
  64165. */
  64166. indexOf(value: T): number;
  64167. /**
  64168. * Returns whether an element is part of the active data.
  64169. * @param value defines the value to look for
  64170. * @returns true if found in the active data otherwise false
  64171. */
  64172. contains(value: T): boolean;
  64173. private static _GlobalId;
  64174. }
  64175. /**
  64176. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64177. * The data in this array can only be present once
  64178. */
  64179. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64180. private _duplicateId;
  64181. /**
  64182. * Pushes a value at the end of the active data.
  64183. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64184. * @param value defines the object to push in the array.
  64185. */
  64186. push(value: T): void;
  64187. /**
  64188. * Pushes a value at the end of the active data.
  64189. * If the data is already present, it won t be added again
  64190. * @param value defines the object to push in the array.
  64191. * @returns true if added false if it was already present
  64192. */
  64193. pushNoDuplicate(value: T): boolean;
  64194. /**
  64195. * Resets the active data to an empty array.
  64196. */
  64197. reset(): void;
  64198. /**
  64199. * Concats the active data with a given array.
  64200. * This ensures no dupplicate will be present in the result.
  64201. * @param array defines the data to concatenate with.
  64202. */
  64203. concatWithNoDuplicate(array: any): void;
  64204. }
  64205. }
  64206. declare module BABYLON {
  64207. /**
  64208. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64209. * separate meshes. This can be use to improve performances.
  64210. * @see http://doc.babylonjs.com/how_to/multi_materials
  64211. */
  64212. export class MultiMaterial extends Material {
  64213. private _subMaterials;
  64214. /**
  64215. * Gets or Sets the list of Materials used within the multi material.
  64216. * They need to be ordered according to the submeshes order in the associated mesh
  64217. */
  64218. subMaterials: Nullable<Material>[];
  64219. /**
  64220. * Function used to align with Node.getChildren()
  64221. * @returns the list of Materials used within the multi material
  64222. */
  64223. getChildren(): Nullable<Material>[];
  64224. /**
  64225. * Instantiates a new Multi Material
  64226. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64227. * separate meshes. This can be use to improve performances.
  64228. * @see http://doc.babylonjs.com/how_to/multi_materials
  64229. * @param name Define the name in the scene
  64230. * @param scene Define the scene the material belongs to
  64231. */
  64232. constructor(name: string, scene: Scene);
  64233. private _hookArray;
  64234. /**
  64235. * Get one of the submaterial by its index in the submaterials array
  64236. * @param index The index to look the sub material at
  64237. * @returns The Material if the index has been defined
  64238. */
  64239. getSubMaterial(index: number): Nullable<Material>;
  64240. /**
  64241. * Get the list of active textures for the whole sub materials list.
  64242. * @returns All the textures that will be used during the rendering
  64243. */
  64244. getActiveTextures(): BaseTexture[];
  64245. /**
  64246. * Gets the current class name of the material e.g. "MultiMaterial"
  64247. * Mainly use in serialization.
  64248. * @returns the class name
  64249. */
  64250. getClassName(): string;
  64251. /**
  64252. * Checks if the material is ready to render the requested sub mesh
  64253. * @param mesh Define the mesh the submesh belongs to
  64254. * @param subMesh Define the sub mesh to look readyness for
  64255. * @param useInstances Define whether or not the material is used with instances
  64256. * @returns true if ready, otherwise false
  64257. */
  64258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64259. /**
  64260. * Clones the current material and its related sub materials
  64261. * @param name Define the name of the newly cloned material
  64262. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64263. * @returns the cloned material
  64264. */
  64265. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64266. /**
  64267. * Serializes the materials into a JSON representation.
  64268. * @returns the JSON representation
  64269. */
  64270. serialize(): any;
  64271. /**
  64272. * Dispose the material and release its associated resources
  64273. * @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)
  64274. * @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)
  64275. * @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)
  64276. */
  64277. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64278. /**
  64279. * Creates a MultiMaterial from parsed MultiMaterial data.
  64280. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64281. * @param scene defines the hosting scene
  64282. * @returns a new MultiMaterial
  64283. */
  64284. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /**
  64289. * Class used to represent data loading progression
  64290. */
  64291. export class SceneLoaderFlags {
  64292. private static _ForceFullSceneLoadingForIncremental;
  64293. private static _ShowLoadingScreen;
  64294. private static _CleanBoneMatrixWeights;
  64295. private static _loggingLevel;
  64296. /**
  64297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64298. */
  64299. static ForceFullSceneLoadingForIncremental: boolean;
  64300. /**
  64301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64302. */
  64303. static ShowLoadingScreen: boolean;
  64304. /**
  64305. * Defines the current logging level (while loading the scene)
  64306. * @ignorenaming
  64307. */
  64308. static loggingLevel: number;
  64309. /**
  64310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64311. */
  64312. static CleanBoneMatrixWeights: boolean;
  64313. }
  64314. }
  64315. declare module BABYLON {
  64316. /**
  64317. * 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.
  64318. * @see https://doc.babylonjs.com/how_to/transformnode
  64319. */
  64320. export class TransformNode extends Node {
  64321. /**
  64322. * Object will not rotate to face the camera
  64323. */
  64324. static BILLBOARDMODE_NONE: number;
  64325. /**
  64326. * Object will rotate to face the camera but only on the x axis
  64327. */
  64328. static BILLBOARDMODE_X: number;
  64329. /**
  64330. * Object will rotate to face the camera but only on the y axis
  64331. */
  64332. static BILLBOARDMODE_Y: number;
  64333. /**
  64334. * Object will rotate to face the camera but only on the z axis
  64335. */
  64336. static BILLBOARDMODE_Z: number;
  64337. /**
  64338. * Object will rotate to face the camera
  64339. */
  64340. static BILLBOARDMODE_ALL: number;
  64341. private _forward;
  64342. private _forwardInverted;
  64343. private _up;
  64344. private _right;
  64345. private _rightInverted;
  64346. private _position;
  64347. private _rotation;
  64348. private _rotationQuaternion;
  64349. protected _scaling: Vector3;
  64350. protected _isDirty: boolean;
  64351. private _transformToBoneReferal;
  64352. /**
  64353. * Set the billboard mode. Default is 0.
  64354. *
  64355. * | Value | Type | Description |
  64356. * | --- | --- | --- |
  64357. * | 0 | BILLBOARDMODE_NONE | |
  64358. * | 1 | BILLBOARDMODE_X | |
  64359. * | 2 | BILLBOARDMODE_Y | |
  64360. * | 4 | BILLBOARDMODE_Z | |
  64361. * | 7 | BILLBOARDMODE_ALL | |
  64362. *
  64363. */
  64364. billboardMode: number;
  64365. /**
  64366. * 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
  64367. */
  64368. scalingDeterminant: number;
  64369. /**
  64370. * Sets the distance of the object to max, often used by skybox
  64371. */
  64372. infiniteDistance: boolean;
  64373. /**
  64374. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64375. * By default the system will update normals to compensate
  64376. */
  64377. ignoreNonUniformScaling: boolean;
  64378. /** @hidden */
  64379. _poseMatrix: Matrix;
  64380. /** @hidden */
  64381. _localMatrix: Matrix;
  64382. private _absolutePosition;
  64383. private _pivotMatrix;
  64384. private _pivotMatrixInverse;
  64385. protected _postMultiplyPivotMatrix: boolean;
  64386. protected _isWorldMatrixFrozen: boolean;
  64387. /** @hidden */
  64388. _indexInSceneTransformNodesArray: number;
  64389. /**
  64390. * An event triggered after the world matrix is updated
  64391. */
  64392. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64393. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64394. /**
  64395. * Gets a string identifying the name of the class
  64396. * @returns "TransformNode" string
  64397. */
  64398. getClassName(): string;
  64399. /**
  64400. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64401. */
  64402. position: Vector3;
  64403. /**
  64404. * 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)).
  64405. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64406. */
  64407. rotation: Vector3;
  64408. /**
  64409. * 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)).
  64410. */
  64411. scaling: Vector3;
  64412. /**
  64413. * 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).
  64414. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64415. */
  64416. rotationQuaternion: Nullable<Quaternion>;
  64417. /**
  64418. * The forward direction of that transform in world space.
  64419. */
  64420. readonly forward: Vector3;
  64421. /**
  64422. * The up direction of that transform in world space.
  64423. */
  64424. readonly up: Vector3;
  64425. /**
  64426. * The right direction of that transform in world space.
  64427. */
  64428. readonly right: Vector3;
  64429. /**
  64430. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64431. * @param matrix the matrix to copy the pose from
  64432. * @returns this TransformNode.
  64433. */
  64434. updatePoseMatrix(matrix: Matrix): TransformNode;
  64435. /**
  64436. * Returns the mesh Pose matrix.
  64437. * @returns the pose matrix
  64438. */
  64439. getPoseMatrix(): Matrix;
  64440. /** @hidden */
  64441. _isSynchronized(): boolean;
  64442. /** @hidden */
  64443. _initCache(): void;
  64444. /**
  64445. * Flag the transform node as dirty (Forcing it to update everything)
  64446. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64447. * @returns this transform node
  64448. */
  64449. markAsDirty(property: string): TransformNode;
  64450. /**
  64451. * Returns the current mesh absolute position.
  64452. * Returns a Vector3.
  64453. */
  64454. readonly absolutePosition: Vector3;
  64455. /**
  64456. * Sets a new matrix to apply before all other transformation
  64457. * @param matrix defines the transform matrix
  64458. * @returns the current TransformNode
  64459. */
  64460. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64461. /**
  64462. * Sets a new pivot matrix to the current node
  64463. * @param matrix defines the new pivot matrix to use
  64464. * @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
  64465. * @returns the current TransformNode
  64466. */
  64467. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64468. /**
  64469. * Returns the mesh pivot matrix.
  64470. * Default : Identity.
  64471. * @returns the matrix
  64472. */
  64473. getPivotMatrix(): Matrix;
  64474. /**
  64475. * Prevents the World matrix to be computed any longer.
  64476. * @returns the TransformNode.
  64477. */
  64478. freezeWorldMatrix(): TransformNode;
  64479. /**
  64480. * Allows back the World matrix computation.
  64481. * @returns the TransformNode.
  64482. */
  64483. unfreezeWorldMatrix(): this;
  64484. /**
  64485. * True if the World matrix has been frozen.
  64486. */
  64487. readonly isWorldMatrixFrozen: boolean;
  64488. /**
  64489. * Retuns the mesh absolute position in the World.
  64490. * @returns a Vector3.
  64491. */
  64492. getAbsolutePosition(): Vector3;
  64493. /**
  64494. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64495. * @param absolutePosition the absolute position to set
  64496. * @returns the TransformNode.
  64497. */
  64498. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64499. /**
  64500. * Sets the mesh position in its local space.
  64501. * @param vector3 the position to set in localspace
  64502. * @returns the TransformNode.
  64503. */
  64504. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64505. /**
  64506. * Returns the mesh position in the local space from the current World matrix values.
  64507. * @returns a new Vector3.
  64508. */
  64509. getPositionExpressedInLocalSpace(): Vector3;
  64510. /**
  64511. * Translates the mesh along the passed Vector3 in its local space.
  64512. * @param vector3 the distance to translate in localspace
  64513. * @returns the TransformNode.
  64514. */
  64515. locallyTranslate(vector3: Vector3): TransformNode;
  64516. private static _lookAtVectorCache;
  64517. /**
  64518. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64519. * @param targetPoint the position (must be in same space as current mesh) to look at
  64520. * @param yawCor optional yaw (y-axis) correction in radians
  64521. * @param pitchCor optional pitch (x-axis) correction in radians
  64522. * @param rollCor optional roll (z-axis) correction in radians
  64523. * @param space the choosen space of the target
  64524. * @returns the TransformNode.
  64525. */
  64526. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64527. /**
  64528. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64529. * This Vector3 is expressed in the World space.
  64530. * @param localAxis axis to rotate
  64531. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64532. */
  64533. getDirection(localAxis: Vector3): Vector3;
  64534. /**
  64535. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64536. * localAxis is expressed in the mesh local space.
  64537. * result is computed in the Wordl space from the mesh World matrix.
  64538. * @param localAxis axis to rotate
  64539. * @param result the resulting transformnode
  64540. * @returns this TransformNode.
  64541. */
  64542. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  64543. /**
  64544. * Sets this transform node rotation to the given local axis.
  64545. * @param localAxis the axis in local space
  64546. * @param yawCor optional yaw (y-axis) correction in radians
  64547. * @param pitchCor optional pitch (x-axis) correction in radians
  64548. * @param rollCor optional roll (z-axis) correction in radians
  64549. * @returns this TransformNode
  64550. */
  64551. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  64552. /**
  64553. * Sets a new pivot point to the current node
  64554. * @param point defines the new pivot point to use
  64555. * @param space defines if the point is in world or local space (local by default)
  64556. * @returns the current TransformNode
  64557. */
  64558. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  64559. /**
  64560. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  64561. * @returns the pivot point
  64562. */
  64563. getPivotPoint(): Vector3;
  64564. /**
  64565. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  64566. * @param result the vector3 to store the result
  64567. * @returns this TransformNode.
  64568. */
  64569. getPivotPointToRef(result: Vector3): TransformNode;
  64570. /**
  64571. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  64572. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  64573. */
  64574. getAbsolutePivotPoint(): Vector3;
  64575. /**
  64576. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  64577. * @param result vector3 to store the result
  64578. * @returns this TransformNode.
  64579. */
  64580. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  64581. /**
  64582. * Defines the passed node as the parent of the current node.
  64583. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  64584. * @param node the node ot set as the parent
  64585. * @returns this TransformNode.
  64586. */
  64587. setParent(node: Nullable<Node>): TransformNode;
  64588. private _nonUniformScaling;
  64589. /**
  64590. * True if the scaling property of this object is non uniform eg. (1,2,1)
  64591. */
  64592. readonly nonUniformScaling: boolean;
  64593. /** @hidden */
  64594. _updateNonUniformScalingState(value: boolean): boolean;
  64595. /**
  64596. * Attach the current TransformNode to another TransformNode associated with a bone
  64597. * @param bone Bone affecting the TransformNode
  64598. * @param affectedTransformNode TransformNode associated with the bone
  64599. * @returns this object
  64600. */
  64601. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  64602. /**
  64603. * Detach the transform node if its associated with a bone
  64604. * @returns this object
  64605. */
  64606. detachFromBone(): TransformNode;
  64607. private static _rotationAxisCache;
  64608. /**
  64609. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  64610. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64611. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64612. * The passed axis is also normalized.
  64613. * @param axis the axis to rotate around
  64614. * @param amount the amount to rotate in radians
  64615. * @param space Space to rotate in (Default: local)
  64616. * @returns the TransformNode.
  64617. */
  64618. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  64619. /**
  64620. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  64621. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64622. * The passed axis is also normalized. .
  64623. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  64624. * @param point the point to rotate around
  64625. * @param axis the axis to rotate around
  64626. * @param amount the amount to rotate in radians
  64627. * @returns the TransformNode
  64628. */
  64629. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  64630. /**
  64631. * Translates the mesh along the axis vector for the passed distance in the given space.
  64632. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64633. * @param axis the axis to translate in
  64634. * @param distance the distance to translate
  64635. * @param space Space to rotate in (Default: local)
  64636. * @returns the TransformNode.
  64637. */
  64638. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  64639. /**
  64640. * Adds a rotation step to the mesh current rotation.
  64641. * x, y, z are Euler angles expressed in radians.
  64642. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  64643. * This means this rotation is made in the mesh local space only.
  64644. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  64645. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  64646. * ```javascript
  64647. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  64648. * ```
  64649. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  64650. * 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.
  64651. * @param x Rotation to add
  64652. * @param y Rotation to add
  64653. * @param z Rotation to add
  64654. * @returns the TransformNode.
  64655. */
  64656. addRotation(x: number, y: number, z: number): TransformNode;
  64657. /**
  64658. * Computes the world matrix of the node
  64659. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  64660. * @returns the world matrix
  64661. */
  64662. computeWorldMatrix(force?: boolean): Matrix;
  64663. protected _afterComputeWorldMatrix(): void;
  64664. /**
  64665. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  64666. * @param func callback function to add
  64667. *
  64668. * @returns the TransformNode.
  64669. */
  64670. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64671. /**
  64672. * Removes a registered callback function.
  64673. * @param func callback function to remove
  64674. * @returns the TransformNode.
  64675. */
  64676. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64677. /**
  64678. * Gets the position of the current mesh in camera space
  64679. * @param camera defines the camera to use
  64680. * @returns a position
  64681. */
  64682. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  64683. /**
  64684. * Returns the distance from the mesh to the active camera
  64685. * @param camera defines the camera to use
  64686. * @returns the distance
  64687. */
  64688. getDistanceToCamera(camera?: Nullable<Camera>): number;
  64689. /**
  64690. * Clone the current transform node
  64691. * @param name Name of the new clone
  64692. * @param newParent New parent for the clone
  64693. * @param doNotCloneChildren Do not clone children hierarchy
  64694. * @returns the new transform node
  64695. */
  64696. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  64697. /**
  64698. * Serializes the objects information.
  64699. * @param currentSerializationObject defines the object to serialize in
  64700. * @returns the serialized object
  64701. */
  64702. serialize(currentSerializationObject?: any): any;
  64703. /**
  64704. * Returns a new TransformNode object parsed from the source provided.
  64705. * @param parsedTransformNode is the source.
  64706. * @param scene the scne the object belongs to
  64707. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  64708. * @returns a new TransformNode object parsed from the source provided.
  64709. */
  64710. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  64711. /**
  64712. * Get all child-transformNodes of this node
  64713. * @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
  64714. * @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
  64715. * @returns an array of TransformNode
  64716. */
  64717. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  64718. /**
  64719. * Releases resources associated with this transform node.
  64720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64722. */
  64723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64724. }
  64725. }
  64726. declare module BABYLON {
  64727. /**
  64728. * Class used to override all child animations of a given target
  64729. */
  64730. export class AnimationPropertiesOverride {
  64731. /**
  64732. * Gets or sets a value indicating if animation blending must be used
  64733. */
  64734. enableBlending: boolean;
  64735. /**
  64736. * Gets or sets the blending speed to use when enableBlending is true
  64737. */
  64738. blendingSpeed: number;
  64739. /**
  64740. * Gets or sets the default loop mode to use
  64741. */
  64742. loopMode: number;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Class used to store bone information
  64748. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  64749. */
  64750. export class Bone extends Node {
  64751. /**
  64752. * defines the bone name
  64753. */
  64754. name: string;
  64755. private static _tmpVecs;
  64756. private static _tmpQuat;
  64757. private static _tmpMats;
  64758. /**
  64759. * Gets the list of child bones
  64760. */
  64761. children: Bone[];
  64762. /** Gets the animations associated with this bone */
  64763. animations: Animation[];
  64764. /**
  64765. * Gets or sets bone length
  64766. */
  64767. length: number;
  64768. /**
  64769. * @hidden Internal only
  64770. * Set this value to map this bone to a different index in the transform matrices
  64771. * Set this value to -1 to exclude the bone from the transform matrices
  64772. */
  64773. _index: Nullable<number>;
  64774. private _skeleton;
  64775. private _localMatrix;
  64776. private _restPose;
  64777. private _baseMatrix;
  64778. private _absoluteTransform;
  64779. private _invertedAbsoluteTransform;
  64780. private _parent;
  64781. private _scalingDeterminant;
  64782. private _worldTransform;
  64783. private _localScaling;
  64784. private _localRotation;
  64785. private _localPosition;
  64786. private _needToDecompose;
  64787. private _needToCompose;
  64788. /** @hidden */
  64789. _linkedTransformNode: Nullable<TransformNode>;
  64790. /** @hidden */
  64791. /** @hidden */
  64792. _matrix: Matrix;
  64793. /**
  64794. * Create a new bone
  64795. * @param name defines the bone name
  64796. * @param skeleton defines the parent skeleton
  64797. * @param parentBone defines the parent (can be null if the bone is the root)
  64798. * @param localMatrix defines the local matrix
  64799. * @param restPose defines the rest pose matrix
  64800. * @param baseMatrix defines the base matrix
  64801. * @param index defines index of the bone in the hiearchy
  64802. */
  64803. constructor(
  64804. /**
  64805. * defines the bone name
  64806. */
  64807. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  64808. /**
  64809. * Gets the parent skeleton
  64810. * @returns a skeleton
  64811. */
  64812. getSkeleton(): Skeleton;
  64813. /**
  64814. * Gets parent bone
  64815. * @returns a bone or null if the bone is the root of the bone hierarchy
  64816. */
  64817. getParent(): Nullable<Bone>;
  64818. /**
  64819. * Sets the parent bone
  64820. * @param parent defines the parent (can be null if the bone is the root)
  64821. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64822. */
  64823. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  64824. /**
  64825. * Gets the local matrix
  64826. * @returns a matrix
  64827. */
  64828. getLocalMatrix(): Matrix;
  64829. /**
  64830. * Gets the base matrix (initial matrix which remains unchanged)
  64831. * @returns a matrix
  64832. */
  64833. getBaseMatrix(): Matrix;
  64834. /**
  64835. * Gets the rest pose matrix
  64836. * @returns a matrix
  64837. */
  64838. getRestPose(): Matrix;
  64839. /**
  64840. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  64841. */
  64842. getWorldMatrix(): Matrix;
  64843. /**
  64844. * Sets the local matrix to rest pose matrix
  64845. */
  64846. returnToRest(): void;
  64847. /**
  64848. * Gets the inverse of the absolute transform matrix.
  64849. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  64850. * @returns a matrix
  64851. */
  64852. getInvertedAbsoluteTransform(): Matrix;
  64853. /**
  64854. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  64855. * @returns a matrix
  64856. */
  64857. getAbsoluteTransform(): Matrix;
  64858. /**
  64859. * Links with the given transform node.
  64860. * The local matrix of this bone is copied from the transform node every frame.
  64861. * @param transformNode defines the transform node to link to
  64862. */
  64863. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  64864. /** Gets or sets current position (in local space) */
  64865. position: Vector3;
  64866. /** Gets or sets current rotation (in local space) */
  64867. rotation: Vector3;
  64868. /** Gets or sets current rotation quaternion (in local space) */
  64869. rotationQuaternion: Quaternion;
  64870. /** Gets or sets current scaling (in local space) */
  64871. scaling: Vector3;
  64872. /**
  64873. * Gets the animation properties override
  64874. */
  64875. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64876. private _decompose;
  64877. private _compose;
  64878. /**
  64879. * Update the base and local matrices
  64880. * @param matrix defines the new base or local matrix
  64881. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64882. * @param updateLocalMatrix defines if the local matrix should be updated
  64883. */
  64884. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  64885. /** @hidden */
  64886. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  64887. /**
  64888. * Flag the bone as dirty (Forcing it to update everything)
  64889. */
  64890. markAsDirty(): void;
  64891. private _markAsDirtyAndCompose;
  64892. private _markAsDirtyAndDecompose;
  64893. /**
  64894. * Translate the bone in local or world space
  64895. * @param vec The amount to translate the bone
  64896. * @param space The space that the translation is in
  64897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64898. */
  64899. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64900. /**
  64901. * Set the postion of the bone in local or world space
  64902. * @param position The position to set the bone
  64903. * @param space The space that the position is in
  64904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64905. */
  64906. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64907. /**
  64908. * Set the absolute position of the bone (world space)
  64909. * @param position The position to set the bone
  64910. * @param mesh The mesh that this bone is attached to
  64911. */
  64912. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  64913. /**
  64914. * Scale the bone on the x, y and z axes (in local space)
  64915. * @param x The amount to scale the bone on the x axis
  64916. * @param y The amount to scale the bone on the y axis
  64917. * @param z The amount to scale the bone on the z axis
  64918. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  64919. */
  64920. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  64921. /**
  64922. * Set the bone scaling in local space
  64923. * @param scale defines the scaling vector
  64924. */
  64925. setScale(scale: Vector3): void;
  64926. /**
  64927. * Gets the current scaling in local space
  64928. * @returns the current scaling vector
  64929. */
  64930. getScale(): Vector3;
  64931. /**
  64932. * Gets the current scaling in local space and stores it in a target vector
  64933. * @param result defines the target vector
  64934. */
  64935. getScaleToRef(result: Vector3): void;
  64936. /**
  64937. * Set the yaw, pitch, and roll of the bone in local or world space
  64938. * @param yaw The rotation of the bone on the y axis
  64939. * @param pitch The rotation of the bone on the x axis
  64940. * @param roll The rotation of the bone on the z axis
  64941. * @param space The space that the axes of rotation are in
  64942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64943. */
  64944. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  64945. /**
  64946. * Add a rotation to the bone on an axis in local or world space
  64947. * @param axis The axis to rotate the bone on
  64948. * @param amount The amount to rotate the bone
  64949. * @param space The space that the axis is in
  64950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64951. */
  64952. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  64953. /**
  64954. * Set the rotation of the bone to a particular axis angle in local or world space
  64955. * @param axis The axis to rotate the bone on
  64956. * @param angle The angle that the bone should be rotated to
  64957. * @param space The space that the axis is in
  64958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64959. */
  64960. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  64961. /**
  64962. * Set the euler rotation of the bone in local of world space
  64963. * @param rotation The euler rotation that the bone should be set to
  64964. * @param space The space that the rotation is in
  64965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64966. */
  64967. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64968. /**
  64969. * Set the quaternion rotation of the bone in local of world space
  64970. * @param quat The quaternion rotation that the bone should be set to
  64971. * @param space The space that the rotation is in
  64972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64973. */
  64974. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  64975. /**
  64976. * Set the rotation matrix of the bone in local of world space
  64977. * @param rotMat The rotation matrix that the bone should be set to
  64978. * @param space The space that the rotation is in
  64979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64980. */
  64981. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  64982. private _rotateWithMatrix;
  64983. private _getNegativeRotationToRef;
  64984. /**
  64985. * Get the position of the bone in local or world space
  64986. * @param space The space that the returned position is in
  64987. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64988. * @returns The position of the bone
  64989. */
  64990. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  64991. /**
  64992. * Copy the position of the bone to a vector3 in local or world space
  64993. * @param space The space that the returned position is in
  64994. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64995. * @param result The vector3 to copy the position to
  64996. */
  64997. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  64998. /**
  64999. * Get the absolute position of the bone (world space)
  65000. * @param mesh The mesh that this bone is attached to
  65001. * @returns The absolute position of the bone
  65002. */
  65003. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65004. /**
  65005. * Copy the absolute position of the bone (world space) to the result param
  65006. * @param mesh The mesh that this bone is attached to
  65007. * @param result The vector3 to copy the absolute position to
  65008. */
  65009. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65010. /**
  65011. * Compute the absolute transforms of this bone and its children
  65012. */
  65013. computeAbsoluteTransforms(): void;
  65014. /**
  65015. * Get the world direction from an axis that is in the local space of the bone
  65016. * @param localAxis The local direction that is used to compute the world direction
  65017. * @param mesh The mesh that this bone is attached to
  65018. * @returns The world direction
  65019. */
  65020. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65021. /**
  65022. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65023. * @param localAxis The local direction that is used to compute the world direction
  65024. * @param mesh The mesh that this bone is attached to
  65025. * @param result The vector3 that the world direction will be copied to
  65026. */
  65027. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65028. /**
  65029. * Get the euler rotation of the bone in local or world space
  65030. * @param space The space that the rotation should be in
  65031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65032. * @returns The euler rotation
  65033. */
  65034. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65035. /**
  65036. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65037. * @param space The space that the rotation should be in
  65038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65039. * @param result The vector3 that the rotation should be copied to
  65040. */
  65041. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65042. /**
  65043. * Get the quaternion rotation of the bone in either local or world space
  65044. * @param space The space that the rotation should be in
  65045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65046. * @returns The quaternion rotation
  65047. */
  65048. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65049. /**
  65050. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65051. * @param space The space that the rotation should be in
  65052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65053. * @param result The quaternion that the rotation should be copied to
  65054. */
  65055. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65056. /**
  65057. * Get the rotation matrix of the bone in local or world space
  65058. * @param space The space that the rotation should be in
  65059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65060. * @returns The rotation matrix
  65061. */
  65062. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65063. /**
  65064. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65065. * @param space The space that the rotation should be in
  65066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65067. * @param result The quaternion that the rotation should be copied to
  65068. */
  65069. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65070. /**
  65071. * Get the world position of a point that is in the local space of the bone
  65072. * @param position The local position
  65073. * @param mesh The mesh that this bone is attached to
  65074. * @returns The world position
  65075. */
  65076. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65077. /**
  65078. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65079. * @param position The local position
  65080. * @param mesh The mesh that this bone is attached to
  65081. * @param result The vector3 that the world position should be copied to
  65082. */
  65083. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65084. /**
  65085. * Get the local position of a point that is in world space
  65086. * @param position The world position
  65087. * @param mesh The mesh that this bone is attached to
  65088. * @returns The local position
  65089. */
  65090. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65091. /**
  65092. * Get the local position of a point that is in world space and copy it to the result param
  65093. * @param position The world position
  65094. * @param mesh The mesh that this bone is attached to
  65095. * @param result The vector3 that the local position should be copied to
  65096. */
  65097. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65098. }
  65099. }
  65100. declare module BABYLON {
  65101. /**
  65102. * Class for creating a cube texture
  65103. */
  65104. export class CubeTexture extends BaseTexture {
  65105. private _delayedOnLoad;
  65106. /**
  65107. * The url of the texture
  65108. */
  65109. url: string;
  65110. /**
  65111. * Gets or sets the center of the bounding box associated with the cube texture.
  65112. * It must define where the camera used to render the texture was set
  65113. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65114. */
  65115. boundingBoxPosition: Vector3;
  65116. private _boundingBoxSize;
  65117. /**
  65118. * Gets or sets the size of the bounding box associated with the cube texture
  65119. * When defined, the cubemap will switch to local mode
  65120. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65121. * @example https://www.babylonjs-playground.com/#RNASML
  65122. */
  65123. /**
  65124. * Returns the bounding box size
  65125. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65126. */
  65127. boundingBoxSize: Vector3;
  65128. protected _rotationY: number;
  65129. /**
  65130. * Sets texture matrix rotation angle around Y axis in radians.
  65131. */
  65132. /**
  65133. * Gets texture matrix rotation angle around Y axis radians.
  65134. */
  65135. rotationY: number;
  65136. /**
  65137. * Are mip maps generated for this texture or not.
  65138. */
  65139. readonly noMipmap: boolean;
  65140. private _noMipmap;
  65141. private _files;
  65142. private _extensions;
  65143. private _textureMatrix;
  65144. private _format;
  65145. private _createPolynomials;
  65146. /** @hidden */
  65147. _prefiltered: boolean;
  65148. /**
  65149. * Creates a cube texture from an array of image urls
  65150. * @param files defines an array of image urls
  65151. * @param scene defines the hosting scene
  65152. * @param noMipmap specifies if mip maps are not used
  65153. * @returns a cube texture
  65154. */
  65155. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65156. /**
  65157. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65158. * @param url defines the url of the prefiltered texture
  65159. * @param scene defines the scene the texture is attached to
  65160. * @param forcedExtension defines the extension of the file if different from the url
  65161. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65162. * @return the prefiltered texture
  65163. */
  65164. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65165. /**
  65166. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65167. * as prefiltered data.
  65168. * @param rootUrl defines the url of the texture or the root name of the six images
  65169. * @param scene defines the scene the texture is attached to
  65170. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65171. * @param noMipmap defines if mipmaps should be created or not
  65172. * @param files defines the six files to load for the different faces
  65173. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65174. * @param onError defines a callback triggered in case of error during load
  65175. * @param format defines the internal format to use for the texture once loaded
  65176. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65177. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65178. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65179. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65180. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65181. * @return the cube texture
  65182. */
  65183. 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);
  65184. /**
  65185. * Get the current class name of the texture useful for serialization or dynamic coding.
  65186. * @returns "CubeTexture"
  65187. */
  65188. getClassName(): string;
  65189. /**
  65190. * Update the url (and optional buffer) of this texture if url was null during construction.
  65191. * @param url the url of the texture
  65192. * @param forcedExtension defines the extension to use
  65193. * @param onLoad callback called when the texture is loaded (defaults to null)
  65194. */
  65195. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65196. /**
  65197. * Delays loading of the cube texture
  65198. * @param forcedExtension defines the extension to use
  65199. */
  65200. delayLoad(forcedExtension?: string): void;
  65201. /**
  65202. * Returns the reflection texture matrix
  65203. * @returns the reflection texture matrix
  65204. */
  65205. getReflectionTextureMatrix(): Matrix;
  65206. /**
  65207. * Sets the reflection texture matrix
  65208. * @param value Reflection texture matrix
  65209. */
  65210. setReflectionTextureMatrix(value: Matrix): void;
  65211. /**
  65212. * Parses text to create a cube texture
  65213. * @param parsedTexture define the serialized text to read from
  65214. * @param scene defines the hosting scene
  65215. * @param rootUrl defines the root url of the cube texture
  65216. * @returns a cube texture
  65217. */
  65218. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65219. /**
  65220. * Makes a clone, or deep copy, of the cube texture
  65221. * @returns a new cube texture
  65222. */
  65223. clone(): CubeTexture;
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /** @hidden */
  65228. export var postprocessVertexShader: {
  65229. name: string;
  65230. shader: string;
  65231. };
  65232. }
  65233. declare module BABYLON {
  65234. /**
  65235. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65236. * This is the base of the follow, arc rotate cameras and Free camera
  65237. * @see http://doc.babylonjs.com/features/cameras
  65238. */
  65239. export class TargetCamera extends Camera {
  65240. private static _RigCamTransformMatrix;
  65241. private static _TargetTransformMatrix;
  65242. private static _TargetFocalPoint;
  65243. /**
  65244. * Define the current direction the camera is moving to
  65245. */
  65246. cameraDirection: Vector3;
  65247. /**
  65248. * Define the current rotation the camera is rotating to
  65249. */
  65250. cameraRotation: Vector2;
  65251. /**
  65252. * When set, the up vector of the camera will be updated by the rotation of the camera
  65253. */
  65254. updateUpVectorFromRotation: boolean;
  65255. private _tmpQuaternion;
  65256. /**
  65257. * Define the current rotation of the camera
  65258. */
  65259. rotation: Vector3;
  65260. /**
  65261. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65262. */
  65263. rotationQuaternion: Quaternion;
  65264. /**
  65265. * Define the current speed of the camera
  65266. */
  65267. speed: number;
  65268. /**
  65269. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65270. * around all axis.
  65271. */
  65272. noRotationConstraint: boolean;
  65273. /**
  65274. * Define the current target of the camera as an object or a position.
  65275. */
  65276. lockedTarget: any;
  65277. /** @hidden */
  65278. _currentTarget: Vector3;
  65279. /** @hidden */
  65280. _initialFocalDistance: number;
  65281. /** @hidden */
  65282. _viewMatrix: Matrix;
  65283. /** @hidden */
  65284. _camMatrix: Matrix;
  65285. /** @hidden */
  65286. _cameraTransformMatrix: Matrix;
  65287. /** @hidden */
  65288. _cameraRotationMatrix: Matrix;
  65289. /** @hidden */
  65290. _referencePoint: Vector3;
  65291. /** @hidden */
  65292. _transformedReferencePoint: Vector3;
  65293. protected _globalCurrentTarget: Vector3;
  65294. protected _globalCurrentUpVector: Vector3;
  65295. /** @hidden */
  65296. _reset: () => void;
  65297. private _defaultUp;
  65298. /**
  65299. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65300. * This is the base of the follow, arc rotate cameras and Free camera
  65301. * @see http://doc.babylonjs.com/features/cameras
  65302. * @param name Defines the name of the camera in the scene
  65303. * @param position Defines the start position of the camera in the scene
  65304. * @param scene Defines the scene the camera belongs to
  65305. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65306. */
  65307. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65308. /**
  65309. * Gets the position in front of the camera at a given distance.
  65310. * @param distance The distance from the camera we want the position to be
  65311. * @returns the position
  65312. */
  65313. getFrontPosition(distance: number): Vector3;
  65314. /** @hidden */
  65315. _getLockedTargetPosition(): Nullable<Vector3>;
  65316. private _storedPosition;
  65317. private _storedRotation;
  65318. private _storedRotationQuaternion;
  65319. /**
  65320. * Store current camera state of the camera (fov, position, rotation, etc..)
  65321. * @returns the camera
  65322. */
  65323. storeState(): Camera;
  65324. /**
  65325. * Restored camera state. You must call storeState() first
  65326. * @returns whether it was successful or not
  65327. * @hidden
  65328. */
  65329. _restoreStateValues(): boolean;
  65330. /** @hidden */
  65331. _initCache(): void;
  65332. /** @hidden */
  65333. _updateCache(ignoreParentClass?: boolean): void;
  65334. /** @hidden */
  65335. _isSynchronizedViewMatrix(): boolean;
  65336. /** @hidden */
  65337. _computeLocalCameraSpeed(): number;
  65338. /** @hidden */
  65339. setTarget(target: Vector3): void;
  65340. /**
  65341. * Return the current target position of the camera. This value is expressed in local space.
  65342. * @returns the target position
  65343. */
  65344. getTarget(): Vector3;
  65345. /** @hidden */
  65346. _decideIfNeedsToMove(): boolean;
  65347. /** @hidden */
  65348. _updatePosition(): void;
  65349. /** @hidden */
  65350. _checkInputs(): void;
  65351. protected _updateCameraRotationMatrix(): void;
  65352. /**
  65353. * 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)
  65354. * @returns the current camera
  65355. */
  65356. private _rotateUpVectorWithCameraRotationMatrix;
  65357. private _cachedRotationZ;
  65358. private _cachedQuaternionRotationZ;
  65359. /** @hidden */
  65360. _getViewMatrix(): Matrix;
  65361. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65362. /**
  65363. * @hidden
  65364. */
  65365. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65366. /**
  65367. * @hidden
  65368. */
  65369. _updateRigCameras(): void;
  65370. private _getRigCamPositionAndTarget;
  65371. /**
  65372. * Gets the current object class name.
  65373. * @return the class name
  65374. */
  65375. getClassName(): string;
  65376. }
  65377. }
  65378. declare module BABYLON {
  65379. /**
  65380. * @ignore
  65381. * This is a list of all the different input types that are available in the application.
  65382. * Fo instance: ArcRotateCameraGamepadInput...
  65383. */
  65384. export var CameraInputTypes: {};
  65385. /**
  65386. * This is the contract to implement in order to create a new input class.
  65387. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65388. */
  65389. export interface ICameraInput<TCamera extends Camera> {
  65390. /**
  65391. * Defines the camera the input is attached to.
  65392. */
  65393. camera: Nullable<TCamera>;
  65394. /**
  65395. * Gets the class name of the current intput.
  65396. * @returns the class name
  65397. */
  65398. getClassName(): string;
  65399. /**
  65400. * Get the friendly name associated with the input class.
  65401. * @returns the input friendly name
  65402. */
  65403. getSimpleName(): string;
  65404. /**
  65405. * Attach the input controls to a specific dom element to get the input from.
  65406. * @param element Defines the element the controls should be listened from
  65407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65408. */
  65409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65410. /**
  65411. * Detach the current controls from the specified dom element.
  65412. * @param element Defines the element to stop listening the inputs from
  65413. */
  65414. detachControl(element: Nullable<HTMLElement>): void;
  65415. /**
  65416. * Update the current camera state depending on the inputs that have been used this frame.
  65417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65418. */
  65419. checkInputs?: () => void;
  65420. }
  65421. /**
  65422. * Represents a map of input types to input instance or input index to input instance.
  65423. */
  65424. export interface CameraInputsMap<TCamera extends Camera> {
  65425. /**
  65426. * Accessor to the input by input type.
  65427. */
  65428. [name: string]: ICameraInput<TCamera>;
  65429. /**
  65430. * Accessor to the input by input index.
  65431. */
  65432. [idx: number]: ICameraInput<TCamera>;
  65433. }
  65434. /**
  65435. * This represents the input manager used within a camera.
  65436. * It helps dealing with all the different kind of input attached to a camera.
  65437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65438. */
  65439. export class CameraInputsManager<TCamera extends Camera> {
  65440. /**
  65441. * Defines the list of inputs attahed to the camera.
  65442. */
  65443. attached: CameraInputsMap<TCamera>;
  65444. /**
  65445. * Defines the dom element the camera is collecting inputs from.
  65446. * This is null if the controls have not been attached.
  65447. */
  65448. attachedElement: Nullable<HTMLElement>;
  65449. /**
  65450. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65451. */
  65452. noPreventDefault: boolean;
  65453. /**
  65454. * Defined the camera the input manager belongs to.
  65455. */
  65456. camera: TCamera;
  65457. /**
  65458. * Update the current camera state depending on the inputs that have been used this frame.
  65459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65460. */
  65461. checkInputs: () => void;
  65462. /**
  65463. * Instantiate a new Camera Input Manager.
  65464. * @param camera Defines the camera the input manager blongs to
  65465. */
  65466. constructor(camera: TCamera);
  65467. /**
  65468. * Add an input method to a camera
  65469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65470. * @param input camera input method
  65471. */
  65472. add(input: ICameraInput<TCamera>): void;
  65473. /**
  65474. * Remove a specific input method from a camera
  65475. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65476. * @param inputToRemove camera input method
  65477. */
  65478. remove(inputToRemove: ICameraInput<TCamera>): void;
  65479. /**
  65480. * Remove a specific input type from a camera
  65481. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65482. * @param inputType the type of the input to remove
  65483. */
  65484. removeByType(inputType: string): void;
  65485. private _addCheckInputs;
  65486. /**
  65487. * Attach the input controls to the currently attached dom element to listen the events from.
  65488. * @param input Defines the input to attach
  65489. */
  65490. attachInput(input: ICameraInput<TCamera>): void;
  65491. /**
  65492. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65493. * @param element Defines the dom element to collect the events from
  65494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65495. */
  65496. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65497. /**
  65498. * Detach the current manager inputs controls from a specific dom element.
  65499. * @param element Defines the dom element to collect the events from
  65500. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65501. */
  65502. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65503. /**
  65504. * Rebuild the dynamic inputCheck function from the current list of
  65505. * defined inputs in the manager.
  65506. */
  65507. rebuildInputCheck(): void;
  65508. /**
  65509. * Remove all attached input methods from a camera
  65510. */
  65511. clear(): void;
  65512. /**
  65513. * Serialize the current input manager attached to a camera.
  65514. * This ensures than once parsed,
  65515. * the input associated to the camera will be identical to the current ones
  65516. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65517. */
  65518. serialize(serializedCamera: any): void;
  65519. /**
  65520. * Parses an input manager serialized JSON to restore the previous list of inputs
  65521. * and states associated to a camera.
  65522. * @param parsedCamera Defines the JSON to parse
  65523. */
  65524. parse(parsedCamera: any): void;
  65525. }
  65526. }
  65527. declare module BABYLON {
  65528. /**
  65529. * Gather the list of keyboard event types as constants.
  65530. */
  65531. export class KeyboardEventTypes {
  65532. /**
  65533. * The keydown event is fired when a key becomes active (pressed).
  65534. */
  65535. static readonly KEYDOWN: number;
  65536. /**
  65537. * The keyup event is fired when a key has been released.
  65538. */
  65539. static readonly KEYUP: number;
  65540. }
  65541. /**
  65542. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65543. */
  65544. export class KeyboardInfo {
  65545. /**
  65546. * Defines the type of event (KeyboardEventTypes)
  65547. */
  65548. type: number;
  65549. /**
  65550. * Defines the related dom event
  65551. */
  65552. event: KeyboardEvent;
  65553. /**
  65554. * Instantiates a new keyboard info.
  65555. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65556. * @param type Defines the type of event (KeyboardEventTypes)
  65557. * @param event Defines the related dom event
  65558. */
  65559. constructor(
  65560. /**
  65561. * Defines the type of event (KeyboardEventTypes)
  65562. */
  65563. type: number,
  65564. /**
  65565. * Defines the related dom event
  65566. */
  65567. event: KeyboardEvent);
  65568. }
  65569. /**
  65570. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65571. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  65572. */
  65573. export class KeyboardInfoPre extends KeyboardInfo {
  65574. /**
  65575. * Defines the type of event (KeyboardEventTypes)
  65576. */
  65577. type: number;
  65578. /**
  65579. * Defines the related dom event
  65580. */
  65581. event: KeyboardEvent;
  65582. /**
  65583. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  65584. */
  65585. skipOnPointerObservable: boolean;
  65586. /**
  65587. * Instantiates a new keyboard pre info.
  65588. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65589. * @param type Defines the type of event (KeyboardEventTypes)
  65590. * @param event Defines the related dom event
  65591. */
  65592. constructor(
  65593. /**
  65594. * Defines the type of event (KeyboardEventTypes)
  65595. */
  65596. type: number,
  65597. /**
  65598. * Defines the related dom event
  65599. */
  65600. event: KeyboardEvent);
  65601. }
  65602. }
  65603. declare module BABYLON {
  65604. /**
  65605. * Manage the keyboard inputs to control the movement of a free camera.
  65606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65607. */
  65608. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  65609. /**
  65610. * Defines the camera the input is attached to.
  65611. */
  65612. camera: FreeCamera;
  65613. /**
  65614. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  65615. */
  65616. keysUp: number[];
  65617. /**
  65618. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  65619. */
  65620. keysDown: number[];
  65621. /**
  65622. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  65623. */
  65624. keysLeft: number[];
  65625. /**
  65626. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  65627. */
  65628. keysRight: number[];
  65629. private _keys;
  65630. private _onCanvasBlurObserver;
  65631. private _onKeyboardObserver;
  65632. private _engine;
  65633. private _scene;
  65634. /**
  65635. * Attach the input controls to a specific dom element to get the input from.
  65636. * @param element Defines the element the controls should be listened from
  65637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65638. */
  65639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65640. /**
  65641. * Detach the current controls from the specified dom element.
  65642. * @param element Defines the element to stop listening the inputs from
  65643. */
  65644. detachControl(element: Nullable<HTMLElement>): void;
  65645. /**
  65646. * Update the current camera state depending on the inputs that have been used this frame.
  65647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65648. */
  65649. checkInputs(): void;
  65650. /**
  65651. * Gets the class name of the current intput.
  65652. * @returns the class name
  65653. */
  65654. getClassName(): string;
  65655. /** @hidden */
  65656. _onLostFocus(): void;
  65657. /**
  65658. * Get the friendly name associated with the input class.
  65659. * @returns the input friendly name
  65660. */
  65661. getSimpleName(): string;
  65662. }
  65663. }
  65664. declare module BABYLON {
  65665. /**
  65666. * Interface describing all the common properties and methods a shadow light needs to implement.
  65667. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65668. * as well as binding the different shadow properties to the effects.
  65669. */
  65670. export interface IShadowLight extends Light {
  65671. /**
  65672. * The light id in the scene (used in scene.findLighById for instance)
  65673. */
  65674. id: string;
  65675. /**
  65676. * The position the shdow will be casted from.
  65677. */
  65678. position: Vector3;
  65679. /**
  65680. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65681. */
  65682. direction: Vector3;
  65683. /**
  65684. * The transformed position. Position of the light in world space taking parenting in account.
  65685. */
  65686. transformedPosition: Vector3;
  65687. /**
  65688. * The transformed direction. Direction of the light in world space taking parenting in account.
  65689. */
  65690. transformedDirection: Vector3;
  65691. /**
  65692. * The friendly name of the light in the scene.
  65693. */
  65694. name: string;
  65695. /**
  65696. * Defines the shadow projection clipping minimum z value.
  65697. */
  65698. shadowMinZ: number;
  65699. /**
  65700. * Defines the shadow projection clipping maximum z value.
  65701. */
  65702. shadowMaxZ: number;
  65703. /**
  65704. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65705. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65706. */
  65707. computeTransformedInformation(): boolean;
  65708. /**
  65709. * Gets the scene the light belongs to.
  65710. * @returns The scene
  65711. */
  65712. getScene(): Scene;
  65713. /**
  65714. * Callback defining a custom Projection Matrix Builder.
  65715. * This can be used to override the default projection matrix computation.
  65716. */
  65717. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65718. /**
  65719. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65720. * @param matrix The materix to updated with the projection information
  65721. * @param viewMatrix The transform matrix of the light
  65722. * @param renderList The list of mesh to render in the map
  65723. * @returns The current light
  65724. */
  65725. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65726. /**
  65727. * Gets the current depth scale used in ESM.
  65728. * @returns The scale
  65729. */
  65730. getDepthScale(): number;
  65731. /**
  65732. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65733. * @returns true if a cube texture needs to be use
  65734. */
  65735. needCube(): boolean;
  65736. /**
  65737. * Detects if the projection matrix requires to be recomputed this frame.
  65738. * @returns true if it requires to be recomputed otherwise, false.
  65739. */
  65740. needProjectionMatrixCompute(): boolean;
  65741. /**
  65742. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65743. */
  65744. forceProjectionMatrixCompute(): void;
  65745. /**
  65746. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65747. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65748. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65749. */
  65750. getShadowDirection(faceIndex?: number): Vector3;
  65751. /**
  65752. * Gets the minZ used for shadow according to both the scene and the light.
  65753. * @param activeCamera The camera we are returning the min for
  65754. * @returns the depth min z
  65755. */
  65756. getDepthMinZ(activeCamera: Camera): number;
  65757. /**
  65758. * Gets the maxZ used for shadow according to both the scene and the light.
  65759. * @param activeCamera The camera we are returning the max for
  65760. * @returns the depth max z
  65761. */
  65762. getDepthMaxZ(activeCamera: Camera): number;
  65763. }
  65764. /**
  65765. * Base implementation IShadowLight
  65766. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65767. */
  65768. export abstract class ShadowLight extends Light implements IShadowLight {
  65769. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65770. protected _position: Vector3;
  65771. protected _setPosition(value: Vector3): void;
  65772. /**
  65773. * Sets the position the shadow will be casted from. Also use as the light position for both
  65774. * point and spot lights.
  65775. */
  65776. /**
  65777. * Sets the position the shadow will be casted from. Also use as the light position for both
  65778. * point and spot lights.
  65779. */
  65780. position: Vector3;
  65781. protected _direction: Vector3;
  65782. protected _setDirection(value: Vector3): void;
  65783. /**
  65784. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65785. * Also use as the light direction on spot and directional lights.
  65786. */
  65787. /**
  65788. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65789. * Also use as the light direction on spot and directional lights.
  65790. */
  65791. direction: Vector3;
  65792. private _shadowMinZ;
  65793. /**
  65794. * Gets the shadow projection clipping minimum z value.
  65795. */
  65796. /**
  65797. * Sets the shadow projection clipping minimum z value.
  65798. */
  65799. shadowMinZ: number;
  65800. private _shadowMaxZ;
  65801. /**
  65802. * Sets the shadow projection clipping maximum z value.
  65803. */
  65804. /**
  65805. * Gets the shadow projection clipping maximum z value.
  65806. */
  65807. shadowMaxZ: number;
  65808. /**
  65809. * Callback defining a custom Projection Matrix Builder.
  65810. * This can be used to override the default projection matrix computation.
  65811. */
  65812. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65813. /**
  65814. * The transformed position. Position of the light in world space taking parenting in account.
  65815. */
  65816. transformedPosition: Vector3;
  65817. /**
  65818. * The transformed direction. Direction of the light in world space taking parenting in account.
  65819. */
  65820. transformedDirection: Vector3;
  65821. private _needProjectionMatrixCompute;
  65822. /**
  65823. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65824. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65825. */
  65826. computeTransformedInformation(): boolean;
  65827. /**
  65828. * Return the depth scale used for the shadow map.
  65829. * @returns the depth scale.
  65830. */
  65831. getDepthScale(): number;
  65832. /**
  65833. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65834. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65835. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65836. */
  65837. getShadowDirection(faceIndex?: number): Vector3;
  65838. /**
  65839. * Returns the ShadowLight absolute position in the World.
  65840. * @returns the position vector in world space
  65841. */
  65842. getAbsolutePosition(): Vector3;
  65843. /**
  65844. * Sets the ShadowLight direction toward the passed target.
  65845. * @param target The point to target in local space
  65846. * @returns the updated ShadowLight direction
  65847. */
  65848. setDirectionToTarget(target: Vector3): Vector3;
  65849. /**
  65850. * Returns the light rotation in euler definition.
  65851. * @returns the x y z rotation in local space.
  65852. */
  65853. getRotation(): Vector3;
  65854. /**
  65855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65856. * @returns true if a cube texture needs to be use
  65857. */
  65858. needCube(): boolean;
  65859. /**
  65860. * Detects if the projection matrix requires to be recomputed this frame.
  65861. * @returns true if it requires to be recomputed otherwise, false.
  65862. */
  65863. needProjectionMatrixCompute(): boolean;
  65864. /**
  65865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65866. */
  65867. forceProjectionMatrixCompute(): void;
  65868. /** @hidden */
  65869. _initCache(): void;
  65870. /** @hidden */
  65871. _isSynchronized(): boolean;
  65872. /**
  65873. * Computes the world matrix of the node
  65874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65875. * @returns the world matrix
  65876. */
  65877. computeWorldMatrix(force?: boolean): Matrix;
  65878. /**
  65879. * Gets the minZ used for shadow according to both the scene and the light.
  65880. * @param activeCamera The camera we are returning the min for
  65881. * @returns the depth min z
  65882. */
  65883. getDepthMinZ(activeCamera: Camera): number;
  65884. /**
  65885. * Gets the maxZ used for shadow according to both the scene and the light.
  65886. * @param activeCamera The camera we are returning the max for
  65887. * @returns the depth max z
  65888. */
  65889. getDepthMaxZ(activeCamera: Camera): number;
  65890. /**
  65891. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65892. * @param matrix The materix to updated with the projection information
  65893. * @param viewMatrix The transform matrix of the light
  65894. * @param renderList The list of mesh to render in the map
  65895. * @returns The current light
  65896. */
  65897. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65898. }
  65899. }
  65900. declare module BABYLON {
  65901. /**
  65902. * "Static Class" containing the most commonly used helper while dealing with material for
  65903. * rendering purpose.
  65904. *
  65905. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65906. *
  65907. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65908. */
  65909. export class MaterialHelper {
  65910. /**
  65911. * Bind the current view position to an effect.
  65912. * @param effect The effect to be bound
  65913. * @param scene The scene the eyes position is used from
  65914. */
  65915. static BindEyePosition(effect: Effect, scene: Scene): void;
  65916. /**
  65917. * Helps preparing the defines values about the UVs in used in the effect.
  65918. * UVs are shared as much as we can accross channels in the shaders.
  65919. * @param texture The texture we are preparing the UVs for
  65920. * @param defines The defines to update
  65921. * @param key The channel key "diffuse", "specular"... used in the shader
  65922. */
  65923. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65924. /**
  65925. * Binds a texture matrix value to its corrsponding uniform
  65926. * @param texture The texture to bind the matrix for
  65927. * @param uniformBuffer The uniform buffer receivin the data
  65928. * @param key The channel key "diffuse", "specular"... used in the shader
  65929. */
  65930. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65931. /**
  65932. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65933. * @param mesh defines the current mesh
  65934. * @param scene defines the current scene
  65935. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65936. * @param pointsCloud defines if point cloud rendering has to be turned on
  65937. * @param fogEnabled defines if fog has to be turned on
  65938. * @param alphaTest defines if alpha testing has to be turned on
  65939. * @param defines defines the current list of defines
  65940. */
  65941. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65942. /**
  65943. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65944. * @param scene defines the current scene
  65945. * @param engine defines the current engine
  65946. * @param defines specifies the list of active defines
  65947. * @param useInstances defines if instances have to be turned on
  65948. * @param useClipPlane defines if clip plane have to be turned on
  65949. */
  65950. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65951. /**
  65952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65953. * @param mesh The mesh containing the geometry data we will draw
  65954. * @param defines The defines to update
  65955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65956. * @param useBones Precise whether bones should be used or not (override mesh info)
  65957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65959. * @returns false if defines are considered not dirty and have not been checked
  65960. */
  65961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65962. /**
  65963. * Prepares the defines related to the light information passed in parameter
  65964. * @param scene The scene we are intending to draw
  65965. * @param mesh The mesh the effect is compiling for
  65966. * @param defines The defines to update
  65967. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65968. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65969. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65970. * @returns true if normals will be required for the rest of the effect
  65971. */
  65972. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65973. /**
  65974. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65975. * that won t be acctive due to defines being turned off.
  65976. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65977. * @param samplersList The samplers list
  65978. * @param defines The defines helping in the list generation
  65979. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65980. */
  65981. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65982. /**
  65983. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65984. * @param defines The defines to update while falling back
  65985. * @param fallbacks The authorized effect fallbacks
  65986. * @param maxSimultaneousLights The maximum number of lights allowed
  65987. * @param rank the current rank of the Effect
  65988. * @returns The newly affected rank
  65989. */
  65990. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65991. /**
  65992. * Prepares the list of attributes required for morph targets according to the effect defines.
  65993. * @param attribs The current list of supported attribs
  65994. * @param mesh The mesh to prepare the morph targets attributes for
  65995. * @param defines The current Defines of the effect
  65996. */
  65997. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65998. /**
  65999. * Prepares the list of attributes required for bones according to the effect defines.
  66000. * @param attribs The current list of supported attribs
  66001. * @param mesh The mesh to prepare the bones attributes for
  66002. * @param defines The current Defines of the effect
  66003. * @param fallbacks The current efffect fallback strategy
  66004. */
  66005. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66006. /**
  66007. * Prepares the list of attributes required for instances according to the effect defines.
  66008. * @param attribs The current list of supported attribs
  66009. * @param defines The current Defines of the effect
  66010. */
  66011. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66012. /**
  66013. * Binds the light shadow information to the effect for the given mesh.
  66014. * @param light The light containing the generator
  66015. * @param scene The scene the lights belongs to
  66016. * @param mesh The mesh we are binding the information to render
  66017. * @param lightIndex The light index in the effect used to render the mesh
  66018. * @param effect The effect we are binding the data to
  66019. */
  66020. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66021. /**
  66022. * Binds the light information to the effect.
  66023. * @param light The light containing the generator
  66024. * @param effect The effect we are binding the data to
  66025. * @param lightIndex The light index in the effect used to render
  66026. */
  66027. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66028. /**
  66029. * Binds the lights information from the scene to the effect for the given mesh.
  66030. * @param scene The scene the lights belongs to
  66031. * @param mesh The mesh we are binding the information to render
  66032. * @param effect The effect we are binding the data to
  66033. * @param defines The generated defines for the effect
  66034. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66035. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66036. */
  66037. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66038. private static _tempFogColor;
  66039. /**
  66040. * Binds the fog information from the scene to the effect for the given mesh.
  66041. * @param scene The scene the lights belongs to
  66042. * @param mesh The mesh we are binding the information to render
  66043. * @param effect The effect we are binding the data to
  66044. * @param linearSpace Defines if the fog effect is applied in linear space
  66045. */
  66046. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66047. /**
  66048. * Binds the bones information from the mesh to the effect.
  66049. * @param mesh The mesh we are binding the information to render
  66050. * @param effect The effect we are binding the data to
  66051. */
  66052. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66053. /**
  66054. * Binds the morph targets information from the mesh to the effect.
  66055. * @param abstractMesh The mesh we are binding the information to render
  66056. * @param effect The effect we are binding the data to
  66057. */
  66058. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66059. /**
  66060. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66061. * @param defines The generated defines used in the effect
  66062. * @param effect The effect we are binding the data to
  66063. * @param scene The scene we are willing to render with logarithmic scale for
  66064. */
  66065. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66066. /**
  66067. * Binds the clip plane information from the scene to the effect.
  66068. * @param scene The scene the clip plane information are extracted from
  66069. * @param effect The effect we are binding the data to
  66070. */
  66071. static BindClipPlane(effect: Effect, scene: Scene): void;
  66072. }
  66073. }
  66074. declare module BABYLON {
  66075. /** @hidden */
  66076. export var kernelBlurVaryingDeclaration: {
  66077. name: string;
  66078. shader: string;
  66079. };
  66080. }
  66081. declare module BABYLON {
  66082. /** @hidden */
  66083. export var kernelBlurFragment: {
  66084. name: string;
  66085. shader: string;
  66086. };
  66087. }
  66088. declare module BABYLON {
  66089. /** @hidden */
  66090. export var kernelBlurFragment2: {
  66091. name: string;
  66092. shader: string;
  66093. };
  66094. }
  66095. declare module BABYLON {
  66096. /** @hidden */
  66097. export var kernelBlurPixelShader: {
  66098. name: string;
  66099. shader: string;
  66100. };
  66101. }
  66102. declare module BABYLON {
  66103. /** @hidden */
  66104. export var kernelBlurVertex: {
  66105. name: string;
  66106. shader: string;
  66107. };
  66108. }
  66109. declare module BABYLON {
  66110. /** @hidden */
  66111. export var kernelBlurVertexShader: {
  66112. name: string;
  66113. shader: string;
  66114. };
  66115. }
  66116. declare module BABYLON {
  66117. /**
  66118. * The Blur Post Process which blurs an image based on a kernel and direction.
  66119. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66120. */
  66121. export class BlurPostProcess extends PostProcess {
  66122. /** The direction in which to blur the image. */
  66123. direction: Vector2;
  66124. private blockCompilation;
  66125. protected _kernel: number;
  66126. protected _idealKernel: number;
  66127. protected _packedFloat: boolean;
  66128. private _staticDefines;
  66129. /**
  66130. * Sets the length in pixels of the blur sample region
  66131. */
  66132. /**
  66133. * Gets the length in pixels of the blur sample region
  66134. */
  66135. kernel: number;
  66136. /**
  66137. * Sets wether or not the blur needs to unpack/repack floats
  66138. */
  66139. /**
  66140. * Gets wether or not the blur is unpacking/repacking floats
  66141. */
  66142. packedFloat: boolean;
  66143. /**
  66144. * Creates a new instance BlurPostProcess
  66145. * @param name The name of the effect.
  66146. * @param direction The direction in which to blur the image.
  66147. * @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.
  66148. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66149. * @param camera The camera to apply the render pass to.
  66150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66151. * @param engine The engine which the post process will be applied. (default: current engine)
  66152. * @param reusable If the post process can be reused on the same frame. (default: false)
  66153. * @param textureType Type of textures used when performing the post process. (default: 0)
  66154. * @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)
  66155. */
  66156. constructor(name: string,
  66157. /** The direction in which to blur the image. */
  66158. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66159. /**
  66160. * Updates the effect with the current post process compile time values and recompiles the shader.
  66161. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66162. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66163. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66164. * @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
  66165. * @param onCompiled Called when the shader has been compiled.
  66166. * @param onError Called if there is an error when compiling a shader.
  66167. */
  66168. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66169. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66170. /**
  66171. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66172. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66173. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66174. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66175. * The gaps between physical kernels are compensated for in the weighting of the samples
  66176. * @param idealKernel Ideal blur kernel.
  66177. * @return Nearest best kernel.
  66178. */
  66179. protected _nearestBestKernel(idealKernel: number): number;
  66180. /**
  66181. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66182. * @param x The point on the Gaussian distribution to sample.
  66183. * @return the value of the Gaussian function at x.
  66184. */
  66185. protected _gaussianWeight(x: number): number;
  66186. /**
  66187. * Generates a string that can be used as a floating point number in GLSL.
  66188. * @param x Value to print.
  66189. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66190. * @return GLSL float string.
  66191. */
  66192. protected _glslFloat(x: number, decimalFigures?: number): string;
  66193. }
  66194. }
  66195. declare module BABYLON {
  66196. /** @hidden */
  66197. export var shadowMapPixelShader: {
  66198. name: string;
  66199. shader: string;
  66200. };
  66201. }
  66202. declare module BABYLON {
  66203. /** @hidden */
  66204. export var bonesDeclaration: {
  66205. name: string;
  66206. shader: string;
  66207. };
  66208. }
  66209. declare module BABYLON {
  66210. /** @hidden */
  66211. export var morphTargetsVertexGlobalDeclaration: {
  66212. name: string;
  66213. shader: string;
  66214. };
  66215. }
  66216. declare module BABYLON {
  66217. /** @hidden */
  66218. export var morphTargetsVertexDeclaration: {
  66219. name: string;
  66220. shader: string;
  66221. };
  66222. }
  66223. declare module BABYLON {
  66224. /** @hidden */
  66225. export var instancesDeclaration: {
  66226. name: string;
  66227. shader: string;
  66228. };
  66229. }
  66230. declare module BABYLON {
  66231. /** @hidden */
  66232. export var helperFunctions: {
  66233. name: string;
  66234. shader: string;
  66235. };
  66236. }
  66237. declare module BABYLON {
  66238. /** @hidden */
  66239. export var morphTargetsVertex: {
  66240. name: string;
  66241. shader: string;
  66242. };
  66243. }
  66244. declare module BABYLON {
  66245. /** @hidden */
  66246. export var instancesVertex: {
  66247. name: string;
  66248. shader: string;
  66249. };
  66250. }
  66251. declare module BABYLON {
  66252. /** @hidden */
  66253. export var bonesVertex: {
  66254. name: string;
  66255. shader: string;
  66256. };
  66257. }
  66258. declare module BABYLON {
  66259. /** @hidden */
  66260. export var shadowMapVertexShader: {
  66261. name: string;
  66262. shader: string;
  66263. };
  66264. }
  66265. declare module BABYLON {
  66266. /** @hidden */
  66267. export var depthBoxBlurPixelShader: {
  66268. name: string;
  66269. shader: string;
  66270. };
  66271. }
  66272. declare module BABYLON {
  66273. /**
  66274. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66275. */
  66276. export interface ICustomShaderOptions {
  66277. /**
  66278. * Gets or sets the custom shader name to use
  66279. */
  66280. shaderName: string;
  66281. /**
  66282. * The list of attribute names used in the shader
  66283. */
  66284. attributes?: string[];
  66285. /**
  66286. * The list of unifrom names used in the shader
  66287. */
  66288. uniforms?: string[];
  66289. /**
  66290. * The list of sampler names used in the shader
  66291. */
  66292. samplers?: string[];
  66293. /**
  66294. * The list of defines used in the shader
  66295. */
  66296. defines?: string[];
  66297. }
  66298. /**
  66299. * Interface to implement to create a shadow generator compatible with BJS.
  66300. */
  66301. export interface IShadowGenerator {
  66302. /**
  66303. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66304. * @returns The render target texture if present otherwise, null
  66305. */
  66306. getShadowMap(): Nullable<RenderTargetTexture>;
  66307. /**
  66308. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66309. * @returns The render target texture if the shadow map is present otherwise, null
  66310. */
  66311. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66312. /**
  66313. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66314. * @param subMesh The submesh we want to render in the shadow map
  66315. * @param useInstances Defines wether will draw in the map using instances
  66316. * @returns true if ready otherwise, false
  66317. */
  66318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66319. /**
  66320. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66321. * @param defines Defines of the material we want to update
  66322. * @param lightIndex Index of the light in the enabled light list of the material
  66323. */
  66324. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66325. /**
  66326. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66327. * defined in the generator but impacting the effect).
  66328. * It implies the unifroms available on the materials are the standard BJS ones.
  66329. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66330. * @param effect The effect we are binfing the information for
  66331. */
  66332. bindShadowLight(lightIndex: string, effect: Effect): void;
  66333. /**
  66334. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66335. * (eq to shadow prjection matrix * light transform matrix)
  66336. * @returns The transform matrix used to create the shadow map
  66337. */
  66338. getTransformMatrix(): Matrix;
  66339. /**
  66340. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66341. * Cube and 2D textures for instance.
  66342. */
  66343. recreateShadowMap(): void;
  66344. /**
  66345. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66346. * @param onCompiled Callback triggered at the and of the effects compilation
  66347. * @param options Sets of optional options forcing the compilation with different modes
  66348. */
  66349. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66350. useInstances: boolean;
  66351. }>): void;
  66352. /**
  66353. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66354. * @param options Sets of optional options forcing the compilation with different modes
  66355. * @returns A promise that resolves when the compilation completes
  66356. */
  66357. forceCompilationAsync(options?: Partial<{
  66358. useInstances: boolean;
  66359. }>): Promise<void>;
  66360. /**
  66361. * Serializes the shadow generator setup to a json object.
  66362. * @returns The serialized JSON object
  66363. */
  66364. serialize(): any;
  66365. /**
  66366. * Disposes the Shadow map and related Textures and effects.
  66367. */
  66368. dispose(): void;
  66369. }
  66370. /**
  66371. * Default implementation IShadowGenerator.
  66372. * This is the main object responsible of generating shadows in the framework.
  66373. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66374. */
  66375. export class ShadowGenerator implements IShadowGenerator {
  66376. /**
  66377. * Shadow generator mode None: no filtering applied.
  66378. */
  66379. static readonly FILTER_NONE: number;
  66380. /**
  66381. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66382. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66383. */
  66384. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66385. /**
  66386. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66387. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66388. */
  66389. static readonly FILTER_POISSONSAMPLING: number;
  66390. /**
  66391. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66392. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66393. */
  66394. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66395. /**
  66396. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66397. * edge artifacts on steep falloff.
  66398. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66399. */
  66400. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66401. /**
  66402. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66403. * edge artifacts on steep falloff.
  66404. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66405. */
  66406. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66407. /**
  66408. * Shadow generator mode PCF: Percentage Closer Filtering
  66409. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66410. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66411. */
  66412. static readonly FILTER_PCF: number;
  66413. /**
  66414. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66415. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66416. * Contact Hardening
  66417. */
  66418. static readonly FILTER_PCSS: number;
  66419. /**
  66420. * Reserved for PCF and PCSS
  66421. * Highest Quality.
  66422. *
  66423. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66424. *
  66425. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66426. */
  66427. static readonly QUALITY_HIGH: number;
  66428. /**
  66429. * Reserved for PCF and PCSS
  66430. * Good tradeoff for quality/perf cross devices
  66431. *
  66432. * Execute PCF on a 3*3 kernel.
  66433. *
  66434. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66435. */
  66436. static readonly QUALITY_MEDIUM: number;
  66437. /**
  66438. * Reserved for PCF and PCSS
  66439. * The lowest quality but the fastest.
  66440. *
  66441. * Execute PCF on a 1*1 kernel.
  66442. *
  66443. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66444. */
  66445. static readonly QUALITY_LOW: number;
  66446. /** Gets or sets the custom shader name to use */
  66447. customShaderOptions: ICustomShaderOptions;
  66448. /**
  66449. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66450. */
  66451. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66452. private _bias;
  66453. /**
  66454. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66455. */
  66456. /**
  66457. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66458. */
  66459. bias: number;
  66460. private _normalBias;
  66461. /**
  66462. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66463. */
  66464. /**
  66465. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66466. */
  66467. normalBias: number;
  66468. private _blurBoxOffset;
  66469. /**
  66470. * Gets the blur box offset: offset applied during the blur pass.
  66471. * Only useful if useKernelBlur = false
  66472. */
  66473. /**
  66474. * Sets the blur box offset: offset applied during the blur pass.
  66475. * Only useful if useKernelBlur = false
  66476. */
  66477. blurBoxOffset: number;
  66478. private _blurScale;
  66479. /**
  66480. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66481. * 2 means half of the size.
  66482. */
  66483. /**
  66484. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66485. * 2 means half of the size.
  66486. */
  66487. blurScale: number;
  66488. private _blurKernel;
  66489. /**
  66490. * Gets the blur kernel: kernel size of the blur pass.
  66491. * Only useful if useKernelBlur = true
  66492. */
  66493. /**
  66494. * Sets the blur kernel: kernel size of the blur pass.
  66495. * Only useful if useKernelBlur = true
  66496. */
  66497. blurKernel: number;
  66498. private _useKernelBlur;
  66499. /**
  66500. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66501. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66502. */
  66503. /**
  66504. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66505. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66506. */
  66507. useKernelBlur: boolean;
  66508. private _depthScale;
  66509. /**
  66510. * Gets the depth scale used in ESM mode.
  66511. */
  66512. /**
  66513. * Sets the depth scale used in ESM mode.
  66514. * This can override the scale stored on the light.
  66515. */
  66516. depthScale: number;
  66517. private _filter;
  66518. /**
  66519. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66520. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66521. */
  66522. /**
  66523. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66524. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66525. */
  66526. filter: number;
  66527. /**
  66528. * Gets if the current filter is set to Poisson Sampling.
  66529. */
  66530. /**
  66531. * Sets the current filter to Poisson Sampling.
  66532. */
  66533. usePoissonSampling: boolean;
  66534. /**
  66535. * Gets if the current filter is set to ESM.
  66536. */
  66537. /**
  66538. * Sets the current filter is to ESM.
  66539. */
  66540. useExponentialShadowMap: boolean;
  66541. /**
  66542. * Gets if the current filter is set to filtered ESM.
  66543. */
  66544. /**
  66545. * Gets if the current filter is set to filtered ESM.
  66546. */
  66547. useBlurExponentialShadowMap: boolean;
  66548. /**
  66549. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66550. * exponential to prevent steep falloff artifacts).
  66551. */
  66552. /**
  66553. * Sets the current filter to "close ESM" (using the inverse of the
  66554. * exponential to prevent steep falloff artifacts).
  66555. */
  66556. useCloseExponentialShadowMap: boolean;
  66557. /**
  66558. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66559. * exponential to prevent steep falloff artifacts).
  66560. */
  66561. /**
  66562. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66563. * exponential to prevent steep falloff artifacts).
  66564. */
  66565. useBlurCloseExponentialShadowMap: boolean;
  66566. /**
  66567. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66568. */
  66569. /**
  66570. * Sets the current filter to "PCF" (percentage closer filtering).
  66571. */
  66572. usePercentageCloserFiltering: boolean;
  66573. private _filteringQuality;
  66574. /**
  66575. * Gets the PCF or PCSS Quality.
  66576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66577. */
  66578. /**
  66579. * Sets the PCF or PCSS Quality.
  66580. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66581. */
  66582. filteringQuality: number;
  66583. /**
  66584. * Gets if the current filter is set to "PCSS" (contact hardening).
  66585. */
  66586. /**
  66587. * Sets the current filter to "PCSS" (contact hardening).
  66588. */
  66589. useContactHardeningShadow: boolean;
  66590. private _contactHardeningLightSizeUVRatio;
  66591. /**
  66592. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66593. * Using a ratio helps keeping shape stability independently of the map size.
  66594. *
  66595. * It does not account for the light projection as it was having too much
  66596. * instability during the light setup or during light position changes.
  66597. *
  66598. * Only valid if useContactHardeningShadow is true.
  66599. */
  66600. /**
  66601. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66602. * Using a ratio helps keeping shape stability independently of the map size.
  66603. *
  66604. * It does not account for the light projection as it was having too much
  66605. * instability during the light setup or during light position changes.
  66606. *
  66607. * Only valid if useContactHardeningShadow is true.
  66608. */
  66609. contactHardeningLightSizeUVRatio: number;
  66610. private _darkness;
  66611. /**
  66612. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66613. * 0 means strongest and 1 would means no shadow.
  66614. * @returns the darkness.
  66615. */
  66616. getDarkness(): number;
  66617. /**
  66618. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66619. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66620. * @returns the shadow generator allowing fluent coding.
  66621. */
  66622. setDarkness(darkness: number): ShadowGenerator;
  66623. private _transparencyShadow;
  66624. /**
  66625. * Sets the ability to have transparent shadow (boolean).
  66626. * @param transparent True if transparent else False
  66627. * @returns the shadow generator allowing fluent coding
  66628. */
  66629. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66630. private _shadowMap;
  66631. private _shadowMap2;
  66632. /**
  66633. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66634. * @returns The render target texture if present otherwise, null
  66635. */
  66636. getShadowMap(): Nullable<RenderTargetTexture>;
  66637. /**
  66638. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66639. * @returns The render target texture if the shadow map is present otherwise, null
  66640. */
  66641. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66642. /**
  66643. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66644. * @param mesh Mesh to add
  66645. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66646. * @returns the Shadow Generator itself
  66647. */
  66648. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66649. /**
  66650. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66651. * @param mesh Mesh to remove
  66652. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66653. * @returns the Shadow Generator itself
  66654. */
  66655. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66656. /**
  66657. * Controls the extent to which the shadows fade out at the edge of the frustum
  66658. * Used only by directionals and spots
  66659. */
  66660. frustumEdgeFalloff: number;
  66661. private _light;
  66662. /**
  66663. * Returns the associated light object.
  66664. * @returns the light generating the shadow
  66665. */
  66666. getLight(): IShadowLight;
  66667. /**
  66668. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66669. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66670. * It might on the other hand introduce peter panning.
  66671. */
  66672. forceBackFacesOnly: boolean;
  66673. private _scene;
  66674. private _lightDirection;
  66675. private _effect;
  66676. private _viewMatrix;
  66677. private _projectionMatrix;
  66678. private _transformMatrix;
  66679. private _cachedPosition;
  66680. private _cachedDirection;
  66681. private _cachedDefines;
  66682. private _currentRenderID;
  66683. private _boxBlurPostprocess;
  66684. private _kernelBlurXPostprocess;
  66685. private _kernelBlurYPostprocess;
  66686. private _blurPostProcesses;
  66687. private _mapSize;
  66688. private _currentFaceIndex;
  66689. private _currentFaceIndexCache;
  66690. private _textureType;
  66691. private _defaultTextureMatrix;
  66692. /** @hidden */
  66693. static _SceneComponentInitialization: (scene: Scene) => void;
  66694. /**
  66695. * Creates a ShadowGenerator object.
  66696. * A ShadowGenerator is the required tool to use the shadows.
  66697. * Each light casting shadows needs to use its own ShadowGenerator.
  66698. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66699. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66700. * @param light The light object generating the shadows.
  66701. * @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.
  66702. */
  66703. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66704. private _initializeGenerator;
  66705. private _initializeShadowMap;
  66706. private _initializeBlurRTTAndPostProcesses;
  66707. private _renderForShadowMap;
  66708. private _renderSubMeshForShadowMap;
  66709. private _applyFilterValues;
  66710. /**
  66711. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66712. * @param onCompiled Callback triggered at the and of the effects compilation
  66713. * @param options Sets of optional options forcing the compilation with different modes
  66714. */
  66715. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66716. useInstances: boolean;
  66717. }>): void;
  66718. /**
  66719. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66720. * @param options Sets of optional options forcing the compilation with different modes
  66721. * @returns A promise that resolves when the compilation completes
  66722. */
  66723. forceCompilationAsync(options?: Partial<{
  66724. useInstances: boolean;
  66725. }>): Promise<void>;
  66726. /**
  66727. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66728. * @param subMesh The submesh we want to render in the shadow map
  66729. * @param useInstances Defines wether will draw in the map using instances
  66730. * @returns true if ready otherwise, false
  66731. */
  66732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66733. /**
  66734. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66735. * @param defines Defines of the material we want to update
  66736. * @param lightIndex Index of the light in the enabled light list of the material
  66737. */
  66738. prepareDefines(defines: any, lightIndex: number): void;
  66739. /**
  66740. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66741. * defined in the generator but impacting the effect).
  66742. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66743. * @param effect The effect we are binfing the information for
  66744. */
  66745. bindShadowLight(lightIndex: string, effect: Effect): void;
  66746. /**
  66747. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66748. * (eq to shadow prjection matrix * light transform matrix)
  66749. * @returns The transform matrix used to create the shadow map
  66750. */
  66751. getTransformMatrix(): Matrix;
  66752. /**
  66753. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66754. * Cube and 2D textures for instance.
  66755. */
  66756. recreateShadowMap(): void;
  66757. private _disposeBlurPostProcesses;
  66758. private _disposeRTTandPostProcesses;
  66759. /**
  66760. * Disposes the ShadowGenerator.
  66761. * Returns nothing.
  66762. */
  66763. dispose(): void;
  66764. /**
  66765. * Serializes the shadow generator setup to a json object.
  66766. * @returns The serialized JSON object
  66767. */
  66768. serialize(): any;
  66769. /**
  66770. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66771. * @param parsedShadowGenerator The JSON object to parse
  66772. * @param scene The scene to create the shadow map for
  66773. * @returns The parsed shadow generator
  66774. */
  66775. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66776. }
  66777. }
  66778. declare module BABYLON {
  66779. /**
  66780. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66781. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66782. * 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.
  66783. */
  66784. export abstract class Light extends Node {
  66785. /**
  66786. * Falloff Default: light is falling off following the material specification:
  66787. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66788. */
  66789. static readonly FALLOFF_DEFAULT: number;
  66790. /**
  66791. * Falloff Physical: light is falling off following the inverse squared distance law.
  66792. */
  66793. static readonly FALLOFF_PHYSICAL: number;
  66794. /**
  66795. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66796. * to enhance interoperability with other engines.
  66797. */
  66798. static readonly FALLOFF_GLTF: number;
  66799. /**
  66800. * Falloff Standard: light is falling off like in the standard material
  66801. * to enhance interoperability with other materials.
  66802. */
  66803. static readonly FALLOFF_STANDARD: number;
  66804. /**
  66805. * If every light affecting the material is in this lightmapMode,
  66806. * material.lightmapTexture adds or multiplies
  66807. * (depends on material.useLightmapAsShadowmap)
  66808. * after every other light calculations.
  66809. */
  66810. static readonly LIGHTMAP_DEFAULT: number;
  66811. /**
  66812. * material.lightmapTexture as only diffuse lighting from this light
  66813. * adds only specular lighting from this light
  66814. * adds dynamic shadows
  66815. */
  66816. static readonly LIGHTMAP_SPECULAR: number;
  66817. /**
  66818. * material.lightmapTexture as only lighting
  66819. * no light calculation from this light
  66820. * only adds dynamic shadows from this light
  66821. */
  66822. static readonly LIGHTMAP_SHADOWSONLY: number;
  66823. /**
  66824. * Each light type uses the default quantity according to its type:
  66825. * point/spot lights use luminous intensity
  66826. * directional lights use illuminance
  66827. */
  66828. static readonly INTENSITYMODE_AUTOMATIC: number;
  66829. /**
  66830. * lumen (lm)
  66831. */
  66832. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66833. /**
  66834. * candela (lm/sr)
  66835. */
  66836. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66837. /**
  66838. * lux (lm/m^2)
  66839. */
  66840. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66841. /**
  66842. * nit (cd/m^2)
  66843. */
  66844. static readonly INTENSITYMODE_LUMINANCE: number;
  66845. /**
  66846. * Light type const id of the point light.
  66847. */
  66848. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66849. /**
  66850. * Light type const id of the directional light.
  66851. */
  66852. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66853. /**
  66854. * Light type const id of the spot light.
  66855. */
  66856. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66857. /**
  66858. * Light type const id of the hemispheric light.
  66859. */
  66860. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66861. /**
  66862. * Diffuse gives the basic color to an object.
  66863. */
  66864. diffuse: Color3;
  66865. /**
  66866. * Specular produces a highlight color on an object.
  66867. * Note: This is note affecting PBR materials.
  66868. */
  66869. specular: Color3;
  66870. /**
  66871. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66872. * falling off base on range or angle.
  66873. * This can be set to any values in Light.FALLOFF_x.
  66874. *
  66875. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66876. * other types of materials.
  66877. */
  66878. falloffType: number;
  66879. /**
  66880. * Strength of the light.
  66881. * Note: By default it is define in the framework own unit.
  66882. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66883. */
  66884. intensity: number;
  66885. private _range;
  66886. protected _inverseSquaredRange: number;
  66887. /**
  66888. * Defines how far from the source the light is impacting in scene units.
  66889. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66890. */
  66891. /**
  66892. * Defines how far from the source the light is impacting in scene units.
  66893. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66894. */
  66895. range: number;
  66896. /**
  66897. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66898. * of light.
  66899. */
  66900. private _photometricScale;
  66901. private _intensityMode;
  66902. /**
  66903. * Gets the photometric scale used to interpret the intensity.
  66904. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66905. */
  66906. /**
  66907. * Sets the photometric scale used to interpret the intensity.
  66908. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66909. */
  66910. intensityMode: number;
  66911. private _radius;
  66912. /**
  66913. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66914. */
  66915. /**
  66916. * sets the light radius used by PBR Materials to simulate soft area lights.
  66917. */
  66918. radius: number;
  66919. private _renderPriority;
  66920. /**
  66921. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66922. * exceeding the number allowed of the materials.
  66923. */
  66924. renderPriority: number;
  66925. private _shadowEnabled;
  66926. /**
  66927. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66928. * the current shadow generator.
  66929. */
  66930. /**
  66931. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66932. * the current shadow generator.
  66933. */
  66934. shadowEnabled: boolean;
  66935. private _includedOnlyMeshes;
  66936. /**
  66937. * Gets the only meshes impacted by this light.
  66938. */
  66939. /**
  66940. * Sets the only meshes impacted by this light.
  66941. */
  66942. includedOnlyMeshes: AbstractMesh[];
  66943. private _excludedMeshes;
  66944. /**
  66945. * Gets the meshes not impacted by this light.
  66946. */
  66947. /**
  66948. * Sets the meshes not impacted by this light.
  66949. */
  66950. excludedMeshes: AbstractMesh[];
  66951. private _excludeWithLayerMask;
  66952. /**
  66953. * Gets the layer id use to find what meshes are not impacted by the light.
  66954. * Inactive if 0
  66955. */
  66956. /**
  66957. * Sets the layer id use to find what meshes are not impacted by the light.
  66958. * Inactive if 0
  66959. */
  66960. excludeWithLayerMask: number;
  66961. private _includeOnlyWithLayerMask;
  66962. /**
  66963. * Gets the layer id use to find what meshes are impacted by the light.
  66964. * Inactive if 0
  66965. */
  66966. /**
  66967. * Sets the layer id use to find what meshes are impacted by the light.
  66968. * Inactive if 0
  66969. */
  66970. includeOnlyWithLayerMask: number;
  66971. private _lightmapMode;
  66972. /**
  66973. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66974. */
  66975. /**
  66976. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66977. */
  66978. lightmapMode: number;
  66979. /**
  66980. * Shadow generator associted to the light.
  66981. * @hidden Internal use only.
  66982. */
  66983. _shadowGenerator: Nullable<IShadowGenerator>;
  66984. /**
  66985. * @hidden Internal use only.
  66986. */
  66987. _excludedMeshesIds: string[];
  66988. /**
  66989. * @hidden Internal use only.
  66990. */
  66991. _includedOnlyMeshesIds: string[];
  66992. /**
  66993. * The current light unifom buffer.
  66994. * @hidden Internal use only.
  66995. */
  66996. _uniformBuffer: UniformBuffer;
  66997. /**
  66998. * Creates a Light object in the scene.
  66999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67000. * @param name The firendly name of the light
  67001. * @param scene The scene the light belongs too
  67002. */
  67003. constructor(name: string, scene: Scene);
  67004. protected abstract _buildUniformLayout(): void;
  67005. /**
  67006. * Sets the passed Effect "effect" with the Light information.
  67007. * @param effect The effect to update
  67008. * @param lightIndex The index of the light in the effect to update
  67009. * @returns The light
  67010. */
  67011. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67012. /**
  67013. * Returns the string "Light".
  67014. * @returns the class name
  67015. */
  67016. getClassName(): string;
  67017. /** @hidden */
  67018. readonly _isLight: boolean;
  67019. /**
  67020. * Converts the light information to a readable string for debug purpose.
  67021. * @param fullDetails Supports for multiple levels of logging within scene loading
  67022. * @returns the human readable light info
  67023. */
  67024. toString(fullDetails?: boolean): string;
  67025. /** @hidden */
  67026. protected _syncParentEnabledState(): void;
  67027. /**
  67028. * Set the enabled state of this node.
  67029. * @param value - the new enabled state
  67030. */
  67031. setEnabled(value: boolean): void;
  67032. /**
  67033. * Returns the Light associated shadow generator if any.
  67034. * @return the associated shadow generator.
  67035. */
  67036. getShadowGenerator(): Nullable<IShadowGenerator>;
  67037. /**
  67038. * Returns a Vector3, the absolute light position in the World.
  67039. * @returns the world space position of the light
  67040. */
  67041. getAbsolutePosition(): Vector3;
  67042. /**
  67043. * Specifies if the light will affect the passed mesh.
  67044. * @param mesh The mesh to test against the light
  67045. * @return true the mesh is affected otherwise, false.
  67046. */
  67047. canAffectMesh(mesh: AbstractMesh): boolean;
  67048. /**
  67049. * Sort function to order lights for rendering.
  67050. * @param a First Light object to compare to second.
  67051. * @param b Second Light object to compare first.
  67052. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67053. */
  67054. static CompareLightsPriority(a: Light, b: Light): number;
  67055. /**
  67056. * Releases resources associated with this node.
  67057. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67058. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67059. */
  67060. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67061. /**
  67062. * Returns the light type ID (integer).
  67063. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67064. */
  67065. getTypeID(): number;
  67066. /**
  67067. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67068. * @returns the scaled intensity in intensity mode unit
  67069. */
  67070. getScaledIntensity(): number;
  67071. /**
  67072. * Returns a new Light object, named "name", from the current one.
  67073. * @param name The name of the cloned light
  67074. * @returns the new created light
  67075. */
  67076. clone(name: string): Nullable<Light>;
  67077. /**
  67078. * Serializes the current light into a Serialization object.
  67079. * @returns the serialized object.
  67080. */
  67081. serialize(): any;
  67082. /**
  67083. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67084. * This new light is named "name" and added to the passed scene.
  67085. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67086. * @param name The friendly name of the light
  67087. * @param scene The scene the new light will belong to
  67088. * @returns the constructor function
  67089. */
  67090. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67091. /**
  67092. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67093. * @param parsedLight The JSON representation of the light
  67094. * @param scene The scene to create the parsed light in
  67095. * @returns the created light after parsing
  67096. */
  67097. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67098. private _hookArrayForExcluded;
  67099. private _hookArrayForIncludedOnly;
  67100. private _resyncMeshes;
  67101. /**
  67102. * Forces the meshes to update their light related information in their rendering used effects
  67103. * @hidden Internal Use Only
  67104. */
  67105. _markMeshesAsLightDirty(): void;
  67106. /**
  67107. * Recomputes the cached photometric scale if needed.
  67108. */
  67109. private _computePhotometricScale;
  67110. /**
  67111. * Returns the Photometric Scale according to the light type and intensity mode.
  67112. */
  67113. private _getPhotometricScale;
  67114. /**
  67115. * Reorder the light in the scene according to their defined priority.
  67116. * @hidden Internal Use Only
  67117. */
  67118. _reorderLightsInScene(): void;
  67119. /**
  67120. * Prepares the list of defines specific to the light type.
  67121. * @param defines the list of defines
  67122. * @param lightIndex defines the index of the light for the effect
  67123. */
  67124. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67125. }
  67126. }
  67127. declare module BABYLON {
  67128. /**
  67129. * Interface used to define Action
  67130. */
  67131. export interface IAction {
  67132. /**
  67133. * Trigger for the action
  67134. */
  67135. trigger: number;
  67136. /** Options of the trigger */
  67137. triggerOptions: any;
  67138. /**
  67139. * Gets the trigger parameters
  67140. * @returns the trigger parameters
  67141. */
  67142. getTriggerParameter(): any;
  67143. /**
  67144. * Internal only - executes current action event
  67145. * @hidden
  67146. */
  67147. _executeCurrent(evt?: ActionEvent): void;
  67148. /**
  67149. * Serialize placeholder for child classes
  67150. * @param parent of child
  67151. * @returns the serialized object
  67152. */
  67153. serialize(parent: any): any;
  67154. }
  67155. /**
  67156. * The action to be carried out following a trigger
  67157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67158. */
  67159. export class Action implements IAction {
  67160. /** the trigger, with or without parameters, for the action */
  67161. triggerOptions: any;
  67162. /**
  67163. * Trigger for the action
  67164. */
  67165. trigger: number;
  67166. /**
  67167. * Internal only - manager for action
  67168. * @hidden
  67169. */
  67170. _actionManager: ActionManager;
  67171. private _nextActiveAction;
  67172. private _child;
  67173. private _condition?;
  67174. private _triggerParameter;
  67175. /**
  67176. * An event triggered prior to action being executed.
  67177. */
  67178. onBeforeExecuteObservable: Observable<Action>;
  67179. /**
  67180. * Creates a new Action
  67181. * @param triggerOptions the trigger, with or without parameters, for the action
  67182. * @param condition an optional determinant of action
  67183. */
  67184. constructor(
  67185. /** the trigger, with or without parameters, for the action */
  67186. triggerOptions: any, condition?: Condition);
  67187. /**
  67188. * Internal only
  67189. * @hidden
  67190. */
  67191. _prepare(): void;
  67192. /**
  67193. * Gets the trigger parameters
  67194. * @returns the trigger parameters
  67195. */
  67196. getTriggerParameter(): any;
  67197. /**
  67198. * Internal only - executes current action event
  67199. * @hidden
  67200. */
  67201. _executeCurrent(evt?: ActionEvent): void;
  67202. /**
  67203. * Execute placeholder for child classes
  67204. * @param evt optional action event
  67205. */
  67206. execute(evt?: ActionEvent): void;
  67207. /**
  67208. * Skips to next active action
  67209. */
  67210. skipToNextActiveAction(): void;
  67211. /**
  67212. * Adds action to chain of actions, may be a DoNothingAction
  67213. * @param action defines the next action to execute
  67214. * @returns The action passed in
  67215. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67216. */
  67217. then(action: Action): Action;
  67218. /**
  67219. * Internal only
  67220. * @hidden
  67221. */
  67222. _getProperty(propertyPath: string): string;
  67223. /**
  67224. * Internal only
  67225. * @hidden
  67226. */
  67227. _getEffectiveTarget(target: any, propertyPath: string): any;
  67228. /**
  67229. * Serialize placeholder for child classes
  67230. * @param parent of child
  67231. * @returns the serialized object
  67232. */
  67233. serialize(parent: any): any;
  67234. /**
  67235. * Internal only called by serialize
  67236. * @hidden
  67237. */
  67238. protected _serialize(serializedAction: any, parent?: any): any;
  67239. /**
  67240. * Internal only
  67241. * @hidden
  67242. */
  67243. static _SerializeValueAsString: (value: any) => string;
  67244. /**
  67245. * Internal only
  67246. * @hidden
  67247. */
  67248. static _GetTargetProperty: (target: Scene | Node) => {
  67249. name: string;
  67250. targetType: string;
  67251. value: string;
  67252. };
  67253. }
  67254. }
  67255. declare module BABYLON {
  67256. /**
  67257. * A Condition applied to an Action
  67258. */
  67259. export class Condition {
  67260. /**
  67261. * Internal only - manager for action
  67262. * @hidden
  67263. */
  67264. _actionManager: ActionManager;
  67265. /**
  67266. * Internal only
  67267. * @hidden
  67268. */
  67269. _evaluationId: number;
  67270. /**
  67271. * Internal only
  67272. * @hidden
  67273. */
  67274. _currentResult: boolean;
  67275. /**
  67276. * Creates a new Condition
  67277. * @param actionManager the manager of the action the condition is applied to
  67278. */
  67279. constructor(actionManager: ActionManager);
  67280. /**
  67281. * Check if the current condition is valid
  67282. * @returns a boolean
  67283. */
  67284. isValid(): boolean;
  67285. /**
  67286. * Internal only
  67287. * @hidden
  67288. */
  67289. _getProperty(propertyPath: string): string;
  67290. /**
  67291. * Internal only
  67292. * @hidden
  67293. */
  67294. _getEffectiveTarget(target: any, propertyPath: string): any;
  67295. /**
  67296. * Serialize placeholder for child classes
  67297. * @returns the serialized object
  67298. */
  67299. serialize(): any;
  67300. /**
  67301. * Internal only
  67302. * @hidden
  67303. */
  67304. protected _serialize(serializedCondition: any): any;
  67305. }
  67306. /**
  67307. * Defines specific conditional operators as extensions of Condition
  67308. */
  67309. export class ValueCondition extends Condition {
  67310. /** path to specify the property of the target the conditional operator uses */
  67311. propertyPath: string;
  67312. /** the value compared by the conditional operator against the current value of the property */
  67313. value: any;
  67314. /** the conditional operator, default ValueCondition.IsEqual */
  67315. operator: number;
  67316. /**
  67317. * Internal only
  67318. * @hidden
  67319. */
  67320. private static _IsEqual;
  67321. /**
  67322. * Internal only
  67323. * @hidden
  67324. */
  67325. private static _IsDifferent;
  67326. /**
  67327. * Internal only
  67328. * @hidden
  67329. */
  67330. private static _IsGreater;
  67331. /**
  67332. * Internal only
  67333. * @hidden
  67334. */
  67335. private static _IsLesser;
  67336. /**
  67337. * returns the number for IsEqual
  67338. */
  67339. static readonly IsEqual: number;
  67340. /**
  67341. * Returns the number for IsDifferent
  67342. */
  67343. static readonly IsDifferent: number;
  67344. /**
  67345. * Returns the number for IsGreater
  67346. */
  67347. static readonly IsGreater: number;
  67348. /**
  67349. * Returns the number for IsLesser
  67350. */
  67351. static readonly IsLesser: number;
  67352. /**
  67353. * Internal only The action manager for the condition
  67354. * @hidden
  67355. */
  67356. _actionManager: ActionManager;
  67357. /**
  67358. * Internal only
  67359. * @hidden
  67360. */
  67361. private _target;
  67362. /**
  67363. * Internal only
  67364. * @hidden
  67365. */
  67366. private _effectiveTarget;
  67367. /**
  67368. * Internal only
  67369. * @hidden
  67370. */
  67371. private _property;
  67372. /**
  67373. * Creates a new ValueCondition
  67374. * @param actionManager manager for the action the condition applies to
  67375. * @param target for the action
  67376. * @param propertyPath path to specify the property of the target the conditional operator uses
  67377. * @param value the value compared by the conditional operator against the current value of the property
  67378. * @param operator the conditional operator, default ValueCondition.IsEqual
  67379. */
  67380. constructor(actionManager: ActionManager, target: any,
  67381. /** path to specify the property of the target the conditional operator uses */
  67382. propertyPath: string,
  67383. /** the value compared by the conditional operator against the current value of the property */
  67384. value: any,
  67385. /** the conditional operator, default ValueCondition.IsEqual */
  67386. operator?: number);
  67387. /**
  67388. * Compares the given value with the property value for the specified conditional operator
  67389. * @returns the result of the comparison
  67390. */
  67391. isValid(): boolean;
  67392. /**
  67393. * Serialize the ValueCondition into a JSON compatible object
  67394. * @returns serialization object
  67395. */
  67396. serialize(): any;
  67397. /**
  67398. * Gets the name of the conditional operator for the ValueCondition
  67399. * @param operator the conditional operator
  67400. * @returns the name
  67401. */
  67402. static GetOperatorName(operator: number): string;
  67403. }
  67404. /**
  67405. * Defines a predicate condition as an extension of Condition
  67406. */
  67407. export class PredicateCondition extends Condition {
  67408. /** defines the predicate function used to validate the condition */
  67409. predicate: () => boolean;
  67410. /**
  67411. * Internal only - manager for action
  67412. * @hidden
  67413. */
  67414. _actionManager: ActionManager;
  67415. /**
  67416. * Creates a new PredicateCondition
  67417. * @param actionManager manager for the action the condition applies to
  67418. * @param predicate defines the predicate function used to validate the condition
  67419. */
  67420. constructor(actionManager: ActionManager,
  67421. /** defines the predicate function used to validate the condition */
  67422. predicate: () => boolean);
  67423. /**
  67424. * @returns the validity of the predicate condition
  67425. */
  67426. isValid(): boolean;
  67427. }
  67428. /**
  67429. * Defines a state condition as an extension of Condition
  67430. */
  67431. export class StateCondition extends Condition {
  67432. /** Value to compare with target state */
  67433. value: string;
  67434. /**
  67435. * Internal only - manager for action
  67436. * @hidden
  67437. */
  67438. _actionManager: ActionManager;
  67439. /**
  67440. * Internal only
  67441. * @hidden
  67442. */
  67443. private _target;
  67444. /**
  67445. * Creates a new StateCondition
  67446. * @param actionManager manager for the action the condition applies to
  67447. * @param target of the condition
  67448. * @param value to compare with target state
  67449. */
  67450. constructor(actionManager: ActionManager, target: any,
  67451. /** Value to compare with target state */
  67452. value: string);
  67453. /**
  67454. * Gets a boolean indicating if the current condition is met
  67455. * @returns the validity of the state
  67456. */
  67457. isValid(): boolean;
  67458. /**
  67459. * Serialize the StateCondition into a JSON compatible object
  67460. * @returns serialization object
  67461. */
  67462. serialize(): any;
  67463. }
  67464. }
  67465. declare module BABYLON {
  67466. /**
  67467. * This defines an action responsible to toggle a boolean once triggered.
  67468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67469. */
  67470. export class SwitchBooleanAction extends Action {
  67471. /**
  67472. * The path to the boolean property in the target object
  67473. */
  67474. propertyPath: string;
  67475. private _target;
  67476. private _effectiveTarget;
  67477. private _property;
  67478. /**
  67479. * Instantiate the action
  67480. * @param triggerOptions defines the trigger options
  67481. * @param target defines the object containing the boolean
  67482. * @param propertyPath defines the path to the boolean property in the target object
  67483. * @param condition defines the trigger related conditions
  67484. */
  67485. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67486. /** @hidden */
  67487. _prepare(): void;
  67488. /**
  67489. * Execute the action toggle the boolean value.
  67490. */
  67491. execute(): void;
  67492. /**
  67493. * Serializes the actions and its related information.
  67494. * @param parent defines the object to serialize in
  67495. * @returns the serialized object
  67496. */
  67497. serialize(parent: any): any;
  67498. }
  67499. /**
  67500. * This defines an action responsible to set a the state field of the target
  67501. * to a desired value once triggered.
  67502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67503. */
  67504. export class SetStateAction extends Action {
  67505. /**
  67506. * The value to store in the state field.
  67507. */
  67508. value: string;
  67509. private _target;
  67510. /**
  67511. * Instantiate the action
  67512. * @param triggerOptions defines the trigger options
  67513. * @param target defines the object containing the state property
  67514. * @param value defines the value to store in the state field
  67515. * @param condition defines the trigger related conditions
  67516. */
  67517. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67518. /**
  67519. * Execute the action and store the value on the target state property.
  67520. */
  67521. execute(): void;
  67522. /**
  67523. * Serializes the actions and its related information.
  67524. * @param parent defines the object to serialize in
  67525. * @returns the serialized object
  67526. */
  67527. serialize(parent: any): any;
  67528. }
  67529. /**
  67530. * This defines an action responsible to set a property of the target
  67531. * to a desired value once triggered.
  67532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67533. */
  67534. export class SetValueAction extends Action {
  67535. /**
  67536. * The path of the property to set in the target.
  67537. */
  67538. propertyPath: string;
  67539. /**
  67540. * The value to set in the property
  67541. */
  67542. value: any;
  67543. private _target;
  67544. private _effectiveTarget;
  67545. private _property;
  67546. /**
  67547. * Instantiate the action
  67548. * @param triggerOptions defines the trigger options
  67549. * @param target defines the object containing the property
  67550. * @param propertyPath defines the path of the property to set in the target
  67551. * @param value defines the value to set in the property
  67552. * @param condition defines the trigger related conditions
  67553. */
  67554. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67555. /** @hidden */
  67556. _prepare(): void;
  67557. /**
  67558. * Execute the action and set the targetted property to the desired value.
  67559. */
  67560. execute(): void;
  67561. /**
  67562. * Serializes the actions and its related information.
  67563. * @param parent defines the object to serialize in
  67564. * @returns the serialized object
  67565. */
  67566. serialize(parent: any): any;
  67567. }
  67568. /**
  67569. * This defines an action responsible to increment the target value
  67570. * to a desired value once triggered.
  67571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67572. */
  67573. export class IncrementValueAction extends Action {
  67574. /**
  67575. * The path of the property to increment in the target.
  67576. */
  67577. propertyPath: string;
  67578. /**
  67579. * The value we should increment the property by.
  67580. */
  67581. value: any;
  67582. private _target;
  67583. private _effectiveTarget;
  67584. private _property;
  67585. /**
  67586. * Instantiate the action
  67587. * @param triggerOptions defines the trigger options
  67588. * @param target defines the object containing the property
  67589. * @param propertyPath defines the path of the property to increment in the target
  67590. * @param value defines the value value we should increment the property by
  67591. * @param condition defines the trigger related conditions
  67592. */
  67593. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67594. /** @hidden */
  67595. _prepare(): void;
  67596. /**
  67597. * Execute the action and increment the target of the value amount.
  67598. */
  67599. execute(): void;
  67600. /**
  67601. * Serializes the actions and its related information.
  67602. * @param parent defines the object to serialize in
  67603. * @returns the serialized object
  67604. */
  67605. serialize(parent: any): any;
  67606. }
  67607. /**
  67608. * This defines an action responsible to start an animation once triggered.
  67609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67610. */
  67611. export class PlayAnimationAction extends Action {
  67612. /**
  67613. * Where the animation should start (animation frame)
  67614. */
  67615. from: number;
  67616. /**
  67617. * Where the animation should stop (animation frame)
  67618. */
  67619. to: number;
  67620. /**
  67621. * Define if the animation should loop or stop after the first play.
  67622. */
  67623. loop?: boolean;
  67624. private _target;
  67625. /**
  67626. * Instantiate the action
  67627. * @param triggerOptions defines the trigger options
  67628. * @param target defines the target animation or animation name
  67629. * @param from defines from where the animation should start (animation frame)
  67630. * @param end defines where the animation should stop (animation frame)
  67631. * @param loop defines if the animation should loop or stop after the first play
  67632. * @param condition defines the trigger related conditions
  67633. */
  67634. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67635. /** @hidden */
  67636. _prepare(): void;
  67637. /**
  67638. * Execute the action and play the animation.
  67639. */
  67640. execute(): void;
  67641. /**
  67642. * Serializes the actions and its related information.
  67643. * @param parent defines the object to serialize in
  67644. * @returns the serialized object
  67645. */
  67646. serialize(parent: any): any;
  67647. }
  67648. /**
  67649. * This defines an action responsible to stop an animation once triggered.
  67650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67651. */
  67652. export class StopAnimationAction extends Action {
  67653. private _target;
  67654. /**
  67655. * Instantiate the action
  67656. * @param triggerOptions defines the trigger options
  67657. * @param target defines the target animation or animation name
  67658. * @param condition defines the trigger related conditions
  67659. */
  67660. constructor(triggerOptions: any, target: any, condition?: Condition);
  67661. /** @hidden */
  67662. _prepare(): void;
  67663. /**
  67664. * Execute the action and stop the animation.
  67665. */
  67666. execute(): void;
  67667. /**
  67668. * Serializes the actions and its related information.
  67669. * @param parent defines the object to serialize in
  67670. * @returns the serialized object
  67671. */
  67672. serialize(parent: any): any;
  67673. }
  67674. /**
  67675. * This defines an action responsible that does nothing once triggered.
  67676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67677. */
  67678. export class DoNothingAction extends Action {
  67679. /**
  67680. * Instantiate the action
  67681. * @param triggerOptions defines the trigger options
  67682. * @param condition defines the trigger related conditions
  67683. */
  67684. constructor(triggerOptions?: any, condition?: Condition);
  67685. /**
  67686. * Execute the action and do nothing.
  67687. */
  67688. execute(): void;
  67689. /**
  67690. * Serializes the actions and its related information.
  67691. * @param parent defines the object to serialize in
  67692. * @returns the serialized object
  67693. */
  67694. serialize(parent: any): any;
  67695. }
  67696. /**
  67697. * This defines an action responsible to trigger several actions once triggered.
  67698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67699. */
  67700. export class CombineAction extends Action {
  67701. /**
  67702. * The list of aggregated animations to run.
  67703. */
  67704. children: Action[];
  67705. /**
  67706. * Instantiate the action
  67707. * @param triggerOptions defines the trigger options
  67708. * @param children defines the list of aggregated animations to run
  67709. * @param condition defines the trigger related conditions
  67710. */
  67711. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67712. /** @hidden */
  67713. _prepare(): void;
  67714. /**
  67715. * Execute the action and executes all the aggregated actions.
  67716. */
  67717. execute(evt: ActionEvent): void;
  67718. /**
  67719. * Serializes the actions and its related information.
  67720. * @param parent defines the object to serialize in
  67721. * @returns the serialized object
  67722. */
  67723. serialize(parent: any): any;
  67724. }
  67725. /**
  67726. * This defines an action responsible to run code (external event) once triggered.
  67727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67728. */
  67729. export class ExecuteCodeAction extends Action {
  67730. /**
  67731. * The callback function to run.
  67732. */
  67733. func: (evt: ActionEvent) => void;
  67734. /**
  67735. * Instantiate the action
  67736. * @param triggerOptions defines the trigger options
  67737. * @param func defines the callback function to run
  67738. * @param condition defines the trigger related conditions
  67739. */
  67740. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67741. /**
  67742. * Execute the action and run the attached code.
  67743. */
  67744. execute(evt: ActionEvent): void;
  67745. }
  67746. /**
  67747. * This defines an action responsible to set the parent property of the target once triggered.
  67748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67749. */
  67750. export class SetParentAction extends Action {
  67751. private _parent;
  67752. private _target;
  67753. /**
  67754. * Instantiate the action
  67755. * @param triggerOptions defines the trigger options
  67756. * @param target defines the target containing the parent property
  67757. * @param parent defines from where the animation should start (animation frame)
  67758. * @param condition defines the trigger related conditions
  67759. */
  67760. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67761. /** @hidden */
  67762. _prepare(): void;
  67763. /**
  67764. * Execute the action and set the parent property.
  67765. */
  67766. execute(): void;
  67767. /**
  67768. * Serializes the actions and its related information.
  67769. * @param parent defines the object to serialize in
  67770. * @returns the serialized object
  67771. */
  67772. serialize(parent: any): any;
  67773. }
  67774. }
  67775. declare module BABYLON {
  67776. /**
  67777. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67778. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67780. */
  67781. export class ActionManager extends AbstractActionManager {
  67782. /**
  67783. * Nothing
  67784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67785. */
  67786. static readonly NothingTrigger: number;
  67787. /**
  67788. * On pick
  67789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67790. */
  67791. static readonly OnPickTrigger: number;
  67792. /**
  67793. * On left pick
  67794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67795. */
  67796. static readonly OnLeftPickTrigger: number;
  67797. /**
  67798. * On right pick
  67799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67800. */
  67801. static readonly OnRightPickTrigger: number;
  67802. /**
  67803. * On center pick
  67804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67805. */
  67806. static readonly OnCenterPickTrigger: number;
  67807. /**
  67808. * On pick down
  67809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67810. */
  67811. static readonly OnPickDownTrigger: number;
  67812. /**
  67813. * On double pick
  67814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67815. */
  67816. static readonly OnDoublePickTrigger: number;
  67817. /**
  67818. * On pick up
  67819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67820. */
  67821. static readonly OnPickUpTrigger: number;
  67822. /**
  67823. * On pick out.
  67824. * This trigger will only be raised if you also declared a OnPickDown
  67825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67826. */
  67827. static readonly OnPickOutTrigger: number;
  67828. /**
  67829. * On long press
  67830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67831. */
  67832. static readonly OnLongPressTrigger: number;
  67833. /**
  67834. * On pointer over
  67835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67836. */
  67837. static readonly OnPointerOverTrigger: number;
  67838. /**
  67839. * On pointer out
  67840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67841. */
  67842. static readonly OnPointerOutTrigger: number;
  67843. /**
  67844. * On every frame
  67845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67846. */
  67847. static readonly OnEveryFrameTrigger: number;
  67848. /**
  67849. * On intersection enter
  67850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67851. */
  67852. static readonly OnIntersectionEnterTrigger: number;
  67853. /**
  67854. * On intersection exit
  67855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67856. */
  67857. static readonly OnIntersectionExitTrigger: number;
  67858. /**
  67859. * On key down
  67860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67861. */
  67862. static readonly OnKeyDownTrigger: number;
  67863. /**
  67864. * On key up
  67865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67866. */
  67867. static readonly OnKeyUpTrigger: number;
  67868. private _scene;
  67869. /**
  67870. * Creates a new action manager
  67871. * @param scene defines the hosting scene
  67872. */
  67873. constructor(scene: Scene);
  67874. /**
  67875. * Releases all associated resources
  67876. */
  67877. dispose(): void;
  67878. /**
  67879. * Gets hosting scene
  67880. * @returns the hosting scene
  67881. */
  67882. getScene(): Scene;
  67883. /**
  67884. * Does this action manager handles actions of any of the given triggers
  67885. * @param triggers defines the triggers to be tested
  67886. * @return a boolean indicating whether one (or more) of the triggers is handled
  67887. */
  67888. hasSpecificTriggers(triggers: number[]): boolean;
  67889. /**
  67890. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67891. * speed.
  67892. * @param triggerA defines the trigger to be tested
  67893. * @param triggerB defines the trigger to be tested
  67894. * @return a boolean indicating whether one (or more) of the triggers is handled
  67895. */
  67896. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67897. /**
  67898. * Does this action manager handles actions of a given trigger
  67899. * @param trigger defines the trigger to be tested
  67900. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67901. * @return whether the trigger is handled
  67902. */
  67903. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67904. /**
  67905. * Does this action manager has pointer triggers
  67906. */
  67907. readonly hasPointerTriggers: boolean;
  67908. /**
  67909. * Does this action manager has pick triggers
  67910. */
  67911. readonly hasPickTriggers: boolean;
  67912. /**
  67913. * Registers an action to this action manager
  67914. * @param action defines the action to be registered
  67915. * @return the action amended (prepared) after registration
  67916. */
  67917. registerAction(action: Action): Nullable<Action>;
  67918. /**
  67919. * Unregisters an action to this action manager
  67920. * @param action defines the action to be unregistered
  67921. * @return a boolean indicating whether the action has been unregistered
  67922. */
  67923. unregisterAction(action: Action): Boolean;
  67924. /**
  67925. * Process a specific trigger
  67926. * @param trigger defines the trigger to process
  67927. * @param evt defines the event details to be processed
  67928. */
  67929. processTrigger(trigger: number, evt?: IActionEvent): void;
  67930. /** @hidden */
  67931. _getEffectiveTarget(target: any, propertyPath: string): any;
  67932. /** @hidden */
  67933. _getProperty(propertyPath: string): string;
  67934. /**
  67935. * Serialize this manager to a JSON object
  67936. * @param name defines the property name to store this manager
  67937. * @returns a JSON representation of this manager
  67938. */
  67939. serialize(name: string): any;
  67940. /**
  67941. * Creates a new ActionManager from a JSON data
  67942. * @param parsedActions defines the JSON data to read from
  67943. * @param object defines the hosting mesh
  67944. * @param scene defines the hosting scene
  67945. */
  67946. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67947. /**
  67948. * Get a trigger name by index
  67949. * @param trigger defines the trigger index
  67950. * @returns a trigger name
  67951. */
  67952. static GetTriggerName(trigger: number): string;
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /**
  67957. * Class representing a ray with position and direction
  67958. */
  67959. export class Ray {
  67960. /** origin point */
  67961. origin: Vector3;
  67962. /** direction */
  67963. direction: Vector3;
  67964. /** length of the ray */
  67965. length: number;
  67966. private static readonly TmpVector3;
  67967. private _tmpRay;
  67968. /**
  67969. * Creates a new ray
  67970. * @param origin origin point
  67971. * @param direction direction
  67972. * @param length length of the ray
  67973. */
  67974. constructor(
  67975. /** origin point */
  67976. origin: Vector3,
  67977. /** direction */
  67978. direction: Vector3,
  67979. /** length of the ray */
  67980. length?: number);
  67981. /**
  67982. * Checks if the ray intersects a box
  67983. * @param minimum bound of the box
  67984. * @param maximum bound of the box
  67985. * @param intersectionTreshold extra extend to be added to the box in all direction
  67986. * @returns if the box was hit
  67987. */
  67988. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67989. /**
  67990. * Checks if the ray intersects a box
  67991. * @param box the bounding box to check
  67992. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67993. * @returns if the box was hit
  67994. */
  67995. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67996. /**
  67997. * If the ray hits a sphere
  67998. * @param sphere the bounding sphere to check
  67999. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68000. * @returns true if it hits the sphere
  68001. */
  68002. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68003. /**
  68004. * If the ray hits a triange
  68005. * @param vertex0 triangle vertex
  68006. * @param vertex1 triangle vertex
  68007. * @param vertex2 triangle vertex
  68008. * @returns intersection information if hit
  68009. */
  68010. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68011. /**
  68012. * Checks if ray intersects a plane
  68013. * @param plane the plane to check
  68014. * @returns the distance away it was hit
  68015. */
  68016. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68017. /**
  68018. * Checks if ray intersects a mesh
  68019. * @param mesh the mesh to check
  68020. * @param fastCheck if only the bounding box should checked
  68021. * @returns picking info of the intersecton
  68022. */
  68023. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68024. /**
  68025. * Checks if ray intersects a mesh
  68026. * @param meshes the meshes to check
  68027. * @param fastCheck if only the bounding box should checked
  68028. * @param results array to store result in
  68029. * @returns Array of picking infos
  68030. */
  68031. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68032. private _comparePickingInfo;
  68033. private static smallnum;
  68034. private static rayl;
  68035. /**
  68036. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68037. * @param sega the first point of the segment to test the intersection against
  68038. * @param segb the second point of the segment to test the intersection against
  68039. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68040. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68041. */
  68042. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68043. /**
  68044. * Update the ray from viewport position
  68045. * @param x position
  68046. * @param y y position
  68047. * @param viewportWidth viewport width
  68048. * @param viewportHeight viewport height
  68049. * @param world world matrix
  68050. * @param view view matrix
  68051. * @param projection projection matrix
  68052. * @returns this ray updated
  68053. */
  68054. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68055. /**
  68056. * Creates a ray with origin and direction of 0,0,0
  68057. * @returns the new ray
  68058. */
  68059. static Zero(): Ray;
  68060. /**
  68061. * Creates a new ray from screen space and viewport
  68062. * @param x position
  68063. * @param y y position
  68064. * @param viewportWidth viewport width
  68065. * @param viewportHeight viewport height
  68066. * @param world world matrix
  68067. * @param view view matrix
  68068. * @param projection projection matrix
  68069. * @returns new ray
  68070. */
  68071. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68072. /**
  68073. * 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
  68074. * transformed to the given world matrix.
  68075. * @param origin The origin point
  68076. * @param end The end point
  68077. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68078. * @returns the new ray
  68079. */
  68080. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68081. /**
  68082. * Transforms a ray by a matrix
  68083. * @param ray ray to transform
  68084. * @param matrix matrix to apply
  68085. * @returns the resulting new ray
  68086. */
  68087. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68088. /**
  68089. * Transforms a ray by a matrix
  68090. * @param ray ray to transform
  68091. * @param matrix matrix to apply
  68092. * @param result ray to store result in
  68093. */
  68094. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68095. /**
  68096. * Unproject a ray from screen space to object space
  68097. * @param sourceX defines the screen space x coordinate to use
  68098. * @param sourceY defines the screen space y coordinate to use
  68099. * @param viewportWidth defines the current width of the viewport
  68100. * @param viewportHeight defines the current height of the viewport
  68101. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68102. * @param view defines the view matrix to use
  68103. * @param projection defines the projection matrix to use
  68104. */
  68105. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68106. }
  68107. interface Scene {
  68108. /** @hidden */
  68109. _tempPickingRay: Nullable<Ray>;
  68110. /** @hidden */
  68111. _cachedRayForTransform: Ray;
  68112. /** @hidden */
  68113. _pickWithRayInverseMatrix: Matrix;
  68114. /** @hidden */
  68115. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68116. /** @hidden */
  68117. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  68118. }
  68119. }
  68120. declare module BABYLON {
  68121. /**
  68122. * Groups all the scene component constants in one place to ease maintenance.
  68123. * @hidden
  68124. */
  68125. export class SceneComponentConstants {
  68126. static readonly NAME_EFFECTLAYER: string;
  68127. static readonly NAME_LAYER: string;
  68128. static readonly NAME_LENSFLARESYSTEM: string;
  68129. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68130. static readonly NAME_PARTICLESYSTEM: string;
  68131. static readonly NAME_GAMEPAD: string;
  68132. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68133. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68134. static readonly NAME_DEPTHRENDERER: string;
  68135. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68136. static readonly NAME_SPRITE: string;
  68137. static readonly NAME_OUTLINERENDERER: string;
  68138. static readonly NAME_PROCEDURALTEXTURE: string;
  68139. static readonly NAME_SHADOWGENERATOR: string;
  68140. static readonly NAME_OCTREE: string;
  68141. static readonly NAME_PHYSICSENGINE: string;
  68142. static readonly NAME_AUDIO: string;
  68143. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68144. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68145. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68146. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68147. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68148. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68149. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68150. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68151. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68152. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68153. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68154. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68155. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68156. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68157. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68158. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68159. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68160. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68161. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68162. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68163. static readonly STEP_AFTERRENDER_AUDIO: number;
  68164. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68165. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68166. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68167. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68168. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68169. static readonly STEP_POINTERMOVE_SPRITE: number;
  68170. static readonly STEP_POINTERDOWN_SPRITE: number;
  68171. static readonly STEP_POINTERUP_SPRITE: number;
  68172. }
  68173. /**
  68174. * This represents a scene component.
  68175. *
  68176. * This is used to decouple the dependency the scene is having on the different workloads like
  68177. * layers, post processes...
  68178. */
  68179. export interface ISceneComponent {
  68180. /**
  68181. * The name of the component. Each component must have a unique name.
  68182. */
  68183. name: string;
  68184. /**
  68185. * The scene the component belongs to.
  68186. */
  68187. scene: Scene;
  68188. /**
  68189. * Register the component to one instance of a scene.
  68190. */
  68191. register(): void;
  68192. /**
  68193. * Rebuilds the elements related to this component in case of
  68194. * context lost for instance.
  68195. */
  68196. rebuild(): void;
  68197. /**
  68198. * Disposes the component and the associated ressources.
  68199. */
  68200. dispose(): void;
  68201. }
  68202. /**
  68203. * This represents a SERIALIZABLE scene component.
  68204. *
  68205. * This extends Scene Component to add Serialization methods on top.
  68206. */
  68207. export interface ISceneSerializableComponent extends ISceneComponent {
  68208. /**
  68209. * Adds all the element from the container to the scene
  68210. * @param container the container holding the elements
  68211. */
  68212. addFromContainer(container: AbstractScene): void;
  68213. /**
  68214. * Removes all the elements in the container from the scene
  68215. * @param container contains the elements to remove
  68216. */
  68217. removeFromContainer(container: AbstractScene): void;
  68218. /**
  68219. * Serializes the component data to the specified json object
  68220. * @param serializationObject The object to serialize to
  68221. */
  68222. serialize(serializationObject: any): void;
  68223. }
  68224. /**
  68225. * Strong typing of a Mesh related stage step action
  68226. */
  68227. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68228. /**
  68229. * Strong typing of a Evaluate Sub Mesh related stage step action
  68230. */
  68231. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68232. /**
  68233. * Strong typing of a Active Mesh related stage step action
  68234. */
  68235. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68236. /**
  68237. * Strong typing of a Camera related stage step action
  68238. */
  68239. export type CameraStageAction = (camera: Camera) => void;
  68240. /**
  68241. * Strong typing of a Render Target related stage step action
  68242. */
  68243. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68244. /**
  68245. * Strong typing of a RenderingGroup related stage step action
  68246. */
  68247. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68248. /**
  68249. * Strong typing of a Mesh Render related stage step action
  68250. */
  68251. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68252. /**
  68253. * Strong typing of a simple stage step action
  68254. */
  68255. export type SimpleStageAction = () => void;
  68256. /**
  68257. * Strong typing of a render target action.
  68258. */
  68259. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68260. /**
  68261. * Strong typing of a pointer move action.
  68262. */
  68263. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68264. /**
  68265. * Strong typing of a pointer up/down action.
  68266. */
  68267. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68268. /**
  68269. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68270. * @hidden
  68271. */
  68272. export class Stage<T extends Function> extends Array<{
  68273. index: number;
  68274. component: ISceneComponent;
  68275. action: T;
  68276. }> {
  68277. /**
  68278. * Hide ctor from the rest of the world.
  68279. * @param items The items to add.
  68280. */
  68281. private constructor();
  68282. /**
  68283. * Creates a new Stage.
  68284. * @returns A new instance of a Stage
  68285. */
  68286. static Create<T extends Function>(): Stage<T>;
  68287. /**
  68288. * Registers a step in an ordered way in the targeted stage.
  68289. * @param index Defines the position to register the step in
  68290. * @param component Defines the component attached to the step
  68291. * @param action Defines the action to launch during the step
  68292. */
  68293. registerStep(index: number, component: ISceneComponent, action: T): void;
  68294. /**
  68295. * Clears all the steps from the stage.
  68296. */
  68297. clear(): void;
  68298. }
  68299. }
  68300. declare module BABYLON {
  68301. interface Scene {
  68302. /** @hidden */
  68303. _pointerOverSprite: Nullable<Sprite>;
  68304. /** @hidden */
  68305. _pickedDownSprite: Nullable<Sprite>;
  68306. /** @hidden */
  68307. _tempSpritePickingRay: Nullable<Ray>;
  68308. /**
  68309. * All of the sprite managers added to this scene
  68310. * @see http://doc.babylonjs.com/babylon101/sprites
  68311. */
  68312. spriteManagers: Array<ISpriteManager>;
  68313. /**
  68314. * An event triggered when sprites rendering is about to start
  68315. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68316. */
  68317. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68318. /**
  68319. * An event triggered when sprites rendering is done
  68320. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68321. */
  68322. onAfterSpritesRenderingObservable: Observable<Scene>;
  68323. /** @hidden */
  68324. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68325. /** Launch a ray to try to pick a sprite in the scene
  68326. * @param x position on screen
  68327. * @param y position on screen
  68328. * @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
  68329. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68330. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68331. * @returns a PickingInfo
  68332. */
  68333. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68334. /** Use the given ray to pick a sprite in the scene
  68335. * @param ray The ray (in world space) to use to pick meshes
  68336. * @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
  68337. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68339. * @returns a PickingInfo
  68340. */
  68341. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68342. /**
  68343. * Force the sprite under the pointer
  68344. * @param sprite defines the sprite to use
  68345. */
  68346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68347. /**
  68348. * Gets the sprite under the pointer
  68349. * @returns a Sprite or null if no sprite is under the pointer
  68350. */
  68351. getPointerOverSprite(): Nullable<Sprite>;
  68352. }
  68353. /**
  68354. * Defines the sprite scene component responsible to manage sprites
  68355. * in a given scene.
  68356. */
  68357. export class SpriteSceneComponent implements ISceneComponent {
  68358. /**
  68359. * The component name helpfull to identify the component in the list of scene components.
  68360. */
  68361. readonly name: string;
  68362. /**
  68363. * The scene the component belongs to.
  68364. */
  68365. scene: Scene;
  68366. /** @hidden */
  68367. private _spritePredicate;
  68368. /**
  68369. * Creates a new instance of the component for the given scene
  68370. * @param scene Defines the scene to register the component in
  68371. */
  68372. constructor(scene: Scene);
  68373. /**
  68374. * Registers the component in a given scene
  68375. */
  68376. register(): void;
  68377. /**
  68378. * Rebuilds the elements related to this component in case of
  68379. * context lost for instance.
  68380. */
  68381. rebuild(): void;
  68382. /**
  68383. * Disposes the component and the associated ressources.
  68384. */
  68385. dispose(): void;
  68386. private _pickSpriteButKeepRay;
  68387. private _pointerMove;
  68388. private _pointerDown;
  68389. private _pointerUp;
  68390. }
  68391. }
  68392. declare module BABYLON {
  68393. /** @hidden */
  68394. export var fogFragmentDeclaration: {
  68395. name: string;
  68396. shader: string;
  68397. };
  68398. }
  68399. declare module BABYLON {
  68400. /** @hidden */
  68401. export var fogFragment: {
  68402. name: string;
  68403. shader: string;
  68404. };
  68405. }
  68406. declare module BABYLON {
  68407. /** @hidden */
  68408. export var spritesPixelShader: {
  68409. name: string;
  68410. shader: string;
  68411. };
  68412. }
  68413. declare module BABYLON {
  68414. /** @hidden */
  68415. export var fogVertexDeclaration: {
  68416. name: string;
  68417. shader: string;
  68418. };
  68419. }
  68420. declare module BABYLON {
  68421. /** @hidden */
  68422. export var spritesVertexShader: {
  68423. name: string;
  68424. shader: string;
  68425. };
  68426. }
  68427. declare module BABYLON {
  68428. /**
  68429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68430. */
  68431. export interface ISpriteManager extends IDisposable {
  68432. /**
  68433. * Restricts the camera to viewing objects with the same layerMask.
  68434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68435. */
  68436. layerMask: number;
  68437. /**
  68438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68439. */
  68440. isPickable: boolean;
  68441. /**
  68442. * Specifies the rendering group id for this mesh (0 by default)
  68443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68444. */
  68445. renderingGroupId: number;
  68446. /**
  68447. * Defines the list of sprites managed by the manager.
  68448. */
  68449. sprites: Array<Sprite>;
  68450. /**
  68451. * Tests the intersection of a sprite with a specific ray.
  68452. * @param ray The ray we are sending to test the collision
  68453. * @param camera The camera space we are sending rays in
  68454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68456. * @returns picking info or null.
  68457. */
  68458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68459. /**
  68460. * Renders the list of sprites on screen.
  68461. */
  68462. render(): void;
  68463. }
  68464. /**
  68465. * Class used to manage multiple sprites on the same spritesheet
  68466. * @see http://doc.babylonjs.com/babylon101/sprites
  68467. */
  68468. export class SpriteManager implements ISpriteManager {
  68469. /** defines the manager's name */
  68470. name: string;
  68471. /** Gets the list of sprites */
  68472. sprites: Sprite[];
  68473. /** Gets or sets the rendering group id (0 by default) */
  68474. renderingGroupId: number;
  68475. /** Gets or sets camera layer mask */
  68476. layerMask: number;
  68477. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68478. fogEnabled: boolean;
  68479. /** Gets or sets a boolean indicating if the sprites are pickable */
  68480. isPickable: boolean;
  68481. /** Defines the default width of a cell in the spritesheet */
  68482. cellWidth: number;
  68483. /** Defines the default height of a cell in the spritesheet */
  68484. cellHeight: number;
  68485. /**
  68486. * An event triggered when the manager is disposed.
  68487. */
  68488. onDisposeObservable: Observable<SpriteManager>;
  68489. private _onDisposeObserver;
  68490. /**
  68491. * Callback called when the manager is disposed
  68492. */
  68493. onDispose: () => void;
  68494. private _capacity;
  68495. private _spriteTexture;
  68496. private _epsilon;
  68497. private _scene;
  68498. private _vertexData;
  68499. private _buffer;
  68500. private _vertexBuffers;
  68501. private _indexBuffer;
  68502. private _effectBase;
  68503. private _effectFog;
  68504. /**
  68505. * Gets or sets the spritesheet texture
  68506. */
  68507. texture: Texture;
  68508. /**
  68509. * Creates a new sprite manager
  68510. * @param name defines the manager's name
  68511. * @param imgUrl defines the sprite sheet url
  68512. * @param capacity defines the maximum allowed number of sprites
  68513. * @param cellSize defines the size of a sprite cell
  68514. * @param scene defines the hosting scene
  68515. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68516. * @param samplingMode defines the smapling mode to use with spritesheet
  68517. */
  68518. constructor(
  68519. /** defines the manager's name */
  68520. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68521. private _appendSpriteVertex;
  68522. /**
  68523. * Intersects the sprites with a ray
  68524. * @param ray defines the ray to intersect with
  68525. * @param camera defines the current active camera
  68526. * @param predicate defines a predicate used to select candidate sprites
  68527. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68528. * @returns null if no hit or a PickingInfo
  68529. */
  68530. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68531. /**
  68532. * Render all child sprites
  68533. */
  68534. render(): void;
  68535. /**
  68536. * Release associated resources
  68537. */
  68538. dispose(): void;
  68539. }
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * Class used to represent a sprite
  68544. * @see http://doc.babylonjs.com/babylon101/sprites
  68545. */
  68546. export class Sprite {
  68547. /** defines the name */
  68548. name: string;
  68549. /** Gets or sets the current world position */
  68550. position: Vector3;
  68551. /** Gets or sets the main color */
  68552. color: Color4;
  68553. /** Gets or sets the width */
  68554. width: number;
  68555. /** Gets or sets the height */
  68556. height: number;
  68557. /** Gets or sets rotation angle */
  68558. angle: number;
  68559. /** Gets or sets the cell index in the sprite sheet */
  68560. cellIndex: number;
  68561. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68562. invertU: number;
  68563. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68564. invertV: number;
  68565. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68566. disposeWhenFinishedAnimating: boolean;
  68567. /** Gets the list of attached animations */
  68568. animations: Animation[];
  68569. /** Gets or sets a boolean indicating if the sprite can be picked */
  68570. isPickable: boolean;
  68571. /**
  68572. * Gets or sets the associated action manager
  68573. */
  68574. actionManager: Nullable<ActionManager>;
  68575. private _animationStarted;
  68576. private _loopAnimation;
  68577. private _fromIndex;
  68578. private _toIndex;
  68579. private _delay;
  68580. private _direction;
  68581. private _manager;
  68582. private _time;
  68583. private _onAnimationEnd;
  68584. /**
  68585. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68586. */
  68587. isVisible: boolean;
  68588. /**
  68589. * Gets or sets the sprite size
  68590. */
  68591. size: number;
  68592. /**
  68593. * Creates a new Sprite
  68594. * @param name defines the name
  68595. * @param manager defines the manager
  68596. */
  68597. constructor(
  68598. /** defines the name */
  68599. name: string, manager: ISpriteManager);
  68600. /**
  68601. * Starts an animation
  68602. * @param from defines the initial key
  68603. * @param to defines the end key
  68604. * @param loop defines if the animation must loop
  68605. * @param delay defines the start delay (in ms)
  68606. * @param onAnimationEnd defines a callback to call when animation ends
  68607. */
  68608. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68609. /** Stops current animation (if any) */
  68610. stopAnimation(): void;
  68611. /** @hidden */
  68612. _animate(deltaTime: number): void;
  68613. /** Release associated resources */
  68614. dispose(): void;
  68615. }
  68616. }
  68617. declare module BABYLON {
  68618. /**
  68619. * Information about the result of picking within a scene
  68620. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68621. */
  68622. export class PickingInfo {
  68623. /** @hidden */
  68624. _pickingUnavailable: boolean;
  68625. /**
  68626. * If the pick collided with an object
  68627. */
  68628. hit: boolean;
  68629. /**
  68630. * Distance away where the pick collided
  68631. */
  68632. distance: number;
  68633. /**
  68634. * The location of pick collision
  68635. */
  68636. pickedPoint: Nullable<Vector3>;
  68637. /**
  68638. * The mesh corresponding the the pick collision
  68639. */
  68640. pickedMesh: Nullable<AbstractMesh>;
  68641. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68642. bu: number;
  68643. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68644. bv: number;
  68645. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68646. faceId: number;
  68647. /** Id of the the submesh that was picked */
  68648. subMeshId: number;
  68649. /** If a sprite was picked, this will be the sprite the pick collided with */
  68650. pickedSprite: Nullable<Sprite>;
  68651. /**
  68652. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68653. */
  68654. originMesh: Nullable<AbstractMesh>;
  68655. /**
  68656. * The ray that was used to perform the picking.
  68657. */
  68658. ray: Nullable<Ray>;
  68659. /**
  68660. * Gets the normal correspodning to the face the pick collided with
  68661. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68662. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68663. * @returns The normal correspodning to the face the pick collided with
  68664. */
  68665. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68666. /**
  68667. * Gets the texture coordinates of where the pick occured
  68668. * @returns the vector containing the coordnates of the texture
  68669. */
  68670. getTextureCoordinates(): Nullable<Vector2>;
  68671. }
  68672. }
  68673. declare module BABYLON {
  68674. /**
  68675. * Gather the list of pointer event types as constants.
  68676. */
  68677. export class PointerEventTypes {
  68678. /**
  68679. * 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.
  68680. */
  68681. static readonly POINTERDOWN: number;
  68682. /**
  68683. * The pointerup event is fired when a pointer is no longer active.
  68684. */
  68685. static readonly POINTERUP: number;
  68686. /**
  68687. * The pointermove event is fired when a pointer changes coordinates.
  68688. */
  68689. static readonly POINTERMOVE: number;
  68690. /**
  68691. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68692. */
  68693. static readonly POINTERWHEEL: number;
  68694. /**
  68695. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68696. */
  68697. static readonly POINTERPICK: number;
  68698. /**
  68699. * The pointertap event is fired when a the object has been touched and released without drag.
  68700. */
  68701. static readonly POINTERTAP: number;
  68702. /**
  68703. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68704. */
  68705. static readonly POINTERDOUBLETAP: number;
  68706. }
  68707. /**
  68708. * Base class of pointer info types.
  68709. */
  68710. export class PointerInfoBase {
  68711. /**
  68712. * Defines the type of event (PointerEventTypes)
  68713. */
  68714. type: number;
  68715. /**
  68716. * Defines the related dom event
  68717. */
  68718. event: PointerEvent | MouseWheelEvent;
  68719. /**
  68720. * Instantiates the base class of pointers info.
  68721. * @param type Defines the type of event (PointerEventTypes)
  68722. * @param event Defines the related dom event
  68723. */
  68724. constructor(
  68725. /**
  68726. * Defines the type of event (PointerEventTypes)
  68727. */
  68728. type: number,
  68729. /**
  68730. * Defines the related dom event
  68731. */
  68732. event: PointerEvent | MouseWheelEvent);
  68733. }
  68734. /**
  68735. * This class is used to store pointer related info for the onPrePointerObservable event.
  68736. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68737. */
  68738. export class PointerInfoPre extends PointerInfoBase {
  68739. /**
  68740. * Ray from a pointer if availible (eg. 6dof controller)
  68741. */
  68742. ray: Nullable<Ray>;
  68743. /**
  68744. * Defines the local position of the pointer on the canvas.
  68745. */
  68746. localPosition: Vector2;
  68747. /**
  68748. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68749. */
  68750. skipOnPointerObservable: boolean;
  68751. /**
  68752. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68753. * @param type Defines the type of event (PointerEventTypes)
  68754. * @param event Defines the related dom event
  68755. * @param localX Defines the local x coordinates of the pointer when the event occured
  68756. * @param localY Defines the local y coordinates of the pointer when the event occured
  68757. */
  68758. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68759. }
  68760. /**
  68761. * This type contains all the data related to a pointer event in Babylon.js.
  68762. * 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.
  68763. */
  68764. export class PointerInfo extends PointerInfoBase {
  68765. /**
  68766. * Defines the picking info associated to the info (if any)\
  68767. */
  68768. pickInfo: Nullable<PickingInfo>;
  68769. /**
  68770. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68771. * @param type Defines the type of event (PointerEventTypes)
  68772. * @param event Defines the related dom event
  68773. * @param pickInfo Defines the picking info associated to the info (if any)\
  68774. */
  68775. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68776. /**
  68777. * Defines the picking info associated to the info (if any)\
  68778. */
  68779. pickInfo: Nullable<PickingInfo>);
  68780. }
  68781. }
  68782. declare module BABYLON {
  68783. /**
  68784. * Manage the mouse inputs to control the movement of a free camera.
  68785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68786. */
  68787. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68788. /**
  68789. * Define if touch is enabled in the mouse input
  68790. */
  68791. touchEnabled: boolean;
  68792. /**
  68793. * Defines the camera the input is attached to.
  68794. */
  68795. camera: FreeCamera;
  68796. /**
  68797. * Defines the buttons associated with the input to handle camera move.
  68798. */
  68799. buttons: number[];
  68800. /**
  68801. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68802. */
  68803. angularSensibility: number;
  68804. private _pointerInput;
  68805. private _onMouseMove;
  68806. private _observer;
  68807. private previousPosition;
  68808. /**
  68809. * Manage the mouse inputs to control the movement of a free camera.
  68810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68811. * @param touchEnabled Defines if touch is enabled or not
  68812. */
  68813. constructor(
  68814. /**
  68815. * Define if touch is enabled in the mouse input
  68816. */
  68817. touchEnabled?: boolean);
  68818. /**
  68819. * Attach the input controls to a specific dom element to get the input from.
  68820. * @param element Defines the element the controls should be listened from
  68821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68822. */
  68823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68824. /**
  68825. * Detach the current controls from the specified dom element.
  68826. * @param element Defines the element to stop listening the inputs from
  68827. */
  68828. detachControl(element: Nullable<HTMLElement>): void;
  68829. /**
  68830. * Gets the class name of the current intput.
  68831. * @returns the class name
  68832. */
  68833. getClassName(): string;
  68834. /**
  68835. * Get the friendly name associated with the input class.
  68836. * @returns the input friendly name
  68837. */
  68838. getSimpleName(): string;
  68839. }
  68840. }
  68841. declare module BABYLON {
  68842. /**
  68843. * Manage the touch inputs to control the movement of a free camera.
  68844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68845. */
  68846. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68847. /**
  68848. * Defines the camera the input is attached to.
  68849. */
  68850. camera: FreeCamera;
  68851. /**
  68852. * Defines the touch sensibility for rotation.
  68853. * The higher the faster.
  68854. */
  68855. touchAngularSensibility: number;
  68856. /**
  68857. * Defines the touch sensibility for move.
  68858. * The higher the faster.
  68859. */
  68860. touchMoveSensibility: number;
  68861. private _offsetX;
  68862. private _offsetY;
  68863. private _pointerPressed;
  68864. private _pointerInput;
  68865. private _observer;
  68866. private _onLostFocus;
  68867. /**
  68868. * Attach the input controls to a specific dom element to get the input from.
  68869. * @param element Defines the element the controls should be listened from
  68870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68871. */
  68872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68873. /**
  68874. * Detach the current controls from the specified dom element.
  68875. * @param element Defines the element to stop listening the inputs from
  68876. */
  68877. detachControl(element: Nullable<HTMLElement>): void;
  68878. /**
  68879. * Update the current camera state depending on the inputs that have been used this frame.
  68880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68881. */
  68882. checkInputs(): void;
  68883. /**
  68884. * Gets the class name of the current intput.
  68885. * @returns the class name
  68886. */
  68887. getClassName(): string;
  68888. /**
  68889. * Get the friendly name associated with the input class.
  68890. * @returns the input friendly name
  68891. */
  68892. getSimpleName(): string;
  68893. }
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * Default Inputs manager for the FreeCamera.
  68898. * It groups all the default supported inputs for ease of use.
  68899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68900. */
  68901. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68902. /**
  68903. * Instantiates a new FreeCameraInputsManager.
  68904. * @param camera Defines the camera the inputs belong to
  68905. */
  68906. constructor(camera: FreeCamera);
  68907. /**
  68908. * Add keyboard input support to the input manager.
  68909. * @returns the current input manager
  68910. */
  68911. addKeyboard(): FreeCameraInputsManager;
  68912. /**
  68913. * Add mouse input support to the input manager.
  68914. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68915. * @returns the current input manager
  68916. */
  68917. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68918. /**
  68919. * Add touch input support to the input manager.
  68920. * @returns the current input manager
  68921. */
  68922. addTouch(): FreeCameraInputsManager;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. /**
  68927. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68928. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68930. */
  68931. export class FreeCamera extends TargetCamera {
  68932. /**
  68933. * Define the collision ellipsoid of the camera.
  68934. * This is helpful to simulate a camera body like the player body around the camera
  68935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68936. */
  68937. ellipsoid: Vector3;
  68938. /**
  68939. * Define an offset for the position of the ellipsoid around the camera.
  68940. * This can be helpful to determine the center of the body near the gravity center of the body
  68941. * instead of its head.
  68942. */
  68943. ellipsoidOffset: Vector3;
  68944. /**
  68945. * Enable or disable collisions of the camera with the rest of the scene objects.
  68946. */
  68947. checkCollisions: boolean;
  68948. /**
  68949. * Enable or disable gravity on the camera.
  68950. */
  68951. applyGravity: boolean;
  68952. /**
  68953. * Define the input manager associated to the camera.
  68954. */
  68955. inputs: FreeCameraInputsManager;
  68956. /**
  68957. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68958. * Higher values reduce sensitivity.
  68959. */
  68960. /**
  68961. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68962. * Higher values reduce sensitivity.
  68963. */
  68964. angularSensibility: number;
  68965. /**
  68966. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68967. */
  68968. keysUp: number[];
  68969. /**
  68970. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68971. */
  68972. keysDown: number[];
  68973. /**
  68974. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68975. */
  68976. keysLeft: number[];
  68977. /**
  68978. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68979. */
  68980. keysRight: number[];
  68981. /**
  68982. * Event raised when the camera collide with a mesh in the scene.
  68983. */
  68984. onCollide: (collidedMesh: AbstractMesh) => void;
  68985. private _collider;
  68986. private _needMoveForGravity;
  68987. private _oldPosition;
  68988. private _diffPosition;
  68989. private _newPosition;
  68990. /** @hidden */
  68991. _localDirection: Vector3;
  68992. /** @hidden */
  68993. _transformedDirection: Vector3;
  68994. /**
  68995. * Instantiates a Free Camera.
  68996. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68997. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68998. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68999. * @param name Define the name of the camera in the scene
  69000. * @param position Define the start position of the camera in the scene
  69001. * @param scene Define the scene the camera belongs to
  69002. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69003. */
  69004. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69005. /**
  69006. * Attached controls to the current camera.
  69007. * @param element Defines the element the controls should be listened from
  69008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69009. */
  69010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69011. /**
  69012. * Detach the current controls from the camera.
  69013. * The camera will stop reacting to inputs.
  69014. * @param element Defines the element to stop listening the inputs from
  69015. */
  69016. detachControl(element: HTMLElement): void;
  69017. private _collisionMask;
  69018. /**
  69019. * Define a collision mask to limit the list of object the camera can collide with
  69020. */
  69021. collisionMask: number;
  69022. /** @hidden */
  69023. _collideWithWorld(displacement: Vector3): void;
  69024. private _onCollisionPositionChange;
  69025. /** @hidden */
  69026. _checkInputs(): void;
  69027. /** @hidden */
  69028. _decideIfNeedsToMove(): boolean;
  69029. /** @hidden */
  69030. _updatePosition(): void;
  69031. /**
  69032. * Destroy the camera and release the current resources hold by it.
  69033. */
  69034. dispose(): void;
  69035. /**
  69036. * Gets the current object class name.
  69037. * @return the class name
  69038. */
  69039. getClassName(): string;
  69040. }
  69041. }
  69042. declare module BABYLON {
  69043. /**
  69044. * Represents a gamepad control stick position
  69045. */
  69046. export class StickValues {
  69047. /**
  69048. * The x component of the control stick
  69049. */
  69050. x: number;
  69051. /**
  69052. * The y component of the control stick
  69053. */
  69054. y: number;
  69055. /**
  69056. * Initializes the gamepad x and y control stick values
  69057. * @param x The x component of the gamepad control stick value
  69058. * @param y The y component of the gamepad control stick value
  69059. */
  69060. constructor(
  69061. /**
  69062. * The x component of the control stick
  69063. */
  69064. x: number,
  69065. /**
  69066. * The y component of the control stick
  69067. */
  69068. y: number);
  69069. }
  69070. /**
  69071. * An interface which manages callbacks for gamepad button changes
  69072. */
  69073. export interface GamepadButtonChanges {
  69074. /**
  69075. * Called when a gamepad has been changed
  69076. */
  69077. changed: boolean;
  69078. /**
  69079. * Called when a gamepad press event has been triggered
  69080. */
  69081. pressChanged: boolean;
  69082. /**
  69083. * Called when a touch event has been triggered
  69084. */
  69085. touchChanged: boolean;
  69086. /**
  69087. * Called when a value has changed
  69088. */
  69089. valueChanged: boolean;
  69090. }
  69091. /**
  69092. * Represents a gamepad
  69093. */
  69094. export class Gamepad {
  69095. /**
  69096. * The id of the gamepad
  69097. */
  69098. id: string;
  69099. /**
  69100. * The index of the gamepad
  69101. */
  69102. index: number;
  69103. /**
  69104. * The browser gamepad
  69105. */
  69106. browserGamepad: any;
  69107. /**
  69108. * Specifies what type of gamepad this represents
  69109. */
  69110. type: number;
  69111. private _leftStick;
  69112. private _rightStick;
  69113. /** @hidden */
  69114. _isConnected: boolean;
  69115. private _leftStickAxisX;
  69116. private _leftStickAxisY;
  69117. private _rightStickAxisX;
  69118. private _rightStickAxisY;
  69119. /**
  69120. * Triggered when the left control stick has been changed
  69121. */
  69122. private _onleftstickchanged;
  69123. /**
  69124. * Triggered when the right control stick has been changed
  69125. */
  69126. private _onrightstickchanged;
  69127. /**
  69128. * Represents a gamepad controller
  69129. */
  69130. static GAMEPAD: number;
  69131. /**
  69132. * Represents a generic controller
  69133. */
  69134. static GENERIC: number;
  69135. /**
  69136. * Represents an XBox controller
  69137. */
  69138. static XBOX: number;
  69139. /**
  69140. * Represents a pose-enabled controller
  69141. */
  69142. static POSE_ENABLED: number;
  69143. /**
  69144. * Specifies whether the left control stick should be Y-inverted
  69145. */
  69146. protected _invertLeftStickY: boolean;
  69147. /**
  69148. * Specifies if the gamepad has been connected
  69149. */
  69150. readonly isConnected: boolean;
  69151. /**
  69152. * Initializes the gamepad
  69153. * @param id The id of the gamepad
  69154. * @param index The index of the gamepad
  69155. * @param browserGamepad The browser gamepad
  69156. * @param leftStickX The x component of the left joystick
  69157. * @param leftStickY The y component of the left joystick
  69158. * @param rightStickX The x component of the right joystick
  69159. * @param rightStickY The y component of the right joystick
  69160. */
  69161. constructor(
  69162. /**
  69163. * The id of the gamepad
  69164. */
  69165. id: string,
  69166. /**
  69167. * The index of the gamepad
  69168. */
  69169. index: number,
  69170. /**
  69171. * The browser gamepad
  69172. */
  69173. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69174. /**
  69175. * Callback triggered when the left joystick has changed
  69176. * @param callback
  69177. */
  69178. onleftstickchanged(callback: (values: StickValues) => void): void;
  69179. /**
  69180. * Callback triggered when the right joystick has changed
  69181. * @param callback
  69182. */
  69183. onrightstickchanged(callback: (values: StickValues) => void): void;
  69184. /**
  69185. * Gets the left joystick
  69186. */
  69187. /**
  69188. * Sets the left joystick values
  69189. */
  69190. leftStick: StickValues;
  69191. /**
  69192. * Gets the right joystick
  69193. */
  69194. /**
  69195. * Sets the right joystick value
  69196. */
  69197. rightStick: StickValues;
  69198. /**
  69199. * Updates the gamepad joystick positions
  69200. */
  69201. update(): void;
  69202. /**
  69203. * Disposes the gamepad
  69204. */
  69205. dispose(): void;
  69206. }
  69207. /**
  69208. * Represents a generic gamepad
  69209. */
  69210. export class GenericPad extends Gamepad {
  69211. private _buttons;
  69212. private _onbuttondown;
  69213. private _onbuttonup;
  69214. /**
  69215. * Observable triggered when a button has been pressed
  69216. */
  69217. onButtonDownObservable: Observable<number>;
  69218. /**
  69219. * Observable triggered when a button has been released
  69220. */
  69221. onButtonUpObservable: Observable<number>;
  69222. /**
  69223. * Callback triggered when a button has been pressed
  69224. * @param callback Called when a button has been pressed
  69225. */
  69226. onbuttondown(callback: (buttonPressed: number) => void): void;
  69227. /**
  69228. * Callback triggered when a button has been released
  69229. * @param callback Called when a button has been released
  69230. */
  69231. onbuttonup(callback: (buttonReleased: number) => void): void;
  69232. /**
  69233. * Initializes the generic gamepad
  69234. * @param id The id of the generic gamepad
  69235. * @param index The index of the generic gamepad
  69236. * @param browserGamepad The browser gamepad
  69237. */
  69238. constructor(id: string, index: number, browserGamepad: any);
  69239. private _setButtonValue;
  69240. /**
  69241. * Updates the generic gamepad
  69242. */
  69243. update(): void;
  69244. /**
  69245. * Disposes the generic gamepad
  69246. */
  69247. dispose(): void;
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /**
  69252. * Defines the types of pose enabled controllers that are supported
  69253. */
  69254. export enum PoseEnabledControllerType {
  69255. /**
  69256. * HTC Vive
  69257. */
  69258. VIVE = 0,
  69259. /**
  69260. * Oculus Rift
  69261. */
  69262. OCULUS = 1,
  69263. /**
  69264. * Windows mixed reality
  69265. */
  69266. WINDOWS = 2,
  69267. /**
  69268. * Samsung gear VR
  69269. */
  69270. GEAR_VR = 3,
  69271. /**
  69272. * Google Daydream
  69273. */
  69274. DAYDREAM = 4,
  69275. /**
  69276. * Generic
  69277. */
  69278. GENERIC = 5
  69279. }
  69280. /**
  69281. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69282. */
  69283. export interface MutableGamepadButton {
  69284. /**
  69285. * Value of the button/trigger
  69286. */
  69287. value: number;
  69288. /**
  69289. * If the button/trigger is currently touched
  69290. */
  69291. touched: boolean;
  69292. /**
  69293. * If the button/trigger is currently pressed
  69294. */
  69295. pressed: boolean;
  69296. }
  69297. /**
  69298. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69299. * @hidden
  69300. */
  69301. export interface ExtendedGamepadButton extends GamepadButton {
  69302. /**
  69303. * If the button/trigger is currently pressed
  69304. */
  69305. readonly pressed: boolean;
  69306. /**
  69307. * If the button/trigger is currently touched
  69308. */
  69309. readonly touched: boolean;
  69310. /**
  69311. * Value of the button/trigger
  69312. */
  69313. readonly value: number;
  69314. }
  69315. /** @hidden */
  69316. export interface _GamePadFactory {
  69317. /**
  69318. * Returns wether or not the current gamepad can be created for this type of controller.
  69319. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69320. * @returns true if it can be created, otherwise false
  69321. */
  69322. canCreate(gamepadInfo: any): boolean;
  69323. /**
  69324. * Creates a new instance of the Gamepad.
  69325. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69326. * @returns the new gamepad instance
  69327. */
  69328. create(gamepadInfo: any): Gamepad;
  69329. }
  69330. /**
  69331. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69332. */
  69333. export class PoseEnabledControllerHelper {
  69334. /** @hidden */
  69335. static _ControllerFactories: _GamePadFactory[];
  69336. /** @hidden */
  69337. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69338. /**
  69339. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69340. * @param vrGamepad the gamepad to initialized
  69341. * @returns a vr controller of the type the gamepad identified as
  69342. */
  69343. static InitiateController(vrGamepad: any): Gamepad;
  69344. }
  69345. /**
  69346. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69347. */
  69348. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69349. private _deviceRoomPosition;
  69350. private _deviceRoomRotationQuaternion;
  69351. /**
  69352. * The device position in babylon space
  69353. */
  69354. devicePosition: Vector3;
  69355. /**
  69356. * The device rotation in babylon space
  69357. */
  69358. deviceRotationQuaternion: Quaternion;
  69359. /**
  69360. * The scale factor of the device in babylon space
  69361. */
  69362. deviceScaleFactor: number;
  69363. /**
  69364. * (Likely devicePosition should be used instead) The device position in its room space
  69365. */
  69366. position: Vector3;
  69367. /**
  69368. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69369. */
  69370. rotationQuaternion: Quaternion;
  69371. /**
  69372. * The type of controller (Eg. Windows mixed reality)
  69373. */
  69374. controllerType: PoseEnabledControllerType;
  69375. protected _calculatedPosition: Vector3;
  69376. private _calculatedRotation;
  69377. /**
  69378. * The raw pose from the device
  69379. */
  69380. rawPose: DevicePose;
  69381. private _trackPosition;
  69382. private _maxRotationDistFromHeadset;
  69383. private _draggedRoomRotation;
  69384. /**
  69385. * @hidden
  69386. */
  69387. _disableTrackPosition(fixedPosition: Vector3): void;
  69388. /**
  69389. * Internal, the mesh attached to the controller
  69390. * @hidden
  69391. */
  69392. _mesh: Nullable<AbstractMesh>;
  69393. private _poseControlledCamera;
  69394. private _leftHandSystemQuaternion;
  69395. /**
  69396. * Internal, matrix used to convert room space to babylon space
  69397. * @hidden
  69398. */
  69399. _deviceToWorld: Matrix;
  69400. /**
  69401. * Node to be used when casting a ray from the controller
  69402. * @hidden
  69403. */
  69404. _pointingPoseNode: Nullable<TransformNode>;
  69405. /**
  69406. * Name of the child mesh that can be used to cast a ray from the controller
  69407. */
  69408. static readonly POINTING_POSE: string;
  69409. /**
  69410. * Creates a new PoseEnabledController from a gamepad
  69411. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69412. */
  69413. constructor(browserGamepad: any);
  69414. private _workingMatrix;
  69415. /**
  69416. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69417. */
  69418. update(): void;
  69419. /**
  69420. * Updates only the pose device and mesh without doing any button event checking
  69421. */
  69422. protected _updatePoseAndMesh(): void;
  69423. /**
  69424. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69425. * @param poseData raw pose fromthe device
  69426. */
  69427. updateFromDevice(poseData: DevicePose): void;
  69428. /**
  69429. * @hidden
  69430. */
  69431. _meshAttachedObservable: Observable<AbstractMesh>;
  69432. /**
  69433. * Attaches a mesh to the controller
  69434. * @param mesh the mesh to be attached
  69435. */
  69436. attachToMesh(mesh: AbstractMesh): void;
  69437. /**
  69438. * Attaches the controllers mesh to a camera
  69439. * @param camera the camera the mesh should be attached to
  69440. */
  69441. attachToPoseControlledCamera(camera: TargetCamera): void;
  69442. /**
  69443. * Disposes of the controller
  69444. */
  69445. dispose(): void;
  69446. /**
  69447. * The mesh that is attached to the controller
  69448. */
  69449. readonly mesh: Nullable<AbstractMesh>;
  69450. /**
  69451. * Gets the ray of the controller in the direction the controller is pointing
  69452. * @param length the length the resulting ray should be
  69453. * @returns a ray in the direction the controller is pointing
  69454. */
  69455. getForwardRay(length?: number): Ray;
  69456. }
  69457. }
  69458. declare module BABYLON {
  69459. /**
  69460. * Defines the WebVRController object that represents controllers tracked in 3D space
  69461. */
  69462. export abstract class WebVRController extends PoseEnabledController {
  69463. /**
  69464. * Internal, the default controller model for the controller
  69465. */
  69466. protected _defaultModel: AbstractMesh;
  69467. /**
  69468. * Fired when the trigger state has changed
  69469. */
  69470. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69471. /**
  69472. * Fired when the main button state has changed
  69473. */
  69474. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69475. /**
  69476. * Fired when the secondary button state has changed
  69477. */
  69478. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69479. /**
  69480. * Fired when the pad state has changed
  69481. */
  69482. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69483. /**
  69484. * Fired when controllers stick values have changed
  69485. */
  69486. onPadValuesChangedObservable: Observable<StickValues>;
  69487. /**
  69488. * Array of button availible on the controller
  69489. */
  69490. protected _buttons: Array<MutableGamepadButton>;
  69491. private _onButtonStateChange;
  69492. /**
  69493. * Fired when a controller button's state has changed
  69494. * @param callback the callback containing the button that was modified
  69495. */
  69496. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69497. /**
  69498. * X and Y axis corrisponding to the controllers joystick
  69499. */
  69500. pad: StickValues;
  69501. /**
  69502. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69503. */
  69504. hand: string;
  69505. /**
  69506. * The default controller model for the controller
  69507. */
  69508. readonly defaultModel: AbstractMesh;
  69509. /**
  69510. * Creates a new WebVRController from a gamepad
  69511. * @param vrGamepad the gamepad that the WebVRController should be created from
  69512. */
  69513. constructor(vrGamepad: any);
  69514. /**
  69515. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69516. */
  69517. update(): void;
  69518. /**
  69519. * Function to be called when a button is modified
  69520. */
  69521. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69522. /**
  69523. * Loads a mesh and attaches it to the controller
  69524. * @param scene the scene the mesh should be added to
  69525. * @param meshLoaded callback for when the mesh has been loaded
  69526. */
  69527. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69528. private _setButtonValue;
  69529. private _changes;
  69530. private _checkChanges;
  69531. /**
  69532. * Disposes of th webVRCOntroller
  69533. */
  69534. dispose(): void;
  69535. }
  69536. }
  69537. declare module BABYLON {
  69538. /**
  69539. * The HemisphericLight simulates the ambient environment light,
  69540. * so the passed direction is the light reflection direction, not the incoming direction.
  69541. */
  69542. export class HemisphericLight extends Light {
  69543. /**
  69544. * The groundColor is the light in the opposite direction to the one specified during creation.
  69545. * 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.
  69546. */
  69547. groundColor: Color3;
  69548. /**
  69549. * The light reflection direction, not the incoming direction.
  69550. */
  69551. direction: Vector3;
  69552. /**
  69553. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69554. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69555. * The HemisphericLight can't cast shadows.
  69556. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69557. * @param name The friendly name of the light
  69558. * @param direction The direction of the light reflection
  69559. * @param scene The scene the light belongs to
  69560. */
  69561. constructor(name: string, direction: Vector3, scene: Scene);
  69562. protected _buildUniformLayout(): void;
  69563. /**
  69564. * Returns the string "HemisphericLight".
  69565. * @return The class name
  69566. */
  69567. getClassName(): string;
  69568. /**
  69569. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69570. * Returns the updated direction.
  69571. * @param target The target the direction should point to
  69572. * @return The computed direction
  69573. */
  69574. setDirectionToTarget(target: Vector3): Vector3;
  69575. /**
  69576. * Returns the shadow generator associated to the light.
  69577. * @returns Always null for hemispheric lights because it does not support shadows.
  69578. */
  69579. getShadowGenerator(): Nullable<IShadowGenerator>;
  69580. /**
  69581. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69582. * @param effect The effect to update
  69583. * @param lightIndex The index of the light in the effect to update
  69584. * @returns The hemispheric light
  69585. */
  69586. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69587. /**
  69588. * Computes the world matrix of the node
  69589. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69590. * @param useWasUpdatedFlag defines a reserved property
  69591. * @returns the world matrix
  69592. */
  69593. computeWorldMatrix(): Matrix;
  69594. /**
  69595. * Returns the integer 3.
  69596. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69597. */
  69598. getTypeID(): number;
  69599. /**
  69600. * Prepares the list of defines specific to the light type.
  69601. * @param defines the list of defines
  69602. * @param lightIndex defines the index of the light for the effect
  69603. */
  69604. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69605. }
  69606. }
  69607. declare module BABYLON {
  69608. /**
  69609. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69610. * IMPORTANT!! The data is right-hand data.
  69611. * @export
  69612. * @interface DevicePose
  69613. */
  69614. export interface DevicePose {
  69615. /**
  69616. * The position of the device, values in array are [x,y,z].
  69617. */
  69618. readonly position: Nullable<Float32Array>;
  69619. /**
  69620. * The linearVelocity of the device, values in array are [x,y,z].
  69621. */
  69622. readonly linearVelocity: Nullable<Float32Array>;
  69623. /**
  69624. * The linearAcceleration of the device, values in array are [x,y,z].
  69625. */
  69626. readonly linearAcceleration: Nullable<Float32Array>;
  69627. /**
  69628. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69629. */
  69630. readonly orientation: Nullable<Float32Array>;
  69631. /**
  69632. * The angularVelocity of the device, values in array are [x,y,z].
  69633. */
  69634. readonly angularVelocity: Nullable<Float32Array>;
  69635. /**
  69636. * The angularAcceleration of the device, values in array are [x,y,z].
  69637. */
  69638. readonly angularAcceleration: Nullable<Float32Array>;
  69639. }
  69640. /**
  69641. * Interface representing a pose controlled object in Babylon.
  69642. * A pose controlled object has both regular pose values as well as pose values
  69643. * from an external device such as a VR head mounted display
  69644. */
  69645. export interface PoseControlled {
  69646. /**
  69647. * The position of the object in babylon space.
  69648. */
  69649. position: Vector3;
  69650. /**
  69651. * The rotation quaternion of the object in babylon space.
  69652. */
  69653. rotationQuaternion: Quaternion;
  69654. /**
  69655. * The position of the device in babylon space.
  69656. */
  69657. devicePosition?: Vector3;
  69658. /**
  69659. * The rotation quaternion of the device in babylon space.
  69660. */
  69661. deviceRotationQuaternion: Quaternion;
  69662. /**
  69663. * The raw pose coming from the device.
  69664. */
  69665. rawPose: Nullable<DevicePose>;
  69666. /**
  69667. * The scale of the device to be used when translating from device space to babylon space.
  69668. */
  69669. deviceScaleFactor: number;
  69670. /**
  69671. * Updates the poseControlled values based on the input device pose.
  69672. * @param poseData the pose data to update the object with
  69673. */
  69674. updateFromDevice(poseData: DevicePose): void;
  69675. }
  69676. /**
  69677. * Set of options to customize the webVRCamera
  69678. */
  69679. export interface WebVROptions {
  69680. /**
  69681. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69682. */
  69683. trackPosition?: boolean;
  69684. /**
  69685. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69686. */
  69687. positionScale?: number;
  69688. /**
  69689. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69690. */
  69691. displayName?: string;
  69692. /**
  69693. * Should the native controller meshes be initialized. (default: true)
  69694. */
  69695. controllerMeshes?: boolean;
  69696. /**
  69697. * Creating a default HemiLight only on controllers. (default: true)
  69698. */
  69699. defaultLightingOnControllers?: boolean;
  69700. /**
  69701. * If you don't want to use the default VR button of the helper. (default: false)
  69702. */
  69703. useCustomVRButton?: boolean;
  69704. /**
  69705. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69706. */
  69707. customVRButton?: HTMLButtonElement;
  69708. /**
  69709. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69710. */
  69711. rayLength?: number;
  69712. /**
  69713. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69714. */
  69715. defaultHeight?: number;
  69716. }
  69717. /**
  69718. * This represents a WebVR camera.
  69719. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69720. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69721. */
  69722. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69723. private webVROptions;
  69724. /**
  69725. * @hidden
  69726. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69727. */
  69728. _vrDevice: any;
  69729. /**
  69730. * The rawPose of the vrDevice.
  69731. */
  69732. rawPose: Nullable<DevicePose>;
  69733. private _onVREnabled;
  69734. private _specsVersion;
  69735. private _attached;
  69736. private _frameData;
  69737. protected _descendants: Array<Node>;
  69738. private _deviceRoomPosition;
  69739. /** @hidden */
  69740. _deviceRoomRotationQuaternion: Quaternion;
  69741. private _standingMatrix;
  69742. /**
  69743. * Represents device position in babylon space.
  69744. */
  69745. devicePosition: Vector3;
  69746. /**
  69747. * Represents device rotation in babylon space.
  69748. */
  69749. deviceRotationQuaternion: Quaternion;
  69750. /**
  69751. * The scale of the device to be used when translating from device space to babylon space.
  69752. */
  69753. deviceScaleFactor: number;
  69754. private _deviceToWorld;
  69755. private _worldToDevice;
  69756. /**
  69757. * References to the webVR controllers for the vrDevice.
  69758. */
  69759. controllers: Array<WebVRController>;
  69760. /**
  69761. * Emits an event when a controller is attached.
  69762. */
  69763. onControllersAttachedObservable: Observable<WebVRController[]>;
  69764. /**
  69765. * Emits an event when a controller's mesh has been loaded;
  69766. */
  69767. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69768. /**
  69769. * Emits an event when the HMD's pose has been updated.
  69770. */
  69771. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69772. private _poseSet;
  69773. /**
  69774. * If the rig cameras be used as parent instead of this camera.
  69775. */
  69776. rigParenting: boolean;
  69777. private _lightOnControllers;
  69778. private _defaultHeight?;
  69779. /**
  69780. * Instantiates a WebVRFreeCamera.
  69781. * @param name The name of the WebVRFreeCamera
  69782. * @param position The starting anchor position for the camera
  69783. * @param scene The scene the camera belongs to
  69784. * @param webVROptions a set of customizable options for the webVRCamera
  69785. */
  69786. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69787. /**
  69788. * Gets the device distance from the ground in meters.
  69789. * @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.
  69790. */
  69791. deviceDistanceToRoomGround(): number;
  69792. /**
  69793. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69794. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69795. */
  69796. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69797. /**
  69798. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69799. * @returns A promise with a boolean set to if the standing matrix is supported.
  69800. */
  69801. useStandingMatrixAsync(): Promise<boolean>;
  69802. /**
  69803. * Disposes the camera
  69804. */
  69805. dispose(): void;
  69806. /**
  69807. * Gets a vrController by name.
  69808. * @param name The name of the controller to retreive
  69809. * @returns the controller matching the name specified or null if not found
  69810. */
  69811. getControllerByName(name: string): Nullable<WebVRController>;
  69812. private _leftController;
  69813. /**
  69814. * The controller corrisponding to the users left hand.
  69815. */
  69816. readonly leftController: Nullable<WebVRController>;
  69817. private _rightController;
  69818. /**
  69819. * The controller corrisponding to the users right hand.
  69820. */
  69821. readonly rightController: Nullable<WebVRController>;
  69822. /**
  69823. * Casts a ray forward from the vrCamera's gaze.
  69824. * @param length Length of the ray (default: 100)
  69825. * @returns the ray corrisponding to the gaze
  69826. */
  69827. getForwardRay(length?: number): Ray;
  69828. /**
  69829. * @hidden
  69830. * Updates the camera based on device's frame data
  69831. */
  69832. _checkInputs(): void;
  69833. /**
  69834. * Updates the poseControlled values based on the input device pose.
  69835. * @param poseData Pose coming from the device
  69836. */
  69837. updateFromDevice(poseData: DevicePose): void;
  69838. private _htmlElementAttached;
  69839. private _detachIfAttached;
  69840. /**
  69841. * WebVR's attach control will start broadcasting frames to the device.
  69842. * Note that in certain browsers (chrome for example) this function must be called
  69843. * within a user-interaction callback. Example:
  69844. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69845. *
  69846. * @param element html element to attach the vrDevice to
  69847. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69848. */
  69849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69850. /**
  69851. * Detaches the camera from the html element and disables VR
  69852. *
  69853. * @param element html element to detach from
  69854. */
  69855. detachControl(element: HTMLElement): void;
  69856. /**
  69857. * @returns the name of this class
  69858. */
  69859. getClassName(): string;
  69860. /**
  69861. * Calls resetPose on the vrDisplay
  69862. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69863. */
  69864. resetToCurrentRotation(): void;
  69865. /**
  69866. * @hidden
  69867. * Updates the rig cameras (left and right eye)
  69868. */
  69869. _updateRigCameras(): void;
  69870. private _workingVector;
  69871. private _oneVector;
  69872. private _workingMatrix;
  69873. private updateCacheCalled;
  69874. private _correctPositionIfNotTrackPosition;
  69875. /**
  69876. * @hidden
  69877. * Updates the cached values of the camera
  69878. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69879. */
  69880. _updateCache(ignoreParentClass?: boolean): void;
  69881. /**
  69882. * @hidden
  69883. * Get current device position in babylon world
  69884. */
  69885. _computeDevicePosition(): void;
  69886. /**
  69887. * Updates the current device position and rotation in the babylon world
  69888. */
  69889. update(): void;
  69890. /**
  69891. * @hidden
  69892. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69893. * @returns an identity matrix
  69894. */
  69895. _getViewMatrix(): Matrix;
  69896. private _tmpMatrix;
  69897. /**
  69898. * This function is called by the two RIG cameras.
  69899. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69900. * @hidden
  69901. */
  69902. _getWebVRViewMatrix(): Matrix;
  69903. /** @hidden */
  69904. _getWebVRProjectionMatrix(): Matrix;
  69905. private _onGamepadConnectedObserver;
  69906. private _onGamepadDisconnectedObserver;
  69907. private _updateCacheWhenTrackingDisabledObserver;
  69908. /**
  69909. * Initializes the controllers and their meshes
  69910. */
  69911. initControllers(): void;
  69912. }
  69913. }
  69914. declare module BABYLON {
  69915. /**
  69916. * Size options for a post process
  69917. */
  69918. export type PostProcessOptions = {
  69919. width: number;
  69920. height: number;
  69921. };
  69922. /**
  69923. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69924. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69925. */
  69926. export class PostProcess {
  69927. /** Name of the PostProcess. */
  69928. name: string;
  69929. /**
  69930. * Gets or sets the unique id of the post process
  69931. */
  69932. uniqueId: number;
  69933. /**
  69934. * Width of the texture to apply the post process on
  69935. */
  69936. width: number;
  69937. /**
  69938. * Height of the texture to apply the post process on
  69939. */
  69940. height: number;
  69941. /**
  69942. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69943. * @hidden
  69944. */
  69945. _outputTexture: Nullable<InternalTexture>;
  69946. /**
  69947. * Sampling mode used by the shader
  69948. * See https://doc.babylonjs.com/classes/3.1/texture
  69949. */
  69950. renderTargetSamplingMode: number;
  69951. /**
  69952. * Clear color to use when screen clearing
  69953. */
  69954. clearColor: Color4;
  69955. /**
  69956. * If the buffer needs to be cleared before applying the post process. (default: true)
  69957. * Should be set to false if shader will overwrite all previous pixels.
  69958. */
  69959. autoClear: boolean;
  69960. /**
  69961. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69962. */
  69963. alphaMode: number;
  69964. /**
  69965. * Sets the setAlphaBlendConstants of the babylon engine
  69966. */
  69967. alphaConstants: Color4;
  69968. /**
  69969. * Animations to be used for the post processing
  69970. */
  69971. animations: Animation[];
  69972. /**
  69973. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69974. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69975. */
  69976. enablePixelPerfectMode: boolean;
  69977. /**
  69978. * Force the postprocess to be applied without taking in account viewport
  69979. */
  69980. forceFullscreenViewport: boolean;
  69981. /**
  69982. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69983. *
  69984. * | Value | Type | Description |
  69985. * | ----- | ----------------------------------- | ----------- |
  69986. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69987. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69988. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69989. *
  69990. */
  69991. scaleMode: number;
  69992. /**
  69993. * Force textures to be a power of two (default: false)
  69994. */
  69995. alwaysForcePOT: boolean;
  69996. private _samples;
  69997. /**
  69998. * Number of sample textures (default: 1)
  69999. */
  70000. samples: number;
  70001. /**
  70002. * Modify the scale of the post process to be the same as the viewport (default: false)
  70003. */
  70004. adaptScaleToCurrentViewport: boolean;
  70005. private _camera;
  70006. private _scene;
  70007. private _engine;
  70008. private _options;
  70009. private _reusable;
  70010. private _textureType;
  70011. /**
  70012. * Smart array of input and output textures for the post process.
  70013. * @hidden
  70014. */
  70015. _textures: SmartArray<InternalTexture>;
  70016. /**
  70017. * The index in _textures that corresponds to the output texture.
  70018. * @hidden
  70019. */
  70020. _currentRenderTextureInd: number;
  70021. private _effect;
  70022. private _samplers;
  70023. private _fragmentUrl;
  70024. private _vertexUrl;
  70025. private _parameters;
  70026. private _scaleRatio;
  70027. protected _indexParameters: any;
  70028. private _shareOutputWithPostProcess;
  70029. private _texelSize;
  70030. private _forcedOutputTexture;
  70031. /**
  70032. * Returns the fragment url or shader name used in the post process.
  70033. * @returns the fragment url or name in the shader store.
  70034. */
  70035. getEffectName(): string;
  70036. /**
  70037. * An event triggered when the postprocess is activated.
  70038. */
  70039. onActivateObservable: Observable<Camera>;
  70040. private _onActivateObserver;
  70041. /**
  70042. * A function that is added to the onActivateObservable
  70043. */
  70044. onActivate: Nullable<(camera: Camera) => void>;
  70045. /**
  70046. * An event triggered when the postprocess changes its size.
  70047. */
  70048. onSizeChangedObservable: Observable<PostProcess>;
  70049. private _onSizeChangedObserver;
  70050. /**
  70051. * A function that is added to the onSizeChangedObservable
  70052. */
  70053. onSizeChanged: (postProcess: PostProcess) => void;
  70054. /**
  70055. * An event triggered when the postprocess applies its effect.
  70056. */
  70057. onApplyObservable: Observable<Effect>;
  70058. private _onApplyObserver;
  70059. /**
  70060. * A function that is added to the onApplyObservable
  70061. */
  70062. onApply: (effect: Effect) => void;
  70063. /**
  70064. * An event triggered before rendering the postprocess
  70065. */
  70066. onBeforeRenderObservable: Observable<Effect>;
  70067. private _onBeforeRenderObserver;
  70068. /**
  70069. * A function that is added to the onBeforeRenderObservable
  70070. */
  70071. onBeforeRender: (effect: Effect) => void;
  70072. /**
  70073. * An event triggered after rendering the postprocess
  70074. */
  70075. onAfterRenderObservable: Observable<Effect>;
  70076. private _onAfterRenderObserver;
  70077. /**
  70078. * A function that is added to the onAfterRenderObservable
  70079. */
  70080. onAfterRender: (efect: Effect) => void;
  70081. /**
  70082. * 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
  70083. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70084. */
  70085. inputTexture: InternalTexture;
  70086. /**
  70087. * Gets the camera which post process is applied to.
  70088. * @returns The camera the post process is applied to.
  70089. */
  70090. getCamera(): Camera;
  70091. /**
  70092. * Gets the texel size of the postprocess.
  70093. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70094. */
  70095. readonly texelSize: Vector2;
  70096. /**
  70097. * Creates a new instance PostProcess
  70098. * @param name The name of the PostProcess.
  70099. * @param fragmentUrl The url of the fragment shader to be used.
  70100. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70101. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70102. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70103. * @param camera The camera to apply the render pass to.
  70104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70105. * @param engine The engine which the post process will be applied. (default: current engine)
  70106. * @param reusable If the post process can be reused on the same frame. (default: false)
  70107. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70108. * @param textureType Type of textures used when performing the post process. (default: 0)
  70109. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70110. * @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
  70111. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70112. */
  70113. constructor(
  70114. /** Name of the PostProcess. */
  70115. 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);
  70116. /**
  70117. * Gets a string idenfifying the name of the class
  70118. * @returns "PostProcess" string
  70119. */
  70120. getClassName(): string;
  70121. /**
  70122. * Gets the engine which this post process belongs to.
  70123. * @returns The engine the post process was enabled with.
  70124. */
  70125. getEngine(): Engine;
  70126. /**
  70127. * The effect that is created when initializing the post process.
  70128. * @returns The created effect corrisponding the the postprocess.
  70129. */
  70130. getEffect(): Effect;
  70131. /**
  70132. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70133. * @param postProcess The post process to share the output with.
  70134. * @returns This post process.
  70135. */
  70136. shareOutputWith(postProcess: PostProcess): PostProcess;
  70137. /**
  70138. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70139. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70140. */
  70141. useOwnOutput(): void;
  70142. /**
  70143. * Updates the effect with the current post process compile time values and recompiles the shader.
  70144. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70145. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70146. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70147. * @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
  70148. * @param onCompiled Called when the shader has been compiled.
  70149. * @param onError Called if there is an error when compiling a shader.
  70150. */
  70151. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70152. /**
  70153. * The post process is reusable if it can be used multiple times within one frame.
  70154. * @returns If the post process is reusable
  70155. */
  70156. isReusable(): boolean;
  70157. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70158. markTextureDirty(): void;
  70159. /**
  70160. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70161. * 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.
  70162. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70163. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70164. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70165. * @returns The target texture that was bound to be written to.
  70166. */
  70167. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70168. /**
  70169. * If the post process is supported.
  70170. */
  70171. readonly isSupported: boolean;
  70172. /**
  70173. * The aspect ratio of the output texture.
  70174. */
  70175. readonly aspectRatio: number;
  70176. /**
  70177. * Get a value indicating if the post-process is ready to be used
  70178. * @returns true if the post-process is ready (shader is compiled)
  70179. */
  70180. isReady(): boolean;
  70181. /**
  70182. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70183. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70184. */
  70185. apply(): Nullable<Effect>;
  70186. private _disposeTextures;
  70187. /**
  70188. * Disposes the post process.
  70189. * @param camera The camera to dispose the post process on.
  70190. */
  70191. dispose(camera?: Camera): void;
  70192. }
  70193. }
  70194. declare module BABYLON {
  70195. /**
  70196. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70197. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70198. */
  70199. export class PostProcessManager {
  70200. private _scene;
  70201. private _indexBuffer;
  70202. private _vertexBuffers;
  70203. /**
  70204. * Creates a new instance PostProcess
  70205. * @param scene The scene that the post process is associated with.
  70206. */
  70207. constructor(scene: Scene);
  70208. private _prepareBuffers;
  70209. private _buildIndexBuffer;
  70210. /**
  70211. * Rebuilds the vertex buffers of the manager.
  70212. * @hidden
  70213. */
  70214. _rebuild(): void;
  70215. /**
  70216. * Prepares a frame to be run through a post process.
  70217. * @param sourceTexture The input texture to the post procesess. (default: null)
  70218. * @param postProcesses An array of post processes to be run. (default: null)
  70219. * @returns True if the post processes were able to be run.
  70220. * @hidden
  70221. */
  70222. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70223. /**
  70224. * Manually render a set of post processes to a texture.
  70225. * @param postProcesses An array of post processes to be run.
  70226. * @param targetTexture The target texture to render to.
  70227. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70228. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70229. * @param lodLevel defines which lod of the texture to render to
  70230. */
  70231. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70232. /**
  70233. * Finalize the result of the output of the postprocesses.
  70234. * @param doNotPresent If true the result will not be displayed to the screen.
  70235. * @param targetTexture The target texture to render to.
  70236. * @param faceIndex The index of the face to bind the target texture to.
  70237. * @param postProcesses The array of post processes to render.
  70238. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70239. * @hidden
  70240. */
  70241. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70242. /**
  70243. * Disposes of the post process manager.
  70244. */
  70245. dispose(): void;
  70246. }
  70247. }
  70248. declare module BABYLON {
  70249. interface AbstractScene {
  70250. /**
  70251. * The list of layers (background and foreground) of the scene
  70252. */
  70253. layers: Array<Layer>;
  70254. }
  70255. /**
  70256. * Defines the layer scene component responsible to manage any layers
  70257. * in a given scene.
  70258. */
  70259. export class LayerSceneComponent implements ISceneComponent {
  70260. /**
  70261. * The component name helpfull to identify the component in the list of scene components.
  70262. */
  70263. readonly name: string;
  70264. /**
  70265. * The scene the component belongs to.
  70266. */
  70267. scene: Scene;
  70268. private _engine;
  70269. /**
  70270. * Creates a new instance of the component for the given scene
  70271. * @param scene Defines the scene to register the component in
  70272. */
  70273. constructor(scene: Scene);
  70274. /**
  70275. * Registers the component in a given scene
  70276. */
  70277. register(): void;
  70278. /**
  70279. * Rebuilds the elements related to this component in case of
  70280. * context lost for instance.
  70281. */
  70282. rebuild(): void;
  70283. /**
  70284. * Disposes the component and the associated ressources.
  70285. */
  70286. dispose(): void;
  70287. private _draw;
  70288. private _drawCameraPredicate;
  70289. private _drawCameraBackground;
  70290. private _drawCameraForeground;
  70291. private _drawRenderTargetPredicate;
  70292. private _drawRenderTargetBackground;
  70293. private _drawRenderTargetForeground;
  70294. }
  70295. }
  70296. declare module BABYLON {
  70297. /** @hidden */
  70298. export var layerPixelShader: {
  70299. name: string;
  70300. shader: string;
  70301. };
  70302. }
  70303. declare module BABYLON {
  70304. /** @hidden */
  70305. export var layerVertexShader: {
  70306. name: string;
  70307. shader: string;
  70308. };
  70309. }
  70310. declare module BABYLON {
  70311. /**
  70312. * This represents a full screen 2d layer.
  70313. * This can be useful to display a picture in the background of your scene for instance.
  70314. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70315. */
  70316. export class Layer {
  70317. /**
  70318. * Define the name of the layer.
  70319. */
  70320. name: string;
  70321. /**
  70322. * Define the texture the layer should display.
  70323. */
  70324. texture: Nullable<Texture>;
  70325. /**
  70326. * Is the layer in background or foreground.
  70327. */
  70328. isBackground: boolean;
  70329. /**
  70330. * Define the color of the layer (instead of texture).
  70331. */
  70332. color: Color4;
  70333. /**
  70334. * Define the scale of the layer in order to zoom in out of the texture.
  70335. */
  70336. scale: Vector2;
  70337. /**
  70338. * Define an offset for the layer in order to shift the texture.
  70339. */
  70340. offset: Vector2;
  70341. /**
  70342. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70343. */
  70344. alphaBlendingMode: number;
  70345. /**
  70346. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70347. * Alpha test will not mix with the background color in case of transparency.
  70348. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70349. */
  70350. alphaTest: boolean;
  70351. /**
  70352. * Define a mask to restrict the layer to only some of the scene cameras.
  70353. */
  70354. layerMask: number;
  70355. /**
  70356. * Define the list of render target the layer is visible into.
  70357. */
  70358. renderTargetTextures: RenderTargetTexture[];
  70359. /**
  70360. * Define if the layer is only used in renderTarget or if it also
  70361. * renders in the main frame buffer of the canvas.
  70362. */
  70363. renderOnlyInRenderTargetTextures: boolean;
  70364. private _scene;
  70365. private _vertexBuffers;
  70366. private _indexBuffer;
  70367. private _effect;
  70368. private _alphaTestEffect;
  70369. /**
  70370. * An event triggered when the layer is disposed.
  70371. */
  70372. onDisposeObservable: Observable<Layer>;
  70373. private _onDisposeObserver;
  70374. /**
  70375. * Back compatibility with callback before the onDisposeObservable existed.
  70376. * The set callback will be triggered when the layer has been disposed.
  70377. */
  70378. onDispose: () => void;
  70379. /**
  70380. * An event triggered before rendering the scene
  70381. */
  70382. onBeforeRenderObservable: Observable<Layer>;
  70383. private _onBeforeRenderObserver;
  70384. /**
  70385. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70386. * The set callback will be triggered just before rendering the layer.
  70387. */
  70388. onBeforeRender: () => void;
  70389. /**
  70390. * An event triggered after rendering the scene
  70391. */
  70392. onAfterRenderObservable: Observable<Layer>;
  70393. private _onAfterRenderObserver;
  70394. /**
  70395. * Back compatibility with callback before the onAfterRenderObservable existed.
  70396. * The set callback will be triggered just after rendering the layer.
  70397. */
  70398. onAfterRender: () => void;
  70399. /**
  70400. * Instantiates a new layer.
  70401. * This represents a full screen 2d layer.
  70402. * This can be useful to display a picture in the background of your scene for instance.
  70403. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70404. * @param name Define the name of the layer in the scene
  70405. * @param imgUrl Define the url of the texture to display in the layer
  70406. * @param scene Define the scene the layer belongs to
  70407. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70408. * @param color Defines a color for the layer
  70409. */
  70410. constructor(
  70411. /**
  70412. * Define the name of the layer.
  70413. */
  70414. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70415. private _createIndexBuffer;
  70416. /** @hidden */
  70417. _rebuild(): void;
  70418. /**
  70419. * Renders the layer in the scene.
  70420. */
  70421. render(): void;
  70422. /**
  70423. * Disposes and releases the associated ressources.
  70424. */
  70425. dispose(): void;
  70426. }
  70427. }
  70428. declare module BABYLON {
  70429. interface AbstractScene {
  70430. /**
  70431. * The list of procedural textures added to the scene
  70432. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70433. */
  70434. proceduralTextures: Array<ProceduralTexture>;
  70435. }
  70436. /**
  70437. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70438. * in a given scene.
  70439. */
  70440. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70441. /**
  70442. * The component name helpfull to identify the component in the list of scene components.
  70443. */
  70444. readonly name: string;
  70445. /**
  70446. * The scene the component belongs to.
  70447. */
  70448. scene: Scene;
  70449. /**
  70450. * Creates a new instance of the component for the given scene
  70451. * @param scene Defines the scene to register the component in
  70452. */
  70453. constructor(scene: Scene);
  70454. /**
  70455. * Registers the component in a given scene
  70456. */
  70457. register(): void;
  70458. /**
  70459. * Rebuilds the elements related to this component in case of
  70460. * context lost for instance.
  70461. */
  70462. rebuild(): void;
  70463. /**
  70464. * Disposes the component and the associated ressources.
  70465. */
  70466. dispose(): void;
  70467. private _beforeClear;
  70468. }
  70469. }
  70470. declare module BABYLON {
  70471. /** @hidden */
  70472. export var proceduralVertexShader: {
  70473. name: string;
  70474. shader: string;
  70475. };
  70476. }
  70477. declare module BABYLON {
  70478. /**
  70479. * 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.
  70480. * This is the base class of any Procedural texture and contains most of the shareable code.
  70481. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70482. */
  70483. export class ProceduralTexture extends Texture {
  70484. isCube: boolean;
  70485. /**
  70486. * Define if the texture is enabled or not (disabled texture will not render)
  70487. */
  70488. isEnabled: boolean;
  70489. /**
  70490. * Define if the texture must be cleared before rendering (default is true)
  70491. */
  70492. autoClear: boolean;
  70493. /**
  70494. * Callback called when the texture is generated
  70495. */
  70496. onGenerated: () => void;
  70497. /**
  70498. * Event raised when the texture is generated
  70499. */
  70500. onGeneratedObservable: Observable<ProceduralTexture>;
  70501. /** @hidden */
  70502. _generateMipMaps: boolean;
  70503. /** @hidden **/
  70504. _effect: Effect;
  70505. /** @hidden */
  70506. _textures: {
  70507. [key: string]: Texture;
  70508. };
  70509. private _size;
  70510. private _currentRefreshId;
  70511. private _refreshRate;
  70512. private _vertexBuffers;
  70513. private _indexBuffer;
  70514. private _uniforms;
  70515. private _samplers;
  70516. private _fragment;
  70517. private _floats;
  70518. private _ints;
  70519. private _floatsArrays;
  70520. private _colors3;
  70521. private _colors4;
  70522. private _vectors2;
  70523. private _vectors3;
  70524. private _matrices;
  70525. private _fallbackTexture;
  70526. private _fallbackTextureUsed;
  70527. private _engine;
  70528. private _cachedDefines;
  70529. private _contentUpdateId;
  70530. private _contentData;
  70531. /**
  70532. * Instantiates a new procedural texture.
  70533. * 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.
  70534. * This is the base class of any Procedural texture and contains most of the shareable code.
  70535. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70536. * @param name Define the name of the texture
  70537. * @param size Define the size of the texture to create
  70538. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70539. * @param scene Define the scene the texture belongs to
  70540. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70541. * @param generateMipMaps Define if the texture should creates mip maps or not
  70542. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70543. */
  70544. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70545. /**
  70546. * The effect that is created when initializing the post process.
  70547. * @returns The created effect corrisponding the the postprocess.
  70548. */
  70549. getEffect(): Effect;
  70550. /**
  70551. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70552. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70553. */
  70554. getContent(): Nullable<ArrayBufferView>;
  70555. private _createIndexBuffer;
  70556. /** @hidden */
  70557. _rebuild(): void;
  70558. /**
  70559. * Resets the texture in order to recreate its associated resources.
  70560. * This can be called in case of context loss
  70561. */
  70562. reset(): void;
  70563. protected _getDefines(): string;
  70564. /**
  70565. * Is the texture ready to be used ? (rendered at least once)
  70566. * @returns true if ready, otherwise, false.
  70567. */
  70568. isReady(): boolean;
  70569. /**
  70570. * Resets the refresh counter of the texture and start bak from scratch.
  70571. * Could be useful to regenerate the texture if it is setup to render only once.
  70572. */
  70573. resetRefreshCounter(): void;
  70574. /**
  70575. * Set the fragment shader to use in order to render the texture.
  70576. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70577. */
  70578. setFragment(fragment: any): void;
  70579. /**
  70580. * Define the refresh rate of the texture or the rendering frequency.
  70581. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70582. */
  70583. refreshRate: number;
  70584. /** @hidden */
  70585. _shouldRender(): boolean;
  70586. /**
  70587. * Get the size the texture is rendering at.
  70588. * @returns the size (texture is always squared)
  70589. */
  70590. getRenderSize(): number;
  70591. /**
  70592. * Resize the texture to new value.
  70593. * @param size Define the new size the texture should have
  70594. * @param generateMipMaps Define whether the new texture should create mip maps
  70595. */
  70596. resize(size: number, generateMipMaps: boolean): void;
  70597. private _checkUniform;
  70598. /**
  70599. * Set a texture in the shader program used to render.
  70600. * @param name Define the name of the uniform samplers as defined in the shader
  70601. * @param texture Define the texture to bind to this sampler
  70602. * @return the texture itself allowing "fluent" like uniform updates
  70603. */
  70604. setTexture(name: string, texture: Texture): ProceduralTexture;
  70605. /**
  70606. * Set a float in the shader.
  70607. * @param name Define the name of the uniform as defined in the shader
  70608. * @param value Define the value to give to the uniform
  70609. * @return the texture itself allowing "fluent" like uniform updates
  70610. */
  70611. setFloat(name: string, value: number): ProceduralTexture;
  70612. /**
  70613. * Set a int in the shader.
  70614. * @param name Define the name of the uniform as defined in the shader
  70615. * @param value Define the value to give to the uniform
  70616. * @return the texture itself allowing "fluent" like uniform updates
  70617. */
  70618. setInt(name: string, value: number): ProceduralTexture;
  70619. /**
  70620. * Set an array of floats in the shader.
  70621. * @param name Define the name of the uniform as defined in the shader
  70622. * @param value Define the value to give to the uniform
  70623. * @return the texture itself allowing "fluent" like uniform updates
  70624. */
  70625. setFloats(name: string, value: number[]): ProceduralTexture;
  70626. /**
  70627. * Set a vec3 in the shader from a Color3.
  70628. * @param name Define the name of the uniform as defined in the shader
  70629. * @param value Define the value to give to the uniform
  70630. * @return the texture itself allowing "fluent" like uniform updates
  70631. */
  70632. setColor3(name: string, value: Color3): ProceduralTexture;
  70633. /**
  70634. * Set a vec4 in the shader from a Color4.
  70635. * @param name Define the name of the uniform as defined in the shader
  70636. * @param value Define the value to give to the uniform
  70637. * @return the texture itself allowing "fluent" like uniform updates
  70638. */
  70639. setColor4(name: string, value: Color4): ProceduralTexture;
  70640. /**
  70641. * Set a vec2 in the shader from a Vector2.
  70642. * @param name Define the name of the uniform as defined in the shader
  70643. * @param value Define the value to give to the uniform
  70644. * @return the texture itself allowing "fluent" like uniform updates
  70645. */
  70646. setVector2(name: string, value: Vector2): ProceduralTexture;
  70647. /**
  70648. * Set a vec3 in the shader from a Vector3.
  70649. * @param name Define the name of the uniform as defined in the shader
  70650. * @param value Define the value to give to the uniform
  70651. * @return the texture itself allowing "fluent" like uniform updates
  70652. */
  70653. setVector3(name: string, value: Vector3): ProceduralTexture;
  70654. /**
  70655. * Set a mat4 in the shader from a MAtrix.
  70656. * @param name Define the name of the uniform as defined in the shader
  70657. * @param value Define the value to give to the uniform
  70658. * @return the texture itself allowing "fluent" like uniform updates
  70659. */
  70660. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70661. /**
  70662. * Render the texture to its associated render target.
  70663. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70664. */
  70665. render(useCameraPostProcess?: boolean): void;
  70666. /**
  70667. * Clone the texture.
  70668. * @returns the cloned texture
  70669. */
  70670. clone(): ProceduralTexture;
  70671. /**
  70672. * Dispose the texture and release its asoociated resources.
  70673. */
  70674. dispose(): void;
  70675. }
  70676. }
  70677. declare module BABYLON {
  70678. /**
  70679. * This represents the base class for particle system in Babylon.
  70680. * 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.
  70681. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70682. * @example https://doc.babylonjs.com/babylon101/particles
  70683. */
  70684. export class BaseParticleSystem {
  70685. /**
  70686. * Source color is added to the destination color without alpha affecting the result
  70687. */
  70688. static BLENDMODE_ONEONE: number;
  70689. /**
  70690. * Blend current color and particle color using particle’s alpha
  70691. */
  70692. static BLENDMODE_STANDARD: number;
  70693. /**
  70694. * Add current color and particle color multiplied by particle’s alpha
  70695. */
  70696. static BLENDMODE_ADD: number;
  70697. /**
  70698. * Multiply current color with particle color
  70699. */
  70700. static BLENDMODE_MULTIPLY: number;
  70701. /**
  70702. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70703. */
  70704. static BLENDMODE_MULTIPLYADD: number;
  70705. /**
  70706. * List of animations used by the particle system.
  70707. */
  70708. animations: Animation[];
  70709. /**
  70710. * The id of the Particle system.
  70711. */
  70712. id: string;
  70713. /**
  70714. * The friendly name of the Particle system.
  70715. */
  70716. name: string;
  70717. /**
  70718. * The rendering group used by the Particle system to chose when to render.
  70719. */
  70720. renderingGroupId: number;
  70721. /**
  70722. * The emitter represents the Mesh or position we are attaching the particle system to.
  70723. */
  70724. emitter: Nullable<AbstractMesh | Vector3>;
  70725. /**
  70726. * The maximum number of particles to emit per frame
  70727. */
  70728. emitRate: number;
  70729. /**
  70730. * If you want to launch only a few particles at once, that can be done, as well.
  70731. */
  70732. manualEmitCount: number;
  70733. /**
  70734. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70735. */
  70736. updateSpeed: number;
  70737. /**
  70738. * The amount of time the particle system is running (depends of the overall update speed).
  70739. */
  70740. targetStopDuration: number;
  70741. /**
  70742. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70743. */
  70744. disposeOnStop: boolean;
  70745. /**
  70746. * Minimum power of emitting particles.
  70747. */
  70748. minEmitPower: number;
  70749. /**
  70750. * Maximum power of emitting particles.
  70751. */
  70752. maxEmitPower: number;
  70753. /**
  70754. * Minimum life time of emitting particles.
  70755. */
  70756. minLifeTime: number;
  70757. /**
  70758. * Maximum life time of emitting particles.
  70759. */
  70760. maxLifeTime: number;
  70761. /**
  70762. * Minimum Size of emitting particles.
  70763. */
  70764. minSize: number;
  70765. /**
  70766. * Maximum Size of emitting particles.
  70767. */
  70768. maxSize: number;
  70769. /**
  70770. * Minimum scale of emitting particles on X axis.
  70771. */
  70772. minScaleX: number;
  70773. /**
  70774. * Maximum scale of emitting particles on X axis.
  70775. */
  70776. maxScaleX: number;
  70777. /**
  70778. * Minimum scale of emitting particles on Y axis.
  70779. */
  70780. minScaleY: number;
  70781. /**
  70782. * Maximum scale of emitting particles on Y axis.
  70783. */
  70784. maxScaleY: number;
  70785. /**
  70786. * Gets or sets the minimal initial rotation in radians.
  70787. */
  70788. minInitialRotation: number;
  70789. /**
  70790. * Gets or sets the maximal initial rotation in radians.
  70791. */
  70792. maxInitialRotation: number;
  70793. /**
  70794. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70795. */
  70796. minAngularSpeed: number;
  70797. /**
  70798. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70799. */
  70800. maxAngularSpeed: number;
  70801. /**
  70802. * The texture used to render each particle. (this can be a spritesheet)
  70803. */
  70804. particleTexture: Nullable<Texture>;
  70805. /**
  70806. * The layer mask we are rendering the particles through.
  70807. */
  70808. layerMask: number;
  70809. /**
  70810. * This can help using your own shader to render the particle system.
  70811. * The according effect will be created
  70812. */
  70813. customShader: any;
  70814. /**
  70815. * By default particle system starts as soon as they are created. This prevents the
  70816. * automatic start to happen and let you decide when to start emitting particles.
  70817. */
  70818. preventAutoStart: boolean;
  70819. private _noiseTexture;
  70820. /**
  70821. * Gets or sets a texture used to add random noise to particle positions
  70822. */
  70823. noiseTexture: Nullable<ProceduralTexture>;
  70824. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70825. noiseStrength: Vector3;
  70826. /**
  70827. * Callback triggered when the particle animation is ending.
  70828. */
  70829. onAnimationEnd: Nullable<() => void>;
  70830. /**
  70831. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70832. */
  70833. blendMode: number;
  70834. /**
  70835. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70836. * to override the particles.
  70837. */
  70838. forceDepthWrite: boolean;
  70839. /** 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 */
  70840. preWarmCycles: number;
  70841. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70842. preWarmStepOffset: number;
  70843. /**
  70844. * 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)
  70845. */
  70846. spriteCellChangeSpeed: number;
  70847. /**
  70848. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70849. */
  70850. startSpriteCellID: number;
  70851. /**
  70852. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70853. */
  70854. endSpriteCellID: number;
  70855. /**
  70856. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70857. */
  70858. spriteCellWidth: number;
  70859. /**
  70860. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70861. */
  70862. spriteCellHeight: number;
  70863. /**
  70864. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70865. */
  70866. spriteRandomStartCell: boolean;
  70867. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70868. translationPivot: Vector2;
  70869. /** @hidden */
  70870. protected _isAnimationSheetEnabled: boolean;
  70871. /**
  70872. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70873. */
  70874. beginAnimationOnStart: boolean;
  70875. /**
  70876. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70877. */
  70878. beginAnimationFrom: number;
  70879. /**
  70880. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70881. */
  70882. beginAnimationTo: number;
  70883. /**
  70884. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70885. */
  70886. beginAnimationLoop: boolean;
  70887. /**
  70888. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70889. */
  70890. isAnimationSheetEnabled: boolean;
  70891. /**
  70892. * Get hosting scene
  70893. * @returns the scene
  70894. */
  70895. getScene(): Scene;
  70896. /**
  70897. * You can use gravity if you want to give an orientation to your particles.
  70898. */
  70899. gravity: Vector3;
  70900. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70901. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70902. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70903. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70904. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70905. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70906. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70907. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70908. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70909. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70910. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70911. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70912. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70913. /**
  70914. * Defines the delay in milliseconds before starting the system (0 by default)
  70915. */
  70916. startDelay: number;
  70917. /**
  70918. * Gets the current list of drag gradients.
  70919. * You must use addDragGradient and removeDragGradient to udpate this list
  70920. * @returns the list of drag gradients
  70921. */
  70922. getDragGradients(): Nullable<Array<FactorGradient>>;
  70923. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70924. limitVelocityDamping: number;
  70925. /**
  70926. * Gets the current list of limit velocity gradients.
  70927. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70928. * @returns the list of limit velocity gradients
  70929. */
  70930. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70931. /**
  70932. * Gets the current list of color gradients.
  70933. * You must use addColorGradient and removeColorGradient to udpate this list
  70934. * @returns the list of color gradients
  70935. */
  70936. getColorGradients(): Nullable<Array<ColorGradient>>;
  70937. /**
  70938. * Gets the current list of size gradients.
  70939. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70940. * @returns the list of size gradients
  70941. */
  70942. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70943. /**
  70944. * Gets the current list of color remap gradients.
  70945. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70946. * @returns the list of color remap gradients
  70947. */
  70948. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70949. /**
  70950. * Gets the current list of alpha remap gradients.
  70951. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70952. * @returns the list of alpha remap gradients
  70953. */
  70954. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70955. /**
  70956. * Gets the current list of life time gradients.
  70957. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70958. * @returns the list of life time gradients
  70959. */
  70960. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70961. /**
  70962. * Gets the current list of angular speed gradients.
  70963. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70964. * @returns the list of angular speed gradients
  70965. */
  70966. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70967. /**
  70968. * Gets the current list of velocity gradients.
  70969. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70970. * @returns the list of velocity gradients
  70971. */
  70972. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70973. /**
  70974. * Gets the current list of start size gradients.
  70975. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70976. * @returns the list of start size gradients
  70977. */
  70978. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70979. /**
  70980. * Gets the current list of emit rate gradients.
  70981. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70982. * @returns the list of emit rate gradients
  70983. */
  70984. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70985. /**
  70986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70987. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70988. */
  70989. direction1: Vector3;
  70990. /**
  70991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70992. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70993. */
  70994. direction2: Vector3;
  70995. /**
  70996. * 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.
  70997. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70998. */
  70999. minEmitBox: Vector3;
  71000. /**
  71001. * 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.
  71002. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71003. */
  71004. maxEmitBox: Vector3;
  71005. /**
  71006. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71007. */
  71008. color1: Color4;
  71009. /**
  71010. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71011. */
  71012. color2: Color4;
  71013. /**
  71014. * Color the particle will have at the end of its lifetime
  71015. */
  71016. colorDead: Color4;
  71017. /**
  71018. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71019. */
  71020. textureMask: Color4;
  71021. /**
  71022. * The particle emitter type defines the emitter used by the particle system.
  71023. * It can be for example box, sphere, or cone...
  71024. */
  71025. particleEmitterType: IParticleEmitterType;
  71026. /** @hidden */
  71027. _isSubEmitter: boolean;
  71028. /**
  71029. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71030. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71031. */
  71032. billboardMode: number;
  71033. protected _isBillboardBased: boolean;
  71034. /**
  71035. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71036. */
  71037. isBillboardBased: boolean;
  71038. /**
  71039. * The scene the particle system belongs to.
  71040. */
  71041. protected _scene: Scene;
  71042. /**
  71043. * Local cache of defines for image processing.
  71044. */
  71045. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71046. /**
  71047. * Default configuration related to image processing available in the standard Material.
  71048. */
  71049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71050. /**
  71051. * Gets the image processing configuration used either in this material.
  71052. */
  71053. /**
  71054. * Sets the Default image processing configuration used either in the this material.
  71055. *
  71056. * If sets to null, the scene one is in use.
  71057. */
  71058. imageProcessingConfiguration: ImageProcessingConfiguration;
  71059. /**
  71060. * Attaches a new image processing configuration to the Standard Material.
  71061. * @param configuration
  71062. */
  71063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71064. /** @hidden */
  71065. protected _reset(): void;
  71066. /** @hidden */
  71067. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71068. /**
  71069. * Instantiates a particle system.
  71070. * 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.
  71071. * @param name The name of the particle system
  71072. */
  71073. constructor(name: string);
  71074. /**
  71075. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71076. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71077. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71078. * @returns the emitter
  71079. */
  71080. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71081. /**
  71082. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71083. * @param radius The radius of the hemisphere to emit from
  71084. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71085. * @returns the emitter
  71086. */
  71087. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71088. /**
  71089. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71090. * @param radius The radius of the sphere to emit from
  71091. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71092. * @returns the emitter
  71093. */
  71094. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71095. /**
  71096. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71097. * @param radius The radius of the sphere to emit from
  71098. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71099. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71100. * @returns the emitter
  71101. */
  71102. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71103. /**
  71104. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71105. * @param radius The radius of the emission cylinder
  71106. * @param height The height of the emission cylinder
  71107. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71108. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71109. * @returns the emitter
  71110. */
  71111. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71112. /**
  71113. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71114. * @param radius The radius of the cylinder to emit from
  71115. * @param height The height of the emission cylinder
  71116. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71117. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71118. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71119. * @returns the emitter
  71120. */
  71121. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71122. /**
  71123. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71124. * @param radius The radius of the cone to emit from
  71125. * @param angle The base angle of the cone
  71126. * @returns the emitter
  71127. */
  71128. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71129. /**
  71130. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71131. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71132. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71133. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71134. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71135. * @returns the emitter
  71136. */
  71137. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71138. }
  71139. }
  71140. declare module BABYLON {
  71141. /**
  71142. * Type of sub emitter
  71143. */
  71144. export enum SubEmitterType {
  71145. /**
  71146. * Attached to the particle over it's lifetime
  71147. */
  71148. ATTACHED = 0,
  71149. /**
  71150. * Created when the particle dies
  71151. */
  71152. END = 1
  71153. }
  71154. /**
  71155. * Sub emitter class used to emit particles from an existing particle
  71156. */
  71157. export class SubEmitter {
  71158. /**
  71159. * the particle system to be used by the sub emitter
  71160. */
  71161. particleSystem: ParticleSystem;
  71162. /**
  71163. * Type of the submitter (Default: END)
  71164. */
  71165. type: SubEmitterType;
  71166. /**
  71167. * 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)
  71168. * Note: This only is supported when using an emitter of type Mesh
  71169. */
  71170. inheritDirection: boolean;
  71171. /**
  71172. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71173. */
  71174. inheritedVelocityAmount: number;
  71175. /**
  71176. * Creates a sub emitter
  71177. * @param particleSystem the particle system to be used by the sub emitter
  71178. */
  71179. constructor(
  71180. /**
  71181. * the particle system to be used by the sub emitter
  71182. */
  71183. particleSystem: ParticleSystem);
  71184. /**
  71185. * Clones the sub emitter
  71186. * @returns the cloned sub emitter
  71187. */
  71188. clone(): SubEmitter;
  71189. /**
  71190. * Serialize current object to a JSON object
  71191. * @returns the serialized object
  71192. */
  71193. serialize(): any;
  71194. /** @hidden */
  71195. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71196. /**
  71197. * Creates a new SubEmitter from a serialized JSON version
  71198. * @param serializationObject defines the JSON object to read from
  71199. * @param scene defines the hosting scene
  71200. * @param rootUrl defines the rootUrl for data loading
  71201. * @returns a new SubEmitter
  71202. */
  71203. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71204. /** Release associated resources */
  71205. dispose(): void;
  71206. }
  71207. }
  71208. declare module BABYLON {
  71209. /** @hidden */
  71210. export var clipPlaneFragmentDeclaration: {
  71211. name: string;
  71212. shader: string;
  71213. };
  71214. }
  71215. declare module BABYLON {
  71216. /** @hidden */
  71217. export var imageProcessingDeclaration: {
  71218. name: string;
  71219. shader: string;
  71220. };
  71221. }
  71222. declare module BABYLON {
  71223. /** @hidden */
  71224. export var imageProcessingFunctions: {
  71225. name: string;
  71226. shader: string;
  71227. };
  71228. }
  71229. declare module BABYLON {
  71230. /** @hidden */
  71231. export var clipPlaneFragment: {
  71232. name: string;
  71233. shader: string;
  71234. };
  71235. }
  71236. declare module BABYLON {
  71237. /** @hidden */
  71238. export var particlesPixelShader: {
  71239. name: string;
  71240. shader: string;
  71241. };
  71242. }
  71243. declare module BABYLON {
  71244. /** @hidden */
  71245. export var clipPlaneVertexDeclaration: {
  71246. name: string;
  71247. shader: string;
  71248. };
  71249. }
  71250. declare module BABYLON {
  71251. /** @hidden */
  71252. export var clipPlaneVertex: {
  71253. name: string;
  71254. shader: string;
  71255. };
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var particlesVertexShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /**
  71266. * This represents a particle system in Babylon.
  71267. * 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.
  71268. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71269. * @example https://doc.babylonjs.com/babylon101/particles
  71270. */
  71271. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71272. /**
  71273. * Billboard mode will only apply to Y axis
  71274. */
  71275. static readonly BILLBOARDMODE_Y: number;
  71276. /**
  71277. * Billboard mode will apply to all axes
  71278. */
  71279. static readonly BILLBOARDMODE_ALL: number;
  71280. /**
  71281. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71282. */
  71283. static readonly BILLBOARDMODE_STRETCHED: number;
  71284. /**
  71285. * This function can be defined to provide custom update for active particles.
  71286. * This function will be called instead of regular update (age, position, color, etc.).
  71287. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71288. */
  71289. updateFunction: (particles: Particle[]) => void;
  71290. private _emitterWorldMatrix;
  71291. /**
  71292. * This function can be defined to specify initial direction for every new particle.
  71293. * It by default use the emitterType defined function
  71294. */
  71295. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71296. /**
  71297. * This function can be defined to specify initial position for every new particle.
  71298. * It by default use the emitterType defined function
  71299. */
  71300. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71301. /**
  71302. * @hidden
  71303. */
  71304. _inheritedVelocityOffset: Vector3;
  71305. /**
  71306. * An event triggered when the system is disposed
  71307. */
  71308. onDisposeObservable: Observable<ParticleSystem>;
  71309. private _onDisposeObserver;
  71310. /**
  71311. * Sets a callback that will be triggered when the system is disposed
  71312. */
  71313. onDispose: () => void;
  71314. private _particles;
  71315. private _epsilon;
  71316. private _capacity;
  71317. private _stockParticles;
  71318. private _newPartsExcess;
  71319. private _vertexData;
  71320. private _vertexBuffer;
  71321. private _vertexBuffers;
  71322. private _spriteBuffer;
  71323. private _indexBuffer;
  71324. private _effect;
  71325. private _customEffect;
  71326. private _cachedDefines;
  71327. private _scaledColorStep;
  71328. private _colorDiff;
  71329. private _scaledDirection;
  71330. private _scaledGravity;
  71331. private _currentRenderId;
  71332. private _alive;
  71333. private _useInstancing;
  71334. private _started;
  71335. private _stopped;
  71336. private _actualFrame;
  71337. private _scaledUpdateSpeed;
  71338. private _vertexBufferSize;
  71339. /** @hidden */
  71340. _currentEmitRateGradient: Nullable<FactorGradient>;
  71341. /** @hidden */
  71342. _currentEmitRate1: number;
  71343. /** @hidden */
  71344. _currentEmitRate2: number;
  71345. /** @hidden */
  71346. _currentStartSizeGradient: Nullable<FactorGradient>;
  71347. /** @hidden */
  71348. _currentStartSize1: number;
  71349. /** @hidden */
  71350. _currentStartSize2: number;
  71351. private readonly _rawTextureWidth;
  71352. private _rampGradientsTexture;
  71353. private _useRampGradients;
  71354. /** Gets or sets a boolean indicating that ramp gradients must be used
  71355. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71356. */
  71357. useRampGradients: boolean;
  71358. /**
  71359. * 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.
  71360. * 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: [])
  71361. */
  71362. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71363. private _subEmitters;
  71364. /**
  71365. * @hidden
  71366. * If the particle systems emitter should be disposed when the particle system is disposed
  71367. */
  71368. _disposeEmitterOnDispose: boolean;
  71369. /**
  71370. * The current active Sub-systems, this property is used by the root particle system only.
  71371. */
  71372. activeSubSystems: Array<ParticleSystem>;
  71373. private _rootParticleSystem;
  71374. /**
  71375. * Gets the current list of active particles
  71376. */
  71377. readonly particles: Particle[];
  71378. /**
  71379. * Returns the string "ParticleSystem"
  71380. * @returns a string containing the class name
  71381. */
  71382. getClassName(): string;
  71383. /**
  71384. * Instantiates a particle system.
  71385. * 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.
  71386. * @param name The name of the particle system
  71387. * @param capacity The max number of particles alive at the same time
  71388. * @param scene The scene the particle system belongs to
  71389. * @param customEffect a custom effect used to change the way particles are rendered by default
  71390. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71391. * @param epsilon Offset used to render the particles
  71392. */
  71393. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71394. private _addFactorGradient;
  71395. private _removeFactorGradient;
  71396. /**
  71397. * Adds a new life time gradient
  71398. * @param gradient defines the gradient to use (between 0 and 1)
  71399. * @param factor defines the life time factor to affect to the specified gradient
  71400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71401. * @returns the current particle system
  71402. */
  71403. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71404. /**
  71405. * Remove a specific life time gradient
  71406. * @param gradient defines the gradient to remove
  71407. * @returns the current particle system
  71408. */
  71409. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71410. /**
  71411. * Adds a new size gradient
  71412. * @param gradient defines the gradient to use (between 0 and 1)
  71413. * @param factor defines the size factor to affect to the specified gradient
  71414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71415. * @returns the current particle system
  71416. */
  71417. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71418. /**
  71419. * Remove a specific size gradient
  71420. * @param gradient defines the gradient to remove
  71421. * @returns the current particle system
  71422. */
  71423. removeSizeGradient(gradient: number): IParticleSystem;
  71424. /**
  71425. * Adds a new color remap gradient
  71426. * @param gradient defines the gradient to use (between 0 and 1)
  71427. * @param min defines the color remap minimal range
  71428. * @param max defines the color remap maximal range
  71429. * @returns the current particle system
  71430. */
  71431. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71432. /**
  71433. * Remove a specific color remap gradient
  71434. * @param gradient defines the gradient to remove
  71435. * @returns the current particle system
  71436. */
  71437. removeColorRemapGradient(gradient: number): IParticleSystem;
  71438. /**
  71439. * Adds a new alpha remap gradient
  71440. * @param gradient defines the gradient to use (between 0 and 1)
  71441. * @param min defines the alpha remap minimal range
  71442. * @param max defines the alpha remap maximal range
  71443. * @returns the current particle system
  71444. */
  71445. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71446. /**
  71447. * Remove a specific alpha remap gradient
  71448. * @param gradient defines the gradient to remove
  71449. * @returns the current particle system
  71450. */
  71451. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71452. /**
  71453. * Adds a new angular speed gradient
  71454. * @param gradient defines the gradient to use (between 0 and 1)
  71455. * @param factor defines the angular speed to affect to the specified gradient
  71456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71457. * @returns the current particle system
  71458. */
  71459. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71460. /**
  71461. * Remove a specific angular speed gradient
  71462. * @param gradient defines the gradient to remove
  71463. * @returns the current particle system
  71464. */
  71465. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71466. /**
  71467. * Adds a new velocity gradient
  71468. * @param gradient defines the gradient to use (between 0 and 1)
  71469. * @param factor defines the velocity to affect to the specified gradient
  71470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71471. * @returns the current particle system
  71472. */
  71473. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71474. /**
  71475. * Remove a specific velocity gradient
  71476. * @param gradient defines the gradient to remove
  71477. * @returns the current particle system
  71478. */
  71479. removeVelocityGradient(gradient: number): IParticleSystem;
  71480. /**
  71481. * Adds a new limit velocity gradient
  71482. * @param gradient defines the gradient to use (between 0 and 1)
  71483. * @param factor defines the limit velocity value to affect to the specified gradient
  71484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71485. * @returns the current particle system
  71486. */
  71487. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71488. /**
  71489. * Remove a specific limit velocity gradient
  71490. * @param gradient defines the gradient to remove
  71491. * @returns the current particle system
  71492. */
  71493. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71494. /**
  71495. * Adds a new drag gradient
  71496. * @param gradient defines the gradient to use (between 0 and 1)
  71497. * @param factor defines the drag value to affect to the specified gradient
  71498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71499. * @returns the current particle system
  71500. */
  71501. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71502. /**
  71503. * Remove a specific drag gradient
  71504. * @param gradient defines the gradient to remove
  71505. * @returns the current particle system
  71506. */
  71507. removeDragGradient(gradient: number): IParticleSystem;
  71508. /**
  71509. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71510. * @param gradient defines the gradient to use (between 0 and 1)
  71511. * @param factor defines the emit rate value to affect to the specified gradient
  71512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71513. * @returns the current particle system
  71514. */
  71515. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71516. /**
  71517. * Remove a specific emit rate gradient
  71518. * @param gradient defines the gradient to remove
  71519. * @returns the current particle system
  71520. */
  71521. removeEmitRateGradient(gradient: number): IParticleSystem;
  71522. /**
  71523. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71524. * @param gradient defines the gradient to use (between 0 and 1)
  71525. * @param factor defines the start size value to affect to the specified gradient
  71526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71527. * @returns the current particle system
  71528. */
  71529. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71530. /**
  71531. * Remove a specific start size gradient
  71532. * @param gradient defines the gradient to remove
  71533. * @returns the current particle system
  71534. */
  71535. removeStartSizeGradient(gradient: number): IParticleSystem;
  71536. private _createRampGradientTexture;
  71537. /**
  71538. * Gets the current list of ramp gradients.
  71539. * You must use addRampGradient and removeRampGradient to udpate this list
  71540. * @returns the list of ramp gradients
  71541. */
  71542. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71543. /**
  71544. * Adds a new ramp gradient used to remap particle colors
  71545. * @param gradient defines the gradient to use (between 0 and 1)
  71546. * @param color defines the color to affect to the specified gradient
  71547. * @returns the current particle system
  71548. */
  71549. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71550. /**
  71551. * Remove a specific ramp gradient
  71552. * @param gradient defines the gradient to remove
  71553. * @returns the current particle system
  71554. */
  71555. removeRampGradient(gradient: number): ParticleSystem;
  71556. /**
  71557. * Adds a new color gradient
  71558. * @param gradient defines the gradient to use (between 0 and 1)
  71559. * @param color1 defines the color to affect to the specified gradient
  71560. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71561. * @returns this particle system
  71562. */
  71563. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71564. /**
  71565. * Remove a specific color gradient
  71566. * @param gradient defines the gradient to remove
  71567. * @returns this particle system
  71568. */
  71569. removeColorGradient(gradient: number): IParticleSystem;
  71570. private _fetchR;
  71571. protected _reset(): void;
  71572. private _resetEffect;
  71573. private _createVertexBuffers;
  71574. private _createIndexBuffer;
  71575. /**
  71576. * Gets the maximum number of particles active at the same time.
  71577. * @returns The max number of active particles.
  71578. */
  71579. getCapacity(): number;
  71580. /**
  71581. * Gets whether there are still active particles in the system.
  71582. * @returns True if it is alive, otherwise false.
  71583. */
  71584. isAlive(): boolean;
  71585. /**
  71586. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71587. * @returns True if it has been started, otherwise false.
  71588. */
  71589. isStarted(): boolean;
  71590. private _prepareSubEmitterInternalArray;
  71591. /**
  71592. * Starts the particle system and begins to emit
  71593. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71594. */
  71595. start(delay?: number): void;
  71596. /**
  71597. * Stops the particle system.
  71598. * @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.
  71599. */
  71600. stop(stopSubEmitters?: boolean): void;
  71601. /**
  71602. * Remove all active particles
  71603. */
  71604. reset(): void;
  71605. /**
  71606. * @hidden (for internal use only)
  71607. */
  71608. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71609. /**
  71610. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71611. * Its lifetime will start back at 0.
  71612. */
  71613. recycleParticle: (particle: Particle) => void;
  71614. private _stopSubEmitters;
  71615. private _createParticle;
  71616. private _removeFromRoot;
  71617. private _emitFromParticle;
  71618. private _update;
  71619. /** @hidden */
  71620. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71621. /** @hidden */
  71622. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71623. /** @hidden */
  71624. private _getEffect;
  71625. /**
  71626. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71627. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71628. */
  71629. animate(preWarmOnly?: boolean): void;
  71630. private _appendParticleVertices;
  71631. /**
  71632. * Rebuilds the particle system.
  71633. */
  71634. rebuild(): void;
  71635. /**
  71636. * Is this system ready to be used/rendered
  71637. * @return true if the system is ready
  71638. */
  71639. isReady(): boolean;
  71640. private _render;
  71641. /**
  71642. * Renders the particle system in its current state.
  71643. * @returns the current number of particles
  71644. */
  71645. render(): number;
  71646. /**
  71647. * Disposes the particle system and free the associated resources
  71648. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71649. */
  71650. dispose(disposeTexture?: boolean): void;
  71651. /**
  71652. * Clones the particle system.
  71653. * @param name The name of the cloned object
  71654. * @param newEmitter The new emitter to use
  71655. * @returns the cloned particle system
  71656. */
  71657. clone(name: string, newEmitter: any): ParticleSystem;
  71658. /**
  71659. * Serializes the particle system to a JSON object.
  71660. * @returns the JSON object
  71661. */
  71662. serialize(): any;
  71663. /** @hidden */
  71664. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71665. /** @hidden */
  71666. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71667. /**
  71668. * Parses a JSON object to create a particle system.
  71669. * @param parsedParticleSystem The JSON object to parse
  71670. * @param scene The scene to create the particle system in
  71671. * @param rootUrl The root url to use to load external dependencies like texture
  71672. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71673. * @returns the Parsed particle system
  71674. */
  71675. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71676. }
  71677. }
  71678. declare module BABYLON {
  71679. /**
  71680. * A particle represents one of the element emitted by a particle system.
  71681. * This is mainly define by its coordinates, direction, velocity and age.
  71682. */
  71683. export class Particle {
  71684. /**
  71685. * The particle system the particle belongs to.
  71686. */
  71687. particleSystem: ParticleSystem;
  71688. private static _Count;
  71689. /**
  71690. * Unique ID of the particle
  71691. */
  71692. id: number;
  71693. /**
  71694. * The world position of the particle in the scene.
  71695. */
  71696. position: Vector3;
  71697. /**
  71698. * The world direction of the particle in the scene.
  71699. */
  71700. direction: Vector3;
  71701. /**
  71702. * The color of the particle.
  71703. */
  71704. color: Color4;
  71705. /**
  71706. * The color change of the particle per step.
  71707. */
  71708. colorStep: Color4;
  71709. /**
  71710. * Defines how long will the life of the particle be.
  71711. */
  71712. lifeTime: number;
  71713. /**
  71714. * The current age of the particle.
  71715. */
  71716. age: number;
  71717. /**
  71718. * The current size of the particle.
  71719. */
  71720. size: number;
  71721. /**
  71722. * The current scale of the particle.
  71723. */
  71724. scale: Vector2;
  71725. /**
  71726. * The current angle of the particle.
  71727. */
  71728. angle: number;
  71729. /**
  71730. * Defines how fast is the angle changing.
  71731. */
  71732. angularSpeed: number;
  71733. /**
  71734. * Defines the cell index used by the particle to be rendered from a sprite.
  71735. */
  71736. cellIndex: number;
  71737. /**
  71738. * The information required to support color remapping
  71739. */
  71740. remapData: Vector4;
  71741. /** @hidden */
  71742. _randomCellOffset?: number;
  71743. /** @hidden */
  71744. _initialDirection: Nullable<Vector3>;
  71745. /** @hidden */
  71746. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71747. /** @hidden */
  71748. _initialStartSpriteCellID: number;
  71749. /** @hidden */
  71750. _initialEndSpriteCellID: number;
  71751. /** @hidden */
  71752. _currentColorGradient: Nullable<ColorGradient>;
  71753. /** @hidden */
  71754. _currentColor1: Color4;
  71755. /** @hidden */
  71756. _currentColor2: Color4;
  71757. /** @hidden */
  71758. _currentSizeGradient: Nullable<FactorGradient>;
  71759. /** @hidden */
  71760. _currentSize1: number;
  71761. /** @hidden */
  71762. _currentSize2: number;
  71763. /** @hidden */
  71764. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71765. /** @hidden */
  71766. _currentAngularSpeed1: number;
  71767. /** @hidden */
  71768. _currentAngularSpeed2: number;
  71769. /** @hidden */
  71770. _currentVelocityGradient: Nullable<FactorGradient>;
  71771. /** @hidden */
  71772. _currentVelocity1: number;
  71773. /** @hidden */
  71774. _currentVelocity2: number;
  71775. /** @hidden */
  71776. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71777. /** @hidden */
  71778. _currentLimitVelocity1: number;
  71779. /** @hidden */
  71780. _currentLimitVelocity2: number;
  71781. /** @hidden */
  71782. _currentDragGradient: Nullable<FactorGradient>;
  71783. /** @hidden */
  71784. _currentDrag1: number;
  71785. /** @hidden */
  71786. _currentDrag2: number;
  71787. /** @hidden */
  71788. _randomNoiseCoordinates1: Vector3;
  71789. /** @hidden */
  71790. _randomNoiseCoordinates2: Vector3;
  71791. /**
  71792. * Creates a new instance Particle
  71793. * @param particleSystem the particle system the particle belongs to
  71794. */
  71795. constructor(
  71796. /**
  71797. * The particle system the particle belongs to.
  71798. */
  71799. particleSystem: ParticleSystem);
  71800. private updateCellInfoFromSystem;
  71801. /**
  71802. * Defines how the sprite cell index is updated for the particle
  71803. */
  71804. updateCellIndex(): void;
  71805. /** @hidden */
  71806. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71807. /** @hidden */
  71808. _inheritParticleInfoToSubEmitters(): void;
  71809. /** @hidden */
  71810. _reset(): void;
  71811. /**
  71812. * Copy the properties of particle to another one.
  71813. * @param other the particle to copy the information to.
  71814. */
  71815. copyTo(other: Particle): void;
  71816. }
  71817. }
  71818. declare module BABYLON {
  71819. /**
  71820. * Particle emitter represents a volume emitting particles.
  71821. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71822. */
  71823. export interface IParticleEmitterType {
  71824. /**
  71825. * Called by the particle System when the direction is computed for the created particle.
  71826. * @param worldMatrix is the world matrix of the particle system
  71827. * @param directionToUpdate is the direction vector to update with the result
  71828. * @param particle is the particle we are computed the direction for
  71829. */
  71830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71831. /**
  71832. * Called by the particle System when the position is computed for the created particle.
  71833. * @param worldMatrix is the world matrix of the particle system
  71834. * @param positionToUpdate is the position vector to update with the result
  71835. * @param particle is the particle we are computed the position for
  71836. */
  71837. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71838. /**
  71839. * Clones the current emitter and returns a copy of it
  71840. * @returns the new emitter
  71841. */
  71842. clone(): IParticleEmitterType;
  71843. /**
  71844. * Called by the GPUParticleSystem to setup the update shader
  71845. * @param effect defines the update shader
  71846. */
  71847. applyToShader(effect: Effect): void;
  71848. /**
  71849. * Returns a string to use to update the GPU particles update shader
  71850. * @returns the effect defines string
  71851. */
  71852. getEffectDefines(): string;
  71853. /**
  71854. * Returns a string representing the class name
  71855. * @returns a string containing the class name
  71856. */
  71857. getClassName(): string;
  71858. /**
  71859. * Serializes the particle system to a JSON object.
  71860. * @returns the JSON object
  71861. */
  71862. serialize(): any;
  71863. /**
  71864. * Parse properties from a JSON object
  71865. * @param serializationObject defines the JSON object
  71866. */
  71867. parse(serializationObject: any): void;
  71868. }
  71869. }
  71870. declare module BABYLON {
  71871. /**
  71872. * Particle emitter emitting particles from the inside of a box.
  71873. * It emits the particles randomly between 2 given directions.
  71874. */
  71875. export class BoxParticleEmitter implements IParticleEmitterType {
  71876. /**
  71877. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71878. */
  71879. direction1: Vector3;
  71880. /**
  71881. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71882. */
  71883. direction2: Vector3;
  71884. /**
  71885. * 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.
  71886. */
  71887. minEmitBox: Vector3;
  71888. /**
  71889. * 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.
  71890. */
  71891. maxEmitBox: Vector3;
  71892. /**
  71893. * Creates a new instance BoxParticleEmitter
  71894. */
  71895. constructor();
  71896. /**
  71897. * Called by the particle System when the direction is computed for the created particle.
  71898. * @param worldMatrix is the world matrix of the particle system
  71899. * @param directionToUpdate is the direction vector to update with the result
  71900. * @param particle is the particle we are computed the direction for
  71901. */
  71902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71903. /**
  71904. * Called by the particle System when the position is computed for the created particle.
  71905. * @param worldMatrix is the world matrix of the particle system
  71906. * @param positionToUpdate is the position vector to update with the result
  71907. * @param particle is the particle we are computed the position for
  71908. */
  71909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71910. /**
  71911. * Clones the current emitter and returns a copy of it
  71912. * @returns the new emitter
  71913. */
  71914. clone(): BoxParticleEmitter;
  71915. /**
  71916. * Called by the GPUParticleSystem to setup the update shader
  71917. * @param effect defines the update shader
  71918. */
  71919. applyToShader(effect: Effect): void;
  71920. /**
  71921. * Returns a string to use to update the GPU particles update shader
  71922. * @returns a string containng the defines string
  71923. */
  71924. getEffectDefines(): string;
  71925. /**
  71926. * Returns the string "BoxParticleEmitter"
  71927. * @returns a string containing the class name
  71928. */
  71929. getClassName(): string;
  71930. /**
  71931. * Serializes the particle system to a JSON object.
  71932. * @returns the JSON object
  71933. */
  71934. serialize(): any;
  71935. /**
  71936. * Parse properties from a JSON object
  71937. * @param serializationObject defines the JSON object
  71938. */
  71939. parse(serializationObject: any): void;
  71940. }
  71941. }
  71942. declare module BABYLON {
  71943. /**
  71944. * Particle emitter emitting particles from the inside of a cone.
  71945. * It emits the particles alongside the cone volume from the base to the particle.
  71946. * The emission direction might be randomized.
  71947. */
  71948. export class ConeParticleEmitter implements IParticleEmitterType {
  71949. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71950. directionRandomizer: number;
  71951. private _radius;
  71952. private _angle;
  71953. private _height;
  71954. /**
  71955. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71956. */
  71957. radiusRange: number;
  71958. /**
  71959. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71960. */
  71961. heightRange: number;
  71962. /**
  71963. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71964. */
  71965. emitFromSpawnPointOnly: boolean;
  71966. /**
  71967. * Gets or sets the radius of the emission cone
  71968. */
  71969. radius: number;
  71970. /**
  71971. * Gets or sets the angle of the emission cone
  71972. */
  71973. angle: number;
  71974. private _buildHeight;
  71975. /**
  71976. * Creates a new instance ConeParticleEmitter
  71977. * @param radius the radius of the emission cone (1 by default)
  71978. * @param angle the cone base angle (PI by default)
  71979. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71980. */
  71981. constructor(radius?: number, angle?: number,
  71982. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71983. directionRandomizer?: number);
  71984. /**
  71985. * Called by the particle System when the direction is computed for the created particle.
  71986. * @param worldMatrix is the world matrix of the particle system
  71987. * @param directionToUpdate is the direction vector to update with the result
  71988. * @param particle is the particle we are computed the direction for
  71989. */
  71990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71991. /**
  71992. * Called by the particle System when the position is computed for the created particle.
  71993. * @param worldMatrix is the world matrix of the particle system
  71994. * @param positionToUpdate is the position vector to update with the result
  71995. * @param particle is the particle we are computed the position for
  71996. */
  71997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71998. /**
  71999. * Clones the current emitter and returns a copy of it
  72000. * @returns the new emitter
  72001. */
  72002. clone(): ConeParticleEmitter;
  72003. /**
  72004. * Called by the GPUParticleSystem to setup the update shader
  72005. * @param effect defines the update shader
  72006. */
  72007. applyToShader(effect: Effect): void;
  72008. /**
  72009. * Returns a string to use to update the GPU particles update shader
  72010. * @returns a string containng the defines string
  72011. */
  72012. getEffectDefines(): string;
  72013. /**
  72014. * Returns the string "ConeParticleEmitter"
  72015. * @returns a string containing the class name
  72016. */
  72017. getClassName(): string;
  72018. /**
  72019. * Serializes the particle system to a JSON object.
  72020. * @returns the JSON object
  72021. */
  72022. serialize(): any;
  72023. /**
  72024. * Parse properties from a JSON object
  72025. * @param serializationObject defines the JSON object
  72026. */
  72027. parse(serializationObject: any): void;
  72028. }
  72029. }
  72030. declare module BABYLON {
  72031. /**
  72032. * Particle emitter emitting particles from the inside of a cylinder.
  72033. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72034. */
  72035. export class CylinderParticleEmitter implements IParticleEmitterType {
  72036. /**
  72037. * The radius of the emission cylinder.
  72038. */
  72039. radius: number;
  72040. /**
  72041. * The height of the emission cylinder.
  72042. */
  72043. height: number;
  72044. /**
  72045. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72046. */
  72047. radiusRange: number;
  72048. /**
  72049. * How much to randomize the particle direction [0-1].
  72050. */
  72051. directionRandomizer: number;
  72052. /**
  72053. * Creates a new instance CylinderParticleEmitter
  72054. * @param radius the radius of the emission cylinder (1 by default)
  72055. * @param height the height of the emission cylinder (1 by default)
  72056. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72057. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72058. */
  72059. constructor(
  72060. /**
  72061. * The radius of the emission cylinder.
  72062. */
  72063. radius?: number,
  72064. /**
  72065. * The height of the emission cylinder.
  72066. */
  72067. height?: number,
  72068. /**
  72069. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72070. */
  72071. radiusRange?: number,
  72072. /**
  72073. * How much to randomize the particle direction [0-1].
  72074. */
  72075. directionRandomizer?: number);
  72076. /**
  72077. * Called by the particle System when the direction is computed for the created particle.
  72078. * @param worldMatrix is the world matrix of the particle system
  72079. * @param directionToUpdate is the direction vector to update with the result
  72080. * @param particle is the particle we are computed the direction for
  72081. */
  72082. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72083. /**
  72084. * Called by the particle System when the position is computed for the created particle.
  72085. * @param worldMatrix is the world matrix of the particle system
  72086. * @param positionToUpdate is the position vector to update with the result
  72087. * @param particle is the particle we are computed the position for
  72088. */
  72089. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72090. /**
  72091. * Clones the current emitter and returns a copy of it
  72092. * @returns the new emitter
  72093. */
  72094. clone(): CylinderParticleEmitter;
  72095. /**
  72096. * Called by the GPUParticleSystem to setup the update shader
  72097. * @param effect defines the update shader
  72098. */
  72099. applyToShader(effect: Effect): void;
  72100. /**
  72101. * Returns a string to use to update the GPU particles update shader
  72102. * @returns a string containng the defines string
  72103. */
  72104. getEffectDefines(): string;
  72105. /**
  72106. * Returns the string "CylinderParticleEmitter"
  72107. * @returns a string containing the class name
  72108. */
  72109. getClassName(): string;
  72110. /**
  72111. * Serializes the particle system to a JSON object.
  72112. * @returns the JSON object
  72113. */
  72114. serialize(): any;
  72115. /**
  72116. * Parse properties from a JSON object
  72117. * @param serializationObject defines the JSON object
  72118. */
  72119. parse(serializationObject: any): void;
  72120. }
  72121. /**
  72122. * Particle emitter emitting particles from the inside of a cylinder.
  72123. * It emits the particles randomly between two vectors.
  72124. */
  72125. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72126. /**
  72127. * The min limit of the emission direction.
  72128. */
  72129. direction1: Vector3;
  72130. /**
  72131. * The max limit of the emission direction.
  72132. */
  72133. direction2: Vector3;
  72134. /**
  72135. * Creates a new instance CylinderDirectedParticleEmitter
  72136. * @param radius the radius of the emission cylinder (1 by default)
  72137. * @param height the height of the emission cylinder (1 by default)
  72138. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72139. * @param direction1 the min limit of the emission direction (up vector by default)
  72140. * @param direction2 the max limit of the emission direction (up vector by default)
  72141. */
  72142. constructor(radius?: number, height?: number, radiusRange?: number,
  72143. /**
  72144. * The min limit of the emission direction.
  72145. */
  72146. direction1?: Vector3,
  72147. /**
  72148. * The max limit of the emission direction.
  72149. */
  72150. direction2?: Vector3);
  72151. /**
  72152. * Called by the particle System when the direction is computed for the created particle.
  72153. * @param worldMatrix is the world matrix of the particle system
  72154. * @param directionToUpdate is the direction vector to update with the result
  72155. * @param particle is the particle we are computed the direction for
  72156. */
  72157. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72158. /**
  72159. * Clones the current emitter and returns a copy of it
  72160. * @returns the new emitter
  72161. */
  72162. clone(): CylinderDirectedParticleEmitter;
  72163. /**
  72164. * Called by the GPUParticleSystem to setup the update shader
  72165. * @param effect defines the update shader
  72166. */
  72167. applyToShader(effect: Effect): void;
  72168. /**
  72169. * Returns a string to use to update the GPU particles update shader
  72170. * @returns a string containng the defines string
  72171. */
  72172. getEffectDefines(): string;
  72173. /**
  72174. * Returns the string "CylinderDirectedParticleEmitter"
  72175. * @returns a string containing the class name
  72176. */
  72177. getClassName(): string;
  72178. /**
  72179. * Serializes the particle system to a JSON object.
  72180. * @returns the JSON object
  72181. */
  72182. serialize(): any;
  72183. /**
  72184. * Parse properties from a JSON object
  72185. * @param serializationObject defines the JSON object
  72186. */
  72187. parse(serializationObject: any): void;
  72188. }
  72189. }
  72190. declare module BABYLON {
  72191. /**
  72192. * Particle emitter emitting particles from the inside of a hemisphere.
  72193. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72194. */
  72195. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72196. /**
  72197. * The radius of the emission hemisphere.
  72198. */
  72199. radius: number;
  72200. /**
  72201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72202. */
  72203. radiusRange: number;
  72204. /**
  72205. * How much to randomize the particle direction [0-1].
  72206. */
  72207. directionRandomizer: number;
  72208. /**
  72209. * Creates a new instance HemisphericParticleEmitter
  72210. * @param radius the radius of the emission hemisphere (1 by default)
  72211. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72212. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72213. */
  72214. constructor(
  72215. /**
  72216. * The radius of the emission hemisphere.
  72217. */
  72218. radius?: number,
  72219. /**
  72220. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72221. */
  72222. radiusRange?: number,
  72223. /**
  72224. * How much to randomize the particle direction [0-1].
  72225. */
  72226. directionRandomizer?: number);
  72227. /**
  72228. * Called by the particle System when the direction is computed for the created particle.
  72229. * @param worldMatrix is the world matrix of the particle system
  72230. * @param directionToUpdate is the direction vector to update with the result
  72231. * @param particle is the particle we are computed the direction for
  72232. */
  72233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72234. /**
  72235. * Called by the particle System when the position is computed for the created particle.
  72236. * @param worldMatrix is the world matrix of the particle system
  72237. * @param positionToUpdate is the position vector to update with the result
  72238. * @param particle is the particle we are computed the position for
  72239. */
  72240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72241. /**
  72242. * Clones the current emitter and returns a copy of it
  72243. * @returns the new emitter
  72244. */
  72245. clone(): HemisphericParticleEmitter;
  72246. /**
  72247. * Called by the GPUParticleSystem to setup the update shader
  72248. * @param effect defines the update shader
  72249. */
  72250. applyToShader(effect: Effect): void;
  72251. /**
  72252. * Returns a string to use to update the GPU particles update shader
  72253. * @returns a string containng the defines string
  72254. */
  72255. getEffectDefines(): string;
  72256. /**
  72257. * Returns the string "HemisphericParticleEmitter"
  72258. * @returns a string containing the class name
  72259. */
  72260. getClassName(): string;
  72261. /**
  72262. * Serializes the particle system to a JSON object.
  72263. * @returns the JSON object
  72264. */
  72265. serialize(): any;
  72266. /**
  72267. * Parse properties from a JSON object
  72268. * @param serializationObject defines the JSON object
  72269. */
  72270. parse(serializationObject: any): void;
  72271. }
  72272. }
  72273. declare module BABYLON {
  72274. /**
  72275. * Particle emitter emitting particles from a point.
  72276. * It emits the particles randomly between 2 given directions.
  72277. */
  72278. export class PointParticleEmitter implements IParticleEmitterType {
  72279. /**
  72280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72281. */
  72282. direction1: Vector3;
  72283. /**
  72284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72285. */
  72286. direction2: Vector3;
  72287. /**
  72288. * Creates a new instance PointParticleEmitter
  72289. */
  72290. constructor();
  72291. /**
  72292. * Called by the particle System when the direction is computed for the created particle.
  72293. * @param worldMatrix is the world matrix of the particle system
  72294. * @param directionToUpdate is the direction vector to update with the result
  72295. * @param particle is the particle we are computed the direction for
  72296. */
  72297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72298. /**
  72299. * Called by the particle System when the position is computed for the created particle.
  72300. * @param worldMatrix is the world matrix of the particle system
  72301. * @param positionToUpdate is the position vector to update with the result
  72302. * @param particle is the particle we are computed the position for
  72303. */
  72304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72305. /**
  72306. * Clones the current emitter and returns a copy of it
  72307. * @returns the new emitter
  72308. */
  72309. clone(): PointParticleEmitter;
  72310. /**
  72311. * Called by the GPUParticleSystem to setup the update shader
  72312. * @param effect defines the update shader
  72313. */
  72314. applyToShader(effect: Effect): void;
  72315. /**
  72316. * Returns a string to use to update the GPU particles update shader
  72317. * @returns a string containng the defines string
  72318. */
  72319. getEffectDefines(): string;
  72320. /**
  72321. * Returns the string "PointParticleEmitter"
  72322. * @returns a string containing the class name
  72323. */
  72324. getClassName(): string;
  72325. /**
  72326. * Serializes the particle system to a JSON object.
  72327. * @returns the JSON object
  72328. */
  72329. serialize(): any;
  72330. /**
  72331. * Parse properties from a JSON object
  72332. * @param serializationObject defines the JSON object
  72333. */
  72334. parse(serializationObject: any): void;
  72335. }
  72336. }
  72337. declare module BABYLON {
  72338. /**
  72339. * Particle emitter emitting particles from the inside of a sphere.
  72340. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72341. */
  72342. export class SphereParticleEmitter implements IParticleEmitterType {
  72343. /**
  72344. * The radius of the emission sphere.
  72345. */
  72346. radius: number;
  72347. /**
  72348. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72349. */
  72350. radiusRange: number;
  72351. /**
  72352. * How much to randomize the particle direction [0-1].
  72353. */
  72354. directionRandomizer: number;
  72355. /**
  72356. * Creates a new instance SphereParticleEmitter
  72357. * @param radius the radius of the emission sphere (1 by default)
  72358. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72359. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72360. */
  72361. constructor(
  72362. /**
  72363. * The radius of the emission sphere.
  72364. */
  72365. radius?: number,
  72366. /**
  72367. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72368. */
  72369. radiusRange?: number,
  72370. /**
  72371. * How much to randomize the particle direction [0-1].
  72372. */
  72373. directionRandomizer?: number);
  72374. /**
  72375. * Called by the particle System when the direction is computed for the created particle.
  72376. * @param worldMatrix is the world matrix of the particle system
  72377. * @param directionToUpdate is the direction vector to update with the result
  72378. * @param particle is the particle we are computed the direction for
  72379. */
  72380. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72381. /**
  72382. * Called by the particle System when the position is computed for the created particle.
  72383. * @param worldMatrix is the world matrix of the particle system
  72384. * @param positionToUpdate is the position vector to update with the result
  72385. * @param particle is the particle we are computed the position for
  72386. */
  72387. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72388. /**
  72389. * Clones the current emitter and returns a copy of it
  72390. * @returns the new emitter
  72391. */
  72392. clone(): SphereParticleEmitter;
  72393. /**
  72394. * Called by the GPUParticleSystem to setup the update shader
  72395. * @param effect defines the update shader
  72396. */
  72397. applyToShader(effect: Effect): void;
  72398. /**
  72399. * Returns a string to use to update the GPU particles update shader
  72400. * @returns a string containng the defines string
  72401. */
  72402. getEffectDefines(): string;
  72403. /**
  72404. * Returns the string "SphereParticleEmitter"
  72405. * @returns a string containing the class name
  72406. */
  72407. getClassName(): string;
  72408. /**
  72409. * Serializes the particle system to a JSON object.
  72410. * @returns the JSON object
  72411. */
  72412. serialize(): any;
  72413. /**
  72414. * Parse properties from a JSON object
  72415. * @param serializationObject defines the JSON object
  72416. */
  72417. parse(serializationObject: any): void;
  72418. }
  72419. /**
  72420. * Particle emitter emitting particles from the inside of a sphere.
  72421. * It emits the particles randomly between two vectors.
  72422. */
  72423. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72424. /**
  72425. * The min limit of the emission direction.
  72426. */
  72427. direction1: Vector3;
  72428. /**
  72429. * The max limit of the emission direction.
  72430. */
  72431. direction2: Vector3;
  72432. /**
  72433. * Creates a new instance SphereDirectedParticleEmitter
  72434. * @param radius the radius of the emission sphere (1 by default)
  72435. * @param direction1 the min limit of the emission direction (up vector by default)
  72436. * @param direction2 the max limit of the emission direction (up vector by default)
  72437. */
  72438. constructor(radius?: number,
  72439. /**
  72440. * The min limit of the emission direction.
  72441. */
  72442. direction1?: Vector3,
  72443. /**
  72444. * The max limit of the emission direction.
  72445. */
  72446. direction2?: Vector3);
  72447. /**
  72448. * Called by the particle System when the direction is computed for the created particle.
  72449. * @param worldMatrix is the world matrix of the particle system
  72450. * @param directionToUpdate is the direction vector to update with the result
  72451. * @param particle is the particle we are computed the direction for
  72452. */
  72453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72454. /**
  72455. * Clones the current emitter and returns a copy of it
  72456. * @returns the new emitter
  72457. */
  72458. clone(): SphereDirectedParticleEmitter;
  72459. /**
  72460. * Called by the GPUParticleSystem to setup the update shader
  72461. * @param effect defines the update shader
  72462. */
  72463. applyToShader(effect: Effect): void;
  72464. /**
  72465. * Returns a string to use to update the GPU particles update shader
  72466. * @returns a string containng the defines string
  72467. */
  72468. getEffectDefines(): string;
  72469. /**
  72470. * Returns the string "SphereDirectedParticleEmitter"
  72471. * @returns a string containing the class name
  72472. */
  72473. getClassName(): string;
  72474. /**
  72475. * Serializes the particle system to a JSON object.
  72476. * @returns the JSON object
  72477. */
  72478. serialize(): any;
  72479. /**
  72480. * Parse properties from a JSON object
  72481. * @param serializationObject defines the JSON object
  72482. */
  72483. parse(serializationObject: any): void;
  72484. }
  72485. }
  72486. declare module BABYLON {
  72487. /**
  72488. * Interface representing a particle system in Babylon.js.
  72489. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72490. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72491. */
  72492. export interface IParticleSystem {
  72493. /**
  72494. * List of animations used by the particle system.
  72495. */
  72496. animations: Animation[];
  72497. /**
  72498. * The id of the Particle system.
  72499. */
  72500. id: string;
  72501. /**
  72502. * The name of the Particle system.
  72503. */
  72504. name: string;
  72505. /**
  72506. * The emitter represents the Mesh or position we are attaching the particle system to.
  72507. */
  72508. emitter: Nullable<AbstractMesh | Vector3>;
  72509. /**
  72510. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72511. */
  72512. isBillboardBased: boolean;
  72513. /**
  72514. * The rendering group used by the Particle system to chose when to render.
  72515. */
  72516. renderingGroupId: number;
  72517. /**
  72518. * The layer mask we are rendering the particles through.
  72519. */
  72520. layerMask: number;
  72521. /**
  72522. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72523. */
  72524. updateSpeed: number;
  72525. /**
  72526. * The amount of time the particle system is running (depends of the overall update speed).
  72527. */
  72528. targetStopDuration: number;
  72529. /**
  72530. * The texture used to render each particle. (this can be a spritesheet)
  72531. */
  72532. particleTexture: Nullable<Texture>;
  72533. /**
  72534. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72535. */
  72536. blendMode: number;
  72537. /**
  72538. * Minimum life time of emitting particles.
  72539. */
  72540. minLifeTime: number;
  72541. /**
  72542. * Maximum life time of emitting particles.
  72543. */
  72544. maxLifeTime: number;
  72545. /**
  72546. * Minimum Size of emitting particles.
  72547. */
  72548. minSize: number;
  72549. /**
  72550. * Maximum Size of emitting particles.
  72551. */
  72552. maxSize: number;
  72553. /**
  72554. * Minimum scale of emitting particles on X axis.
  72555. */
  72556. minScaleX: number;
  72557. /**
  72558. * Maximum scale of emitting particles on X axis.
  72559. */
  72560. maxScaleX: number;
  72561. /**
  72562. * Minimum scale of emitting particles on Y axis.
  72563. */
  72564. minScaleY: number;
  72565. /**
  72566. * Maximum scale of emitting particles on Y axis.
  72567. */
  72568. maxScaleY: number;
  72569. /**
  72570. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72571. */
  72572. color1: Color4;
  72573. /**
  72574. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72575. */
  72576. color2: Color4;
  72577. /**
  72578. * Color the particle will have at the end of its lifetime.
  72579. */
  72580. colorDead: Color4;
  72581. /**
  72582. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72583. */
  72584. emitRate: number;
  72585. /**
  72586. * You can use gravity if you want to give an orientation to your particles.
  72587. */
  72588. gravity: Vector3;
  72589. /**
  72590. * Minimum power of emitting particles.
  72591. */
  72592. minEmitPower: number;
  72593. /**
  72594. * Maximum power of emitting particles.
  72595. */
  72596. maxEmitPower: number;
  72597. /**
  72598. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72599. */
  72600. minAngularSpeed: number;
  72601. /**
  72602. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72603. */
  72604. maxAngularSpeed: number;
  72605. /**
  72606. * Gets or sets the minimal initial rotation in radians.
  72607. */
  72608. minInitialRotation: number;
  72609. /**
  72610. * Gets or sets the maximal initial rotation in radians.
  72611. */
  72612. maxInitialRotation: number;
  72613. /**
  72614. * The particle emitter type defines the emitter used by the particle system.
  72615. * It can be for example box, sphere, or cone...
  72616. */
  72617. particleEmitterType: Nullable<IParticleEmitterType>;
  72618. /**
  72619. * Defines the delay in milliseconds before starting the system (0 by default)
  72620. */
  72621. startDelay: number;
  72622. /**
  72623. * 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
  72624. */
  72625. preWarmCycles: number;
  72626. /**
  72627. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72628. */
  72629. preWarmStepOffset: number;
  72630. /**
  72631. * 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)
  72632. */
  72633. spriteCellChangeSpeed: number;
  72634. /**
  72635. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72636. */
  72637. startSpriteCellID: number;
  72638. /**
  72639. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72640. */
  72641. endSpriteCellID: number;
  72642. /**
  72643. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72644. */
  72645. spriteCellWidth: number;
  72646. /**
  72647. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72648. */
  72649. spriteCellHeight: number;
  72650. /**
  72651. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72652. */
  72653. spriteRandomStartCell: boolean;
  72654. /**
  72655. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72656. */
  72657. isAnimationSheetEnabled: boolean;
  72658. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72659. translationPivot: Vector2;
  72660. /**
  72661. * Gets or sets a texture used to add random noise to particle positions
  72662. */
  72663. noiseTexture: Nullable<BaseTexture>;
  72664. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72665. noiseStrength: Vector3;
  72666. /**
  72667. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72668. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72669. */
  72670. billboardMode: number;
  72671. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72672. limitVelocityDamping: number;
  72673. /**
  72674. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72675. */
  72676. beginAnimationOnStart: boolean;
  72677. /**
  72678. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72679. */
  72680. beginAnimationFrom: number;
  72681. /**
  72682. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72683. */
  72684. beginAnimationTo: number;
  72685. /**
  72686. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72687. */
  72688. beginAnimationLoop: boolean;
  72689. /**
  72690. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72691. */
  72692. disposeOnStop: boolean;
  72693. /**
  72694. * Gets the maximum number of particles active at the same time.
  72695. * @returns The max number of active particles.
  72696. */
  72697. getCapacity(): number;
  72698. /**
  72699. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72700. * @returns True if it has been started, otherwise false.
  72701. */
  72702. isStarted(): boolean;
  72703. /**
  72704. * Animates the particle system for this frame.
  72705. */
  72706. animate(): void;
  72707. /**
  72708. * Renders the particle system in its current state.
  72709. * @returns the current number of particles
  72710. */
  72711. render(): number;
  72712. /**
  72713. * Dispose the particle system and frees its associated resources.
  72714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72715. */
  72716. dispose(disposeTexture?: boolean): void;
  72717. /**
  72718. * Clones the particle system.
  72719. * @param name The name of the cloned object
  72720. * @param newEmitter The new emitter to use
  72721. * @returns the cloned particle system
  72722. */
  72723. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72724. /**
  72725. * Serializes the particle system to a JSON object.
  72726. * @returns the JSON object
  72727. */
  72728. serialize(): any;
  72729. /**
  72730. * Rebuild the particle system
  72731. */
  72732. rebuild(): void;
  72733. /**
  72734. * Starts the particle system and begins to emit
  72735. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72736. */
  72737. start(delay?: number): void;
  72738. /**
  72739. * Stops the particle system.
  72740. */
  72741. stop(): void;
  72742. /**
  72743. * Remove all active particles
  72744. */
  72745. reset(): void;
  72746. /**
  72747. * Is this system ready to be used/rendered
  72748. * @return true if the system is ready
  72749. */
  72750. isReady(): boolean;
  72751. /**
  72752. * Adds a new color gradient
  72753. * @param gradient defines the gradient to use (between 0 and 1)
  72754. * @param color1 defines the color to affect to the specified gradient
  72755. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72756. * @returns the current particle system
  72757. */
  72758. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72759. /**
  72760. * Remove a specific color gradient
  72761. * @param gradient defines the gradient to remove
  72762. * @returns the current particle system
  72763. */
  72764. removeColorGradient(gradient: number): IParticleSystem;
  72765. /**
  72766. * Adds a new size gradient
  72767. * @param gradient defines the gradient to use (between 0 and 1)
  72768. * @param factor defines the size factor to affect to the specified gradient
  72769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72770. * @returns the current particle system
  72771. */
  72772. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72773. /**
  72774. * Remove a specific size gradient
  72775. * @param gradient defines the gradient to remove
  72776. * @returns the current particle system
  72777. */
  72778. removeSizeGradient(gradient: number): IParticleSystem;
  72779. /**
  72780. * Gets the current list of color gradients.
  72781. * You must use addColorGradient and removeColorGradient to udpate this list
  72782. * @returns the list of color gradients
  72783. */
  72784. getColorGradients(): Nullable<Array<ColorGradient>>;
  72785. /**
  72786. * Gets the current list of size gradients.
  72787. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72788. * @returns the list of size gradients
  72789. */
  72790. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72791. /**
  72792. * Gets the current list of angular speed gradients.
  72793. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72794. * @returns the list of angular speed gradients
  72795. */
  72796. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72797. /**
  72798. * Adds a new angular speed gradient
  72799. * @param gradient defines the gradient to use (between 0 and 1)
  72800. * @param factor defines the angular speed to affect to the specified gradient
  72801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72802. * @returns the current particle system
  72803. */
  72804. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72805. /**
  72806. * Remove a specific angular speed gradient
  72807. * @param gradient defines the gradient to remove
  72808. * @returns the current particle system
  72809. */
  72810. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72811. /**
  72812. * Gets the current list of velocity gradients.
  72813. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72814. * @returns the list of velocity gradients
  72815. */
  72816. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72817. /**
  72818. * Adds a new velocity gradient
  72819. * @param gradient defines the gradient to use (between 0 and 1)
  72820. * @param factor defines the velocity to affect to the specified gradient
  72821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72822. * @returns the current particle system
  72823. */
  72824. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72825. /**
  72826. * Remove a specific velocity gradient
  72827. * @param gradient defines the gradient to remove
  72828. * @returns the current particle system
  72829. */
  72830. removeVelocityGradient(gradient: number): IParticleSystem;
  72831. /**
  72832. * Gets the current list of limit velocity gradients.
  72833. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72834. * @returns the list of limit velocity gradients
  72835. */
  72836. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72837. /**
  72838. * Adds a new limit velocity gradient
  72839. * @param gradient defines the gradient to use (between 0 and 1)
  72840. * @param factor defines the limit velocity to affect to the specified gradient
  72841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72842. * @returns the current particle system
  72843. */
  72844. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72845. /**
  72846. * Remove a specific limit velocity gradient
  72847. * @param gradient defines the gradient to remove
  72848. * @returns the current particle system
  72849. */
  72850. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72851. /**
  72852. * Adds a new drag gradient
  72853. * @param gradient defines the gradient to use (between 0 and 1)
  72854. * @param factor defines the drag to affect to the specified gradient
  72855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72856. * @returns the current particle system
  72857. */
  72858. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72859. /**
  72860. * Remove a specific drag gradient
  72861. * @param gradient defines the gradient to remove
  72862. * @returns the current particle system
  72863. */
  72864. removeDragGradient(gradient: number): IParticleSystem;
  72865. /**
  72866. * Gets the current list of drag gradients.
  72867. * You must use addDragGradient and removeDragGradient to udpate this list
  72868. * @returns the list of drag gradients
  72869. */
  72870. getDragGradients(): Nullable<Array<FactorGradient>>;
  72871. /**
  72872. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72873. * @param gradient defines the gradient to use (between 0 and 1)
  72874. * @param factor defines the emit rate to affect to the specified gradient
  72875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72876. * @returns the current particle system
  72877. */
  72878. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72879. /**
  72880. * Remove a specific emit rate gradient
  72881. * @param gradient defines the gradient to remove
  72882. * @returns the current particle system
  72883. */
  72884. removeEmitRateGradient(gradient: number): IParticleSystem;
  72885. /**
  72886. * Gets the current list of emit rate gradients.
  72887. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72888. * @returns the list of emit rate gradients
  72889. */
  72890. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72891. /**
  72892. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72893. * @param gradient defines the gradient to use (between 0 and 1)
  72894. * @param factor defines the start size to affect to the specified gradient
  72895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72896. * @returns the current particle system
  72897. */
  72898. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72899. /**
  72900. * Remove a specific start size gradient
  72901. * @param gradient defines the gradient to remove
  72902. * @returns the current particle system
  72903. */
  72904. removeStartSizeGradient(gradient: number): IParticleSystem;
  72905. /**
  72906. * Gets the current list of start size gradients.
  72907. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72908. * @returns the list of start size gradients
  72909. */
  72910. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72911. /**
  72912. * Adds a new life time gradient
  72913. * @param gradient defines the gradient to use (between 0 and 1)
  72914. * @param factor defines the life time factor to affect to the specified gradient
  72915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72916. * @returns the current particle system
  72917. */
  72918. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72919. /**
  72920. * Remove a specific life time gradient
  72921. * @param gradient defines the gradient to remove
  72922. * @returns the current particle system
  72923. */
  72924. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72925. /**
  72926. * Gets the current list of life time gradients.
  72927. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72928. * @returns the list of life time gradients
  72929. */
  72930. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72931. /**
  72932. * Gets the current list of color gradients.
  72933. * You must use addColorGradient and removeColorGradient to udpate this list
  72934. * @returns the list of color gradients
  72935. */
  72936. getColorGradients(): Nullable<Array<ColorGradient>>;
  72937. /**
  72938. * Adds a new ramp gradient used to remap particle colors
  72939. * @param gradient defines the gradient to use (between 0 and 1)
  72940. * @param color defines the color to affect to the specified gradient
  72941. * @returns the current particle system
  72942. */
  72943. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72944. /**
  72945. * Gets the current list of ramp gradients.
  72946. * You must use addRampGradient and removeRampGradient to udpate this list
  72947. * @returns the list of ramp gradients
  72948. */
  72949. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72950. /** Gets or sets a boolean indicating that ramp gradients must be used
  72951. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72952. */
  72953. useRampGradients: boolean;
  72954. /**
  72955. * Adds a new color remap gradient
  72956. * @param gradient defines the gradient to use (between 0 and 1)
  72957. * @param min defines the color remap minimal range
  72958. * @param max defines the color remap maximal range
  72959. * @returns the current particle system
  72960. */
  72961. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72962. /**
  72963. * Gets the current list of color remap gradients.
  72964. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72965. * @returns the list of color remap gradients
  72966. */
  72967. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72968. /**
  72969. * Adds a new alpha remap gradient
  72970. * @param gradient defines the gradient to use (between 0 and 1)
  72971. * @param min defines the alpha remap minimal range
  72972. * @param max defines the alpha remap maximal range
  72973. * @returns the current particle system
  72974. */
  72975. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72976. /**
  72977. * Gets the current list of alpha remap gradients.
  72978. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72979. * @returns the list of alpha remap gradients
  72980. */
  72981. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72982. /**
  72983. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72986. * @returns the emitter
  72987. */
  72988. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72989. /**
  72990. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72991. * @param radius The radius of the hemisphere to emit from
  72992. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72993. * @returns the emitter
  72994. */
  72995. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  72996. /**
  72997. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72998. * @param radius The radius of the sphere to emit from
  72999. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73000. * @returns the emitter
  73001. */
  73002. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73003. /**
  73004. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73005. * @param radius The radius of the sphere to emit from
  73006. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73007. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73008. * @returns the emitter
  73009. */
  73010. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73011. /**
  73012. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73013. * @param radius The radius of the emission cylinder
  73014. * @param height The height of the emission cylinder
  73015. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73016. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73017. * @returns the emitter
  73018. */
  73019. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73020. /**
  73021. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73022. * @param radius The radius of the cylinder to emit from
  73023. * @param height The height of the emission cylinder
  73024. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73025. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73026. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73027. * @returns the emitter
  73028. */
  73029. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73030. /**
  73031. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73032. * @param radius The radius of the cone to emit from
  73033. * @param angle The base angle of the cone
  73034. * @returns the emitter
  73035. */
  73036. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73037. /**
  73038. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73039. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73040. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73041. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73042. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73043. * @returns the emitter
  73044. */
  73045. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73046. /**
  73047. * Get hosting scene
  73048. * @returns the scene
  73049. */
  73050. getScene(): Scene;
  73051. }
  73052. }
  73053. declare module BABYLON {
  73054. /**
  73055. * Creates an instance based on a source mesh.
  73056. */
  73057. export class InstancedMesh extends AbstractMesh {
  73058. private _sourceMesh;
  73059. private _currentLOD;
  73060. /** @hidden */
  73061. _indexInSourceMeshInstanceArray: number;
  73062. constructor(name: string, source: Mesh);
  73063. /**
  73064. * Returns the string "InstancedMesh".
  73065. */
  73066. getClassName(): string;
  73067. /**
  73068. * If the source mesh receives shadows
  73069. */
  73070. readonly receiveShadows: boolean;
  73071. /**
  73072. * The material of the source mesh
  73073. */
  73074. readonly material: Nullable<Material>;
  73075. /**
  73076. * Visibility of the source mesh
  73077. */
  73078. readonly visibility: number;
  73079. /**
  73080. * Skeleton of the source mesh
  73081. */
  73082. readonly skeleton: Nullable<Skeleton>;
  73083. /**
  73084. * Rendering ground id of the source mesh
  73085. */
  73086. renderingGroupId: number;
  73087. /**
  73088. * Returns the total number of vertices (integer).
  73089. */
  73090. getTotalVertices(): number;
  73091. /**
  73092. * Returns a positive integer : the total number of indices in this mesh geometry.
  73093. * @returns the numner of indices or zero if the mesh has no geometry.
  73094. */
  73095. getTotalIndices(): number;
  73096. /**
  73097. * The source mesh of the instance
  73098. */
  73099. readonly sourceMesh: Mesh;
  73100. /**
  73101. * Is this node ready to be used/rendered
  73102. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73103. * @return {boolean} is it ready
  73104. */
  73105. isReady(completeCheck?: boolean): boolean;
  73106. /**
  73107. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73108. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73109. * @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.
  73110. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73111. */
  73112. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73113. /**
  73114. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73115. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73116. * The `data` are either a numeric array either a Float32Array.
  73117. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73118. * 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).
  73119. * Note that a new underlying VertexBuffer object is created each call.
  73120. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73121. *
  73122. * Possible `kind` values :
  73123. * - VertexBuffer.PositionKind
  73124. * - VertexBuffer.UVKind
  73125. * - VertexBuffer.UV2Kind
  73126. * - VertexBuffer.UV3Kind
  73127. * - VertexBuffer.UV4Kind
  73128. * - VertexBuffer.UV5Kind
  73129. * - VertexBuffer.UV6Kind
  73130. * - VertexBuffer.ColorKind
  73131. * - VertexBuffer.MatricesIndicesKind
  73132. * - VertexBuffer.MatricesIndicesExtraKind
  73133. * - VertexBuffer.MatricesWeightsKind
  73134. * - VertexBuffer.MatricesWeightsExtraKind
  73135. *
  73136. * Returns the Mesh.
  73137. */
  73138. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73139. /**
  73140. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73141. * If the mesh has no geometry, it is simply returned as it is.
  73142. * The `data` are either a numeric array either a Float32Array.
  73143. * No new underlying VertexBuffer object is created.
  73144. * 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.
  73145. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73146. *
  73147. * Possible `kind` values :
  73148. * - VertexBuffer.PositionKind
  73149. * - VertexBuffer.UVKind
  73150. * - VertexBuffer.UV2Kind
  73151. * - VertexBuffer.UV3Kind
  73152. * - VertexBuffer.UV4Kind
  73153. * - VertexBuffer.UV5Kind
  73154. * - VertexBuffer.UV6Kind
  73155. * - VertexBuffer.ColorKind
  73156. * - VertexBuffer.MatricesIndicesKind
  73157. * - VertexBuffer.MatricesIndicesExtraKind
  73158. * - VertexBuffer.MatricesWeightsKind
  73159. * - VertexBuffer.MatricesWeightsExtraKind
  73160. *
  73161. * Returns the Mesh.
  73162. */
  73163. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73164. /**
  73165. * Sets the mesh indices.
  73166. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73167. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73168. * This method creates a new index buffer each call.
  73169. * Returns the Mesh.
  73170. */
  73171. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73172. /**
  73173. * Boolean : True if the mesh owns the requested kind of data.
  73174. */
  73175. isVerticesDataPresent(kind: string): boolean;
  73176. /**
  73177. * Returns an array of indices (IndicesArray).
  73178. */
  73179. getIndices(): Nullable<IndicesArray>;
  73180. readonly _positions: Nullable<Vector3[]>;
  73181. /**
  73182. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73183. * This means the mesh underlying bounding box and sphere are recomputed.
  73184. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73185. * @returns the current mesh
  73186. */
  73187. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73188. /** @hidden */
  73189. _preActivate(): InstancedMesh;
  73190. /** @hidden */
  73191. _activate(renderId: number): InstancedMesh;
  73192. /**
  73193. * Returns the current associated LOD AbstractMesh.
  73194. */
  73195. getLOD(camera: Camera): AbstractMesh;
  73196. /** @hidden */
  73197. _syncSubMeshes(): InstancedMesh;
  73198. /** @hidden */
  73199. _generatePointsArray(): boolean;
  73200. /**
  73201. * Creates a new InstancedMesh from the current mesh.
  73202. * - name (string) : the cloned mesh name
  73203. * - newParent (optional Node) : the optional Node to parent the clone to.
  73204. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73205. *
  73206. * Returns the clone.
  73207. */
  73208. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73209. /**
  73210. * Disposes the InstancedMesh.
  73211. * Returns nothing.
  73212. */
  73213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73214. }
  73215. }
  73216. declare module BABYLON {
  73217. /**
  73218. * Defines the options associated with the creation of a shader material.
  73219. */
  73220. export interface IShaderMaterialOptions {
  73221. /**
  73222. * Does the material work in alpha blend mode
  73223. */
  73224. needAlphaBlending: boolean;
  73225. /**
  73226. * Does the material work in alpha test mode
  73227. */
  73228. needAlphaTesting: boolean;
  73229. /**
  73230. * The list of attribute names used in the shader
  73231. */
  73232. attributes: string[];
  73233. /**
  73234. * The list of unifrom names used in the shader
  73235. */
  73236. uniforms: string[];
  73237. /**
  73238. * The list of UBO names used in the shader
  73239. */
  73240. uniformBuffers: string[];
  73241. /**
  73242. * The list of sampler names used in the shader
  73243. */
  73244. samplers: string[];
  73245. /**
  73246. * The list of defines used in the shader
  73247. */
  73248. defines: string[];
  73249. }
  73250. /**
  73251. * 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.
  73252. *
  73253. * This returned material effects how the mesh will look based on the code in the shaders.
  73254. *
  73255. * @see http://doc.babylonjs.com/how_to/shader_material
  73256. */
  73257. export class ShaderMaterial extends Material {
  73258. private _shaderPath;
  73259. private _options;
  73260. private _textures;
  73261. private _textureArrays;
  73262. private _floats;
  73263. private _ints;
  73264. private _floatsArrays;
  73265. private _colors3;
  73266. private _colors3Arrays;
  73267. private _colors4;
  73268. private _vectors2;
  73269. private _vectors3;
  73270. private _vectors4;
  73271. private _matrices;
  73272. private _matrices3x3;
  73273. private _matrices2x2;
  73274. private _vectors2Arrays;
  73275. private _vectors3Arrays;
  73276. private _cachedWorldViewMatrix;
  73277. private _renderId;
  73278. /**
  73279. * Instantiate a new shader material.
  73280. * 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.
  73281. * This returned material effects how the mesh will look based on the code in the shaders.
  73282. * @see http://doc.babylonjs.com/how_to/shader_material
  73283. * @param name Define the name of the material in the scene
  73284. * @param scene Define the scene the material belongs to
  73285. * @param shaderPath Defines the route to the shader code in one of three ways:
  73286. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73287. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73288. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73289. * @param options Define the options used to create the shader
  73290. */
  73291. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73292. /**
  73293. * Gets the current class name of the material e.g. "ShaderMaterial"
  73294. * Mainly use in serialization.
  73295. * @returns the class name
  73296. */
  73297. getClassName(): string;
  73298. /**
  73299. * Specifies if the material will require alpha blending
  73300. * @returns a boolean specifying if alpha blending is needed
  73301. */
  73302. needAlphaBlending(): boolean;
  73303. /**
  73304. * Specifies if this material should be rendered in alpha test mode
  73305. * @returns a boolean specifying if an alpha test is needed.
  73306. */
  73307. needAlphaTesting(): boolean;
  73308. private _checkUniform;
  73309. /**
  73310. * Set a texture in the shader.
  73311. * @param name Define the name of the uniform samplers as defined in the shader
  73312. * @param texture Define the texture to bind to this sampler
  73313. * @return the material itself allowing "fluent" like uniform updates
  73314. */
  73315. setTexture(name: string, texture: Texture): ShaderMaterial;
  73316. /**
  73317. * Set a texture array in the shader.
  73318. * @param name Define the name of the uniform sampler array as defined in the shader
  73319. * @param textures Define the list of textures to bind to this sampler
  73320. * @return the material itself allowing "fluent" like uniform updates
  73321. */
  73322. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73323. /**
  73324. * Set a float in the shader.
  73325. * @param name Define the name of the uniform as defined in the shader
  73326. * @param value Define the value to give to the uniform
  73327. * @return the material itself allowing "fluent" like uniform updates
  73328. */
  73329. setFloat(name: string, value: number): ShaderMaterial;
  73330. /**
  73331. * Set a int in the shader.
  73332. * @param name Define the name of the uniform as defined in the shader
  73333. * @param value Define the value to give to the uniform
  73334. * @return the material itself allowing "fluent" like uniform updates
  73335. */
  73336. setInt(name: string, value: number): ShaderMaterial;
  73337. /**
  73338. * Set an array of floats in the shader.
  73339. * @param name Define the name of the uniform as defined in the shader
  73340. * @param value Define the value to give to the uniform
  73341. * @return the material itself allowing "fluent" like uniform updates
  73342. */
  73343. setFloats(name: string, value: number[]): ShaderMaterial;
  73344. /**
  73345. * Set a vec3 in the shader from a Color3.
  73346. * @param name Define the name of the uniform as defined in the shader
  73347. * @param value Define the value to give to the uniform
  73348. * @return the material itself allowing "fluent" like uniform updates
  73349. */
  73350. setColor3(name: string, value: Color3): ShaderMaterial;
  73351. /**
  73352. * Set a vec3 array in the shader from a Color3 array.
  73353. * @param name Define the name of the uniform as defined in the shader
  73354. * @param value Define the value to give to the uniform
  73355. * @return the material itself allowing "fluent" like uniform updates
  73356. */
  73357. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73358. /**
  73359. * Set a vec4 in the shader from a Color4.
  73360. * @param name Define the name of the uniform as defined in the shader
  73361. * @param value Define the value to give to the uniform
  73362. * @return the material itself allowing "fluent" like uniform updates
  73363. */
  73364. setColor4(name: string, value: Color4): ShaderMaterial;
  73365. /**
  73366. * Set a vec2 in the shader from a Vector2.
  73367. * @param name Define the name of the uniform as defined in the shader
  73368. * @param value Define the value to give to the uniform
  73369. * @return the material itself allowing "fluent" like uniform updates
  73370. */
  73371. setVector2(name: string, value: Vector2): ShaderMaterial;
  73372. /**
  73373. * Set a vec3 in the shader from a Vector3.
  73374. * @param name Define the name of the uniform as defined in the shader
  73375. * @param value Define the value to give to the uniform
  73376. * @return the material itself allowing "fluent" like uniform updates
  73377. */
  73378. setVector3(name: string, value: Vector3): ShaderMaterial;
  73379. /**
  73380. * Set a vec4 in the shader from a Vector4.
  73381. * @param name Define the name of the uniform as defined in the shader
  73382. * @param value Define the value to give to the uniform
  73383. * @return the material itself allowing "fluent" like uniform updates
  73384. */
  73385. setVector4(name: string, value: Vector4): ShaderMaterial;
  73386. /**
  73387. * Set a mat4 in the shader from a Matrix.
  73388. * @param name Define the name of the uniform as defined in the shader
  73389. * @param value Define the value to give to the uniform
  73390. * @return the material itself allowing "fluent" like uniform updates
  73391. */
  73392. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73393. /**
  73394. * Set a mat3 in the shader from a Float32Array.
  73395. * @param name Define the name of the uniform as defined in the shader
  73396. * @param value Define the value to give to the uniform
  73397. * @return the material itself allowing "fluent" like uniform updates
  73398. */
  73399. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73400. /**
  73401. * Set a mat2 in the shader from a Float32Array.
  73402. * @param name Define the name of the uniform as defined in the shader
  73403. * @param value Define the value to give to the uniform
  73404. * @return the material itself allowing "fluent" like uniform updates
  73405. */
  73406. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73407. /**
  73408. * Set a vec2 array in the shader from a number array.
  73409. * @param name Define the name of the uniform as defined in the shader
  73410. * @param value Define the value to give to the uniform
  73411. * @return the material itself allowing "fluent" like uniform updates
  73412. */
  73413. setArray2(name: string, value: number[]): ShaderMaterial;
  73414. /**
  73415. * Set a vec3 array in the shader from a number array.
  73416. * @param name Define the name of the uniform as defined in the shader
  73417. * @param value Define the value to give to the uniform
  73418. * @return the material itself allowing "fluent" like uniform updates
  73419. */
  73420. setArray3(name: string, value: number[]): ShaderMaterial;
  73421. private _checkCache;
  73422. /**
  73423. * Checks if the material is ready to render the requested mesh
  73424. * @param mesh Define the mesh to render
  73425. * @param useInstances Define whether or not the material is used with instances
  73426. * @returns true if ready, otherwise false
  73427. */
  73428. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73429. /**
  73430. * Binds the world matrix to the material
  73431. * @param world defines the world transformation matrix
  73432. */
  73433. bindOnlyWorldMatrix(world: Matrix): void;
  73434. /**
  73435. * Binds the material to the mesh
  73436. * @param world defines the world transformation matrix
  73437. * @param mesh defines the mesh to bind the material to
  73438. */
  73439. bind(world: Matrix, mesh?: Mesh): void;
  73440. /**
  73441. * Gets the active textures from the material
  73442. * @returns an array of textures
  73443. */
  73444. getActiveTextures(): BaseTexture[];
  73445. /**
  73446. * Specifies if the material uses a texture
  73447. * @param texture defines the texture to check against the material
  73448. * @returns a boolean specifying if the material uses the texture
  73449. */
  73450. hasTexture(texture: BaseTexture): boolean;
  73451. /**
  73452. * Makes a duplicate of the material, and gives it a new name
  73453. * @param name defines the new name for the duplicated material
  73454. * @returns the cloned material
  73455. */
  73456. clone(name: string): ShaderMaterial;
  73457. /**
  73458. * Disposes the material
  73459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73461. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73462. */
  73463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73464. /**
  73465. * Serializes this material in a JSON representation
  73466. * @returns the serialized material object
  73467. */
  73468. serialize(): any;
  73469. /**
  73470. * Creates a shader material from parsed shader material data
  73471. * @param source defines the JSON represnetation of the material
  73472. * @param scene defines the hosting scene
  73473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73474. * @returns a new material
  73475. */
  73476. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73477. }
  73478. }
  73479. declare module BABYLON {
  73480. /** @hidden */
  73481. export var colorPixelShader: {
  73482. name: string;
  73483. shader: string;
  73484. };
  73485. }
  73486. declare module BABYLON {
  73487. /** @hidden */
  73488. export var colorVertexShader: {
  73489. name: string;
  73490. shader: string;
  73491. };
  73492. }
  73493. declare module BABYLON {
  73494. /**
  73495. * Line mesh
  73496. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  73497. */
  73498. export class LinesMesh extends Mesh {
  73499. /**
  73500. * If vertex color should be applied to the mesh
  73501. */
  73502. useVertexColor?: boolean | undefined;
  73503. /**
  73504. * If vertex alpha should be applied to the mesh
  73505. */
  73506. useVertexAlpha?: boolean | undefined;
  73507. /**
  73508. * Color of the line (Default: White)
  73509. */
  73510. color: Color3;
  73511. /**
  73512. * Alpha of the line (Default: 1)
  73513. */
  73514. alpha: number;
  73515. /**
  73516. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73517. * This margin is expressed in world space coordinates, so its value may vary.
  73518. * Default value is 0.1
  73519. */
  73520. intersectionThreshold: number;
  73521. private _colorShader;
  73522. /**
  73523. * Creates a new LinesMesh
  73524. * @param name defines the name
  73525. * @param scene defines the hosting scene
  73526. * @param parent defines the parent mesh if any
  73527. * @param source defines the optional source LinesMesh used to clone data from
  73528. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  73529. * When false, achieved by calling a clone(), also passing False.
  73530. * This will make creation of children, recursive.
  73531. * @param useVertexColor defines if this LinesMesh supports vertex color
  73532. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  73533. */
  73534. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  73535. /**
  73536. * If vertex color should be applied to the mesh
  73537. */
  73538. useVertexColor?: boolean | undefined,
  73539. /**
  73540. * If vertex alpha should be applied to the mesh
  73541. */
  73542. useVertexAlpha?: boolean | undefined);
  73543. /**
  73544. * Returns the string "LineMesh"
  73545. */
  73546. getClassName(): string;
  73547. /**
  73548. * @hidden
  73549. */
  73550. /**
  73551. * @hidden
  73552. */
  73553. material: Material;
  73554. /**
  73555. * @hidden
  73556. */
  73557. readonly checkCollisions: boolean;
  73558. /** @hidden */
  73559. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  73560. /** @hidden */
  73561. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  73562. /**
  73563. * Disposes of the line mesh
  73564. * @param doNotRecurse If children should be disposed
  73565. */
  73566. dispose(doNotRecurse?: boolean): void;
  73567. /**
  73568. * Returns a new LineMesh object cloned from the current one.
  73569. */
  73570. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  73571. /**
  73572. * Creates a new InstancedLinesMesh object from the mesh model.
  73573. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  73574. * @param name defines the name of the new instance
  73575. * @returns a new InstancedLinesMesh
  73576. */
  73577. createInstance(name: string): InstancedLinesMesh;
  73578. }
  73579. /**
  73580. * Creates an instance based on a source LinesMesh
  73581. */
  73582. export class InstancedLinesMesh extends InstancedMesh {
  73583. /**
  73584. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73585. * This margin is expressed in world space coordinates, so its value may vary.
  73586. * Initilized with the intersectionThreshold value of the source LinesMesh
  73587. */
  73588. intersectionThreshold: number;
  73589. constructor(name: string, source: LinesMesh);
  73590. /**
  73591. * Returns the string "InstancedLinesMesh".
  73592. */
  73593. getClassName(): string;
  73594. }
  73595. }
  73596. declare module BABYLON {
  73597. /** @hidden */
  73598. export var linePixelShader: {
  73599. name: string;
  73600. shader: string;
  73601. };
  73602. }
  73603. declare module BABYLON {
  73604. /** @hidden */
  73605. export var lineVertexShader: {
  73606. name: string;
  73607. shader: string;
  73608. };
  73609. }
  73610. declare module BABYLON {
  73611. interface AbstractMesh {
  73612. /**
  73613. * Disables the mesh edge rendering mode
  73614. * @returns the currentAbstractMesh
  73615. */
  73616. disableEdgesRendering(): AbstractMesh;
  73617. /**
  73618. * Enables the edge rendering mode on the mesh.
  73619. * This mode makes the mesh edges visible
  73620. * @param epsilon defines the maximal distance between two angles to detect a face
  73621. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73622. * @returns the currentAbstractMesh
  73623. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73624. */
  73625. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73626. /**
  73627. * Gets the edgesRenderer associated with the mesh
  73628. */
  73629. edgesRenderer: Nullable<EdgesRenderer>;
  73630. }
  73631. interface LinesMesh {
  73632. /**
  73633. * Enables the edge rendering mode on the mesh.
  73634. * This mode makes the mesh edges visible
  73635. * @param epsilon defines the maximal distance between two angles to detect a face
  73636. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73637. * @returns the currentAbstractMesh
  73638. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73639. */
  73640. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73641. }
  73642. interface InstancedLinesMesh {
  73643. /**
  73644. * Enables the edge rendering mode on the mesh.
  73645. * This mode makes the mesh edges visible
  73646. * @param epsilon defines the maximal distance between two angles to detect a face
  73647. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73648. * @returns the current InstancedLinesMesh
  73649. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73650. */
  73651. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73652. }
  73653. /**
  73654. * Defines the minimum contract an Edges renderer should follow.
  73655. */
  73656. export interface IEdgesRenderer extends IDisposable {
  73657. /**
  73658. * Gets or sets a boolean indicating if the edgesRenderer is active
  73659. */
  73660. isEnabled: boolean;
  73661. /**
  73662. * Renders the edges of the attached mesh,
  73663. */
  73664. render(): void;
  73665. /**
  73666. * Checks wether or not the edges renderer is ready to render.
  73667. * @return true if ready, otherwise false.
  73668. */
  73669. isReady(): boolean;
  73670. }
  73671. /**
  73672. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73673. */
  73674. export class EdgesRenderer implements IEdgesRenderer {
  73675. /**
  73676. * Define the size of the edges with an orthographic camera
  73677. */
  73678. edgesWidthScalerForOrthographic: number;
  73679. /**
  73680. * Define the size of the edges with a perspective camera
  73681. */
  73682. edgesWidthScalerForPerspective: number;
  73683. protected _source: AbstractMesh;
  73684. protected _linesPositions: number[];
  73685. protected _linesNormals: number[];
  73686. protected _linesIndices: number[];
  73687. protected _epsilon: number;
  73688. protected _indicesCount: number;
  73689. protected _lineShader: ShaderMaterial;
  73690. protected _ib: WebGLBuffer;
  73691. protected _buffers: {
  73692. [key: string]: Nullable<VertexBuffer>;
  73693. };
  73694. protected _checkVerticesInsteadOfIndices: boolean;
  73695. private _meshRebuildObserver;
  73696. private _meshDisposeObserver;
  73697. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73698. isEnabled: boolean;
  73699. /**
  73700. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73701. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73702. * @param source Mesh used to create edges
  73703. * @param epsilon sum of angles in adjacency to check for edge
  73704. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73705. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73706. */
  73707. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73708. protected _prepareRessources(): void;
  73709. /** @hidden */
  73710. _rebuild(): void;
  73711. /**
  73712. * Releases the required resources for the edges renderer
  73713. */
  73714. dispose(): void;
  73715. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73716. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73717. /**
  73718. * Checks if the pair of p0 and p1 is en edge
  73719. * @param faceIndex
  73720. * @param edge
  73721. * @param faceNormals
  73722. * @param p0
  73723. * @param p1
  73724. * @private
  73725. */
  73726. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73727. /**
  73728. * push line into the position, normal and index buffer
  73729. * @protected
  73730. */
  73731. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73732. /**
  73733. * Generates lines edges from adjacencjes
  73734. * @private
  73735. */
  73736. _generateEdgesLines(): void;
  73737. /**
  73738. * Checks wether or not the edges renderer is ready to render.
  73739. * @return true if ready, otherwise false.
  73740. */
  73741. isReady(): boolean;
  73742. /**
  73743. * Renders the edges of the attached mesh,
  73744. */
  73745. render(): void;
  73746. }
  73747. /**
  73748. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73749. */
  73750. export class LineEdgesRenderer extends EdgesRenderer {
  73751. /**
  73752. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73753. * @param source LineMesh used to generate edges
  73754. * @param epsilon not important (specified angle for edge detection)
  73755. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73756. */
  73757. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73758. /**
  73759. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73760. */
  73761. _generateEdgesLines(): void;
  73762. }
  73763. }
  73764. declare module BABYLON {
  73765. /**
  73766. * This represents the object necessary to create a rendering group.
  73767. * This is exclusively used and created by the rendering manager.
  73768. * To modify the behavior, you use the available helpers in your scene or meshes.
  73769. * @hidden
  73770. */
  73771. export class RenderingGroup {
  73772. index: number;
  73773. private _scene;
  73774. private _opaqueSubMeshes;
  73775. private _transparentSubMeshes;
  73776. private _alphaTestSubMeshes;
  73777. private _depthOnlySubMeshes;
  73778. private _particleSystems;
  73779. private _spriteManagers;
  73780. private _opaqueSortCompareFn;
  73781. private _alphaTestSortCompareFn;
  73782. private _transparentSortCompareFn;
  73783. private _renderOpaque;
  73784. private _renderAlphaTest;
  73785. private _renderTransparent;
  73786. private _edgesRenderers;
  73787. onBeforeTransparentRendering: () => void;
  73788. /**
  73789. * Set the opaque sort comparison function.
  73790. * If null the sub meshes will be render in the order they were created
  73791. */
  73792. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73793. /**
  73794. * Set the alpha test sort comparison function.
  73795. * If null the sub meshes will be render in the order they were created
  73796. */
  73797. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73798. /**
  73799. * Set the transparent sort comparison function.
  73800. * If null the sub meshes will be render in the order they were created
  73801. */
  73802. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73803. /**
  73804. * Creates a new rendering group.
  73805. * @param index The rendering group index
  73806. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73807. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73808. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73809. */
  73810. 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>);
  73811. /**
  73812. * Render all the sub meshes contained in the group.
  73813. * @param customRenderFunction Used to override the default render behaviour of the group.
  73814. * @returns true if rendered some submeshes.
  73815. */
  73816. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73817. /**
  73818. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73819. * @param subMeshes The submeshes to render
  73820. */
  73821. private renderOpaqueSorted;
  73822. /**
  73823. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73824. * @param subMeshes The submeshes to render
  73825. */
  73826. private renderAlphaTestSorted;
  73827. /**
  73828. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73829. * @param subMeshes The submeshes to render
  73830. */
  73831. private renderTransparentSorted;
  73832. /**
  73833. * Renders the submeshes in a specified order.
  73834. * @param subMeshes The submeshes to sort before render
  73835. * @param sortCompareFn The comparison function use to sort
  73836. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73837. * @param transparent Specifies to activate blending if true
  73838. */
  73839. private static renderSorted;
  73840. /**
  73841. * Renders the submeshes in the order they were dispatched (no sort applied).
  73842. * @param subMeshes The submeshes to render
  73843. */
  73844. private static renderUnsorted;
  73845. /**
  73846. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73847. * are rendered back to front if in the same alpha index.
  73848. *
  73849. * @param a The first submesh
  73850. * @param b The second submesh
  73851. * @returns The result of the comparison
  73852. */
  73853. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73854. /**
  73855. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73856. * are rendered back to front.
  73857. *
  73858. * @param a The first submesh
  73859. * @param b The second submesh
  73860. * @returns The result of the comparison
  73861. */
  73862. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73863. /**
  73864. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73865. * are rendered front to back (prevent overdraw).
  73866. *
  73867. * @param a The first submesh
  73868. * @param b The second submesh
  73869. * @returns The result of the comparison
  73870. */
  73871. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73872. /**
  73873. * Resets the different lists of submeshes to prepare a new frame.
  73874. */
  73875. prepare(): void;
  73876. dispose(): void;
  73877. /**
  73878. * Inserts the submesh in its correct queue depending on its material.
  73879. * @param subMesh The submesh to dispatch
  73880. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73881. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73882. */
  73883. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73884. dispatchSprites(spriteManager: ISpriteManager): void;
  73885. dispatchParticles(particleSystem: IParticleSystem): void;
  73886. private _renderParticles;
  73887. private _renderSprites;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * Interface describing the different options available in the rendering manager
  73893. * regarding Auto Clear between groups.
  73894. */
  73895. export interface IRenderingManagerAutoClearSetup {
  73896. /**
  73897. * Defines whether or not autoclear is enable.
  73898. */
  73899. autoClear: boolean;
  73900. /**
  73901. * Defines whether or not to autoclear the depth buffer.
  73902. */
  73903. depth: boolean;
  73904. /**
  73905. * Defines whether or not to autoclear the stencil buffer.
  73906. */
  73907. stencil: boolean;
  73908. }
  73909. /**
  73910. * This class is used by the onRenderingGroupObservable
  73911. */
  73912. export class RenderingGroupInfo {
  73913. /**
  73914. * The Scene that being rendered
  73915. */
  73916. scene: Scene;
  73917. /**
  73918. * The camera currently used for the rendering pass
  73919. */
  73920. camera: Nullable<Camera>;
  73921. /**
  73922. * The ID of the renderingGroup being processed
  73923. */
  73924. renderingGroupId: number;
  73925. }
  73926. /**
  73927. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73928. * It is enable to manage the different groups as well as the different necessary sort functions.
  73929. * This should not be used directly aside of the few static configurations
  73930. */
  73931. export class RenderingManager {
  73932. /**
  73933. * The max id used for rendering groups (not included)
  73934. */
  73935. static MAX_RENDERINGGROUPS: number;
  73936. /**
  73937. * The min id used for rendering groups (included)
  73938. */
  73939. static MIN_RENDERINGGROUPS: number;
  73940. /**
  73941. * Used to globally prevent autoclearing scenes.
  73942. */
  73943. static AUTOCLEAR: boolean;
  73944. /**
  73945. * @hidden
  73946. */
  73947. _useSceneAutoClearSetup: boolean;
  73948. private _scene;
  73949. private _renderingGroups;
  73950. private _depthStencilBufferAlreadyCleaned;
  73951. private _autoClearDepthStencil;
  73952. private _customOpaqueSortCompareFn;
  73953. private _customAlphaTestSortCompareFn;
  73954. private _customTransparentSortCompareFn;
  73955. private _renderingGroupInfo;
  73956. /**
  73957. * Instantiates a new rendering group for a particular scene
  73958. * @param scene Defines the scene the groups belongs to
  73959. */
  73960. constructor(scene: Scene);
  73961. private _clearDepthStencilBuffer;
  73962. /**
  73963. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73964. * @hidden
  73965. */
  73966. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73967. /**
  73968. * Resets the different information of the group to prepare a new frame
  73969. * @hidden
  73970. */
  73971. reset(): void;
  73972. /**
  73973. * Dispose and release the group and its associated resources.
  73974. * @hidden
  73975. */
  73976. dispose(): void;
  73977. /**
  73978. * Clear the info related to rendering groups preventing retention points during dispose.
  73979. */
  73980. freeRenderingGroups(): void;
  73981. private _prepareRenderingGroup;
  73982. /**
  73983. * Add a sprite manager to the rendering manager in order to render it this frame.
  73984. * @param spriteManager Define the sprite manager to render
  73985. */
  73986. dispatchSprites(spriteManager: ISpriteManager): void;
  73987. /**
  73988. * Add a particle system to the rendering manager in order to render it this frame.
  73989. * @param particleSystem Define the particle system to render
  73990. */
  73991. dispatchParticles(particleSystem: IParticleSystem): void;
  73992. /**
  73993. * Add a submesh to the manager in order to render it this frame
  73994. * @param subMesh The submesh to dispatch
  73995. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73996. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73997. */
  73998. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73999. /**
  74000. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74001. * This allowed control for front to back rendering or reversly depending of the special needs.
  74002. *
  74003. * @param renderingGroupId The rendering group id corresponding to its index
  74004. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74005. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74006. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74007. */
  74008. 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;
  74009. /**
  74010. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74011. *
  74012. * @param renderingGroupId The rendering group id corresponding to its index
  74013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74014. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74015. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74016. */
  74017. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74018. /**
  74019. * Gets the current auto clear configuration for one rendering group of the rendering
  74020. * manager.
  74021. * @param index the rendering group index to get the information for
  74022. * @returns The auto clear setup for the requested rendering group
  74023. */
  74024. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74025. }
  74026. }
  74027. declare module BABYLON {
  74028. /**
  74029. * This Helps creating a texture that will be created from a camera in your scene.
  74030. * It is basically a dynamic texture that could be used to create special effects for instance.
  74031. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74032. */
  74033. export class RenderTargetTexture extends Texture {
  74034. isCube: boolean;
  74035. /**
  74036. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74037. */
  74038. static readonly REFRESHRATE_RENDER_ONCE: number;
  74039. /**
  74040. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74041. */
  74042. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74043. /**
  74044. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74045. * the central point of your effect and can save a lot of performances.
  74046. */
  74047. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74048. /**
  74049. * Use this predicate to dynamically define the list of mesh you want to render.
  74050. * If set, the renderList property will be overwritten.
  74051. */
  74052. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74053. private _renderList;
  74054. /**
  74055. * Use this list to define the list of mesh you want to render.
  74056. */
  74057. renderList: Nullable<Array<AbstractMesh>>;
  74058. private _hookArray;
  74059. /**
  74060. * Define if particles should be rendered in your texture.
  74061. */
  74062. renderParticles: boolean;
  74063. /**
  74064. * Define if sprites should be rendered in your texture.
  74065. */
  74066. renderSprites: boolean;
  74067. /**
  74068. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74069. */
  74070. coordinatesMode: number;
  74071. /**
  74072. * Define the camera used to render the texture.
  74073. */
  74074. activeCamera: Nullable<Camera>;
  74075. /**
  74076. * Override the render function of the texture with your own one.
  74077. */
  74078. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74079. /**
  74080. * Define if camera post processes should be use while rendering the texture.
  74081. */
  74082. useCameraPostProcesses: boolean;
  74083. /**
  74084. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74085. */
  74086. ignoreCameraViewport: boolean;
  74087. private _postProcessManager;
  74088. private _postProcesses;
  74089. private _resizeObserver;
  74090. /**
  74091. * An event triggered when the texture is unbind.
  74092. */
  74093. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74094. /**
  74095. * An event triggered when the texture is unbind.
  74096. */
  74097. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74098. private _onAfterUnbindObserver;
  74099. /**
  74100. * Set a after unbind callback in the texture.
  74101. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74102. */
  74103. onAfterUnbind: () => void;
  74104. /**
  74105. * An event triggered before rendering the texture
  74106. */
  74107. onBeforeRenderObservable: Observable<number>;
  74108. private _onBeforeRenderObserver;
  74109. /**
  74110. * Set a before render callback in the texture.
  74111. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74112. */
  74113. onBeforeRender: (faceIndex: number) => void;
  74114. /**
  74115. * An event triggered after rendering the texture
  74116. */
  74117. onAfterRenderObservable: Observable<number>;
  74118. private _onAfterRenderObserver;
  74119. /**
  74120. * Set a after render callback in the texture.
  74121. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74122. */
  74123. onAfterRender: (faceIndex: number) => void;
  74124. /**
  74125. * An event triggered after the texture clear
  74126. */
  74127. onClearObservable: Observable<Engine>;
  74128. private _onClearObserver;
  74129. /**
  74130. * Set a clear callback in the texture.
  74131. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74132. */
  74133. onClear: (Engine: Engine) => void;
  74134. /**
  74135. * Define the clear color of the Render Target if it should be different from the scene.
  74136. */
  74137. clearColor: Color4;
  74138. protected _size: number | {
  74139. width: number;
  74140. height: number;
  74141. };
  74142. protected _initialSizeParameter: number | {
  74143. width: number;
  74144. height: number;
  74145. } | {
  74146. ratio: number;
  74147. };
  74148. protected _sizeRatio: Nullable<number>;
  74149. /** @hidden */
  74150. _generateMipMaps: boolean;
  74151. protected _renderingManager: RenderingManager;
  74152. /** @hidden */
  74153. _waitingRenderList: string[];
  74154. protected _doNotChangeAspectRatio: boolean;
  74155. protected _currentRefreshId: number;
  74156. protected _refreshRate: number;
  74157. protected _textureMatrix: Matrix;
  74158. protected _samples: number;
  74159. protected _renderTargetOptions: RenderTargetCreationOptions;
  74160. /**
  74161. * Gets render target creation options that were used.
  74162. */
  74163. readonly renderTargetOptions: RenderTargetCreationOptions;
  74164. protected _engine: Engine;
  74165. protected _onRatioRescale(): void;
  74166. /**
  74167. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74168. * It must define where the camera used to render the texture is set
  74169. */
  74170. boundingBoxPosition: Vector3;
  74171. private _boundingBoxSize;
  74172. /**
  74173. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74174. * When defined, the cubemap will switch to local mode
  74175. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74176. * @example https://www.babylonjs-playground.com/#RNASML
  74177. */
  74178. boundingBoxSize: Vector3;
  74179. /**
  74180. * In case the RTT has been created with a depth texture, get the associated
  74181. * depth texture.
  74182. * Otherwise, return null.
  74183. */
  74184. depthStencilTexture: Nullable<InternalTexture>;
  74185. /**
  74186. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74187. * or used a shadow, depth texture...
  74188. * @param name The friendly name of the texture
  74189. * @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)
  74190. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74191. * @param generateMipMaps True if mip maps need to be generated after render.
  74192. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74193. * @param type The type of the buffer in the RTT (int, half float, float...)
  74194. * @param isCube True if a cube texture needs to be created
  74195. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74196. * @param generateDepthBuffer True to generate a depth buffer
  74197. * @param generateStencilBuffer True to generate a stencil buffer
  74198. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74199. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74200. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74201. */
  74202. constructor(name: string, size: number | {
  74203. width: number;
  74204. height: number;
  74205. } | {
  74206. ratio: number;
  74207. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74208. /**
  74209. * Creates a depth stencil texture.
  74210. * This is only available in WebGL 2 or with the depth texture extension available.
  74211. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74212. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74213. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74214. */
  74215. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74216. private _processSizeParameter;
  74217. /**
  74218. * Define the number of samples to use in case of MSAA.
  74219. * It defaults to one meaning no MSAA has been enabled.
  74220. */
  74221. samples: number;
  74222. /**
  74223. * Resets the refresh counter of the texture and start bak from scratch.
  74224. * Could be useful to regenerate the texture if it is setup to render only once.
  74225. */
  74226. resetRefreshCounter(): void;
  74227. /**
  74228. * Define the refresh rate of the texture or the rendering frequency.
  74229. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74230. */
  74231. refreshRate: number;
  74232. /**
  74233. * Adds a post process to the render target rendering passes.
  74234. * @param postProcess define the post process to add
  74235. */
  74236. addPostProcess(postProcess: PostProcess): void;
  74237. /**
  74238. * Clear all the post processes attached to the render target
  74239. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74240. */
  74241. clearPostProcesses(dispose?: boolean): void;
  74242. /**
  74243. * Remove one of the post process from the list of attached post processes to the texture
  74244. * @param postProcess define the post process to remove from the list
  74245. */
  74246. removePostProcess(postProcess: PostProcess): void;
  74247. /** @hidden */
  74248. _shouldRender(): boolean;
  74249. /**
  74250. * Gets the actual render size of the texture.
  74251. * @returns the width of the render size
  74252. */
  74253. getRenderSize(): number;
  74254. /**
  74255. * Gets the actual render width of the texture.
  74256. * @returns the width of the render size
  74257. */
  74258. getRenderWidth(): number;
  74259. /**
  74260. * Gets the actual render height of the texture.
  74261. * @returns the height of the render size
  74262. */
  74263. getRenderHeight(): number;
  74264. /**
  74265. * Get if the texture can be rescaled or not.
  74266. */
  74267. readonly canRescale: boolean;
  74268. /**
  74269. * Resize the texture using a ratio.
  74270. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74271. */
  74272. scale(ratio: number): void;
  74273. /**
  74274. * Get the texture reflection matrix used to rotate/transform the reflection.
  74275. * @returns the reflection matrix
  74276. */
  74277. getReflectionTextureMatrix(): Matrix;
  74278. /**
  74279. * Resize the texture to a new desired size.
  74280. * Be carrefull as it will recreate all the data in the new texture.
  74281. * @param size Define the new size. It can be:
  74282. * - a number for squared texture,
  74283. * - an object containing { width: number, height: number }
  74284. * - or an object containing a ratio { ratio: number }
  74285. */
  74286. resize(size: number | {
  74287. width: number;
  74288. height: number;
  74289. } | {
  74290. ratio: number;
  74291. }): void;
  74292. /**
  74293. * Renders all the objects from the render list into the texture.
  74294. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74295. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74296. */
  74297. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74298. private _bestReflectionRenderTargetDimension;
  74299. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74300. private renderToTarget;
  74301. /**
  74302. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74303. * This allowed control for front to back rendering or reversly depending of the special needs.
  74304. *
  74305. * @param renderingGroupId The rendering group id corresponding to its index
  74306. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74307. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74308. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74309. */
  74310. 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;
  74311. /**
  74312. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74313. *
  74314. * @param renderingGroupId The rendering group id corresponding to its index
  74315. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74316. */
  74317. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74318. /**
  74319. * Clones the texture.
  74320. * @returns the cloned texture
  74321. */
  74322. clone(): RenderTargetTexture;
  74323. /**
  74324. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74325. * @returns The JSON representation of the texture
  74326. */
  74327. serialize(): any;
  74328. /**
  74329. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74330. */
  74331. disposeFramebufferObjects(): void;
  74332. /**
  74333. * Dispose the texture and release its associated resources.
  74334. */
  74335. dispose(): void;
  74336. /** @hidden */
  74337. _rebuild(): void;
  74338. /**
  74339. * Clear the info related to rendering groups preventing retention point in material dispose.
  74340. */
  74341. freeRenderingGroups(): void;
  74342. }
  74343. }
  74344. declare module BABYLON {
  74345. /**
  74346. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74347. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74348. * You can then easily use it as a reflectionTexture on a flat surface.
  74349. * In case the surface is not a plane, please consider relying on reflection probes.
  74350. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74351. */
  74352. export class MirrorTexture extends RenderTargetTexture {
  74353. private scene;
  74354. /**
  74355. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74356. * 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.
  74357. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74358. */
  74359. mirrorPlane: Plane;
  74360. /**
  74361. * Define the blur ratio used to blur the reflection if needed.
  74362. */
  74363. blurRatio: number;
  74364. /**
  74365. * Define the adaptive blur kernel used to blur the reflection if needed.
  74366. * This will autocompute the closest best match for the `blurKernel`
  74367. */
  74368. adaptiveBlurKernel: number;
  74369. /**
  74370. * Define the blur kernel used to blur the reflection if needed.
  74371. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74372. */
  74373. blurKernel: number;
  74374. /**
  74375. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74376. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74377. */
  74378. blurKernelX: number;
  74379. /**
  74380. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74381. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74382. */
  74383. blurKernelY: number;
  74384. private _autoComputeBlurKernel;
  74385. protected _onRatioRescale(): void;
  74386. private _updateGammaSpace;
  74387. private _imageProcessingConfigChangeObserver;
  74388. private _transformMatrix;
  74389. private _mirrorMatrix;
  74390. private _savedViewMatrix;
  74391. private _blurX;
  74392. private _blurY;
  74393. private _adaptiveBlurKernel;
  74394. private _blurKernelX;
  74395. private _blurKernelY;
  74396. private _blurRatio;
  74397. /**
  74398. * Instantiates a Mirror Texture.
  74399. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74400. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74401. * You can then easily use it as a reflectionTexture on a flat surface.
  74402. * In case the surface is not a plane, please consider relying on reflection probes.
  74403. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74404. * @param name
  74405. * @param size
  74406. * @param scene
  74407. * @param generateMipMaps
  74408. * @param type
  74409. * @param samplingMode
  74410. * @param generateDepthBuffer
  74411. */
  74412. constructor(name: string, size: number | {
  74413. width: number;
  74414. height: number;
  74415. } | {
  74416. ratio: number;
  74417. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74418. private _preparePostProcesses;
  74419. /**
  74420. * Clone the mirror texture.
  74421. * @returns the cloned texture
  74422. */
  74423. clone(): MirrorTexture;
  74424. /**
  74425. * Serialize the texture to a JSON representation you could use in Parse later on
  74426. * @returns the serialized JSON representation
  74427. */
  74428. serialize(): any;
  74429. /**
  74430. * Dispose the texture and release its associated resources.
  74431. */
  74432. dispose(): void;
  74433. }
  74434. }
  74435. declare module BABYLON {
  74436. /**
  74437. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74438. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74439. */
  74440. export class Texture extends BaseTexture {
  74441. /** @hidden */
  74442. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74443. /** @hidden */
  74444. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74445. /** @hidden */
  74446. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74447. /** nearest is mag = nearest and min = nearest and mip = linear */
  74448. static readonly NEAREST_SAMPLINGMODE: number;
  74449. /** nearest is mag = nearest and min = nearest and mip = linear */
  74450. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74451. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74452. static readonly BILINEAR_SAMPLINGMODE: number;
  74453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74454. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74455. /** Trilinear is mag = linear and min = linear and mip = linear */
  74456. static readonly TRILINEAR_SAMPLINGMODE: number;
  74457. /** Trilinear is mag = linear and min = linear and mip = linear */
  74458. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74459. /** mag = nearest and min = nearest and mip = nearest */
  74460. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74461. /** mag = nearest and min = linear and mip = nearest */
  74462. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74463. /** mag = nearest and min = linear and mip = linear */
  74464. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74465. /** mag = nearest and min = linear and mip = none */
  74466. static readonly NEAREST_LINEAR: number;
  74467. /** mag = nearest and min = nearest and mip = none */
  74468. static readonly NEAREST_NEAREST: number;
  74469. /** mag = linear and min = nearest and mip = nearest */
  74470. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74471. /** mag = linear and min = nearest and mip = linear */
  74472. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74473. /** mag = linear and min = linear and mip = none */
  74474. static readonly LINEAR_LINEAR: number;
  74475. /** mag = linear and min = nearest and mip = none */
  74476. static readonly LINEAR_NEAREST: number;
  74477. /** Explicit coordinates mode */
  74478. static readonly EXPLICIT_MODE: number;
  74479. /** Spherical coordinates mode */
  74480. static readonly SPHERICAL_MODE: number;
  74481. /** Planar coordinates mode */
  74482. static readonly PLANAR_MODE: number;
  74483. /** Cubic coordinates mode */
  74484. static readonly CUBIC_MODE: number;
  74485. /** Projection coordinates mode */
  74486. static readonly PROJECTION_MODE: number;
  74487. /** Inverse Cubic coordinates mode */
  74488. static readonly SKYBOX_MODE: number;
  74489. /** Inverse Cubic coordinates mode */
  74490. static readonly INVCUBIC_MODE: number;
  74491. /** Equirectangular coordinates mode */
  74492. static readonly EQUIRECTANGULAR_MODE: number;
  74493. /** Equirectangular Fixed coordinates mode */
  74494. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74495. /** Equirectangular Fixed Mirrored coordinates mode */
  74496. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74497. /** Texture is not repeating outside of 0..1 UVs */
  74498. static readonly CLAMP_ADDRESSMODE: number;
  74499. /** Texture is repeating outside of 0..1 UVs */
  74500. static readonly WRAP_ADDRESSMODE: number;
  74501. /** Texture is repeating and mirrored */
  74502. static readonly MIRROR_ADDRESSMODE: number;
  74503. /**
  74504. * 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
  74505. */
  74506. static UseSerializedUrlIfAny: boolean;
  74507. /**
  74508. * Define the url of the texture.
  74509. */
  74510. url: Nullable<string>;
  74511. /**
  74512. * Define an offset on the texture to offset the u coordinates of the UVs
  74513. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74514. */
  74515. uOffset: number;
  74516. /**
  74517. * Define an offset on the texture to offset the v coordinates of the UVs
  74518. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74519. */
  74520. vOffset: number;
  74521. /**
  74522. * Define an offset on the texture to scale the u coordinates of the UVs
  74523. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74524. */
  74525. uScale: number;
  74526. /**
  74527. * Define an offset on the texture to scale the v coordinates of the UVs
  74528. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74529. */
  74530. vScale: number;
  74531. /**
  74532. * Define an offset on the texture to rotate around the u coordinates of the UVs
  74533. * @see http://doc.babylonjs.com/how_to/more_materials
  74534. */
  74535. uAng: number;
  74536. /**
  74537. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74538. * @see http://doc.babylonjs.com/how_to/more_materials
  74539. */
  74540. vAng: number;
  74541. /**
  74542. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74543. * @see http://doc.babylonjs.com/how_to/more_materials
  74544. */
  74545. wAng: number;
  74546. /**
  74547. * Defines the center of rotation (U)
  74548. */
  74549. uRotationCenter: number;
  74550. /**
  74551. * Defines the center of rotation (V)
  74552. */
  74553. vRotationCenter: number;
  74554. /**
  74555. * Defines the center of rotation (W)
  74556. */
  74557. wRotationCenter: number;
  74558. /**
  74559. * Are mip maps generated for this texture or not.
  74560. */
  74561. readonly noMipmap: boolean;
  74562. private _noMipmap;
  74563. /** @hidden */
  74564. _invertY: boolean;
  74565. private _rowGenerationMatrix;
  74566. private _cachedTextureMatrix;
  74567. private _projectionModeMatrix;
  74568. private _t0;
  74569. private _t1;
  74570. private _t2;
  74571. private _cachedUOffset;
  74572. private _cachedVOffset;
  74573. private _cachedUScale;
  74574. private _cachedVScale;
  74575. private _cachedUAng;
  74576. private _cachedVAng;
  74577. private _cachedWAng;
  74578. private _cachedProjectionMatrixId;
  74579. private _cachedCoordinatesMode;
  74580. /** @hidden */
  74581. protected _initialSamplingMode: number;
  74582. /** @hidden */
  74583. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74584. private _deleteBuffer;
  74585. protected _format: Nullable<number>;
  74586. private _delayedOnLoad;
  74587. private _delayedOnError;
  74588. /**
  74589. * Observable triggered once the texture has been loaded.
  74590. */
  74591. onLoadObservable: Observable<Texture>;
  74592. protected _isBlocking: boolean;
  74593. /**
  74594. * Is the texture preventing material to render while loading.
  74595. * If false, a default texture will be used instead of the loading one during the preparation step.
  74596. */
  74597. isBlocking: boolean;
  74598. /**
  74599. * Get the current sampling mode associated with the texture.
  74600. */
  74601. readonly samplingMode: number;
  74602. /**
  74603. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74604. */
  74605. readonly invertY: boolean;
  74606. /**
  74607. * Instantiates a new texture.
  74608. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74609. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74610. * @param url define the url of the picture to load as a texture
  74611. * @param scene define the scene the texture will belong to
  74612. * @param noMipmap define if the texture will require mip maps or not
  74613. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74614. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74615. * @param onLoad define a callback triggered when the texture has been loaded
  74616. * @param onError define a callback triggered when an error occurred during the loading session
  74617. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74618. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74619. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74620. */
  74621. 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);
  74622. /**
  74623. * Update the url (and optional buffer) of this texture if url was null during construction.
  74624. * @param url the url of the texture
  74625. * @param buffer the buffer of the texture (defaults to null)
  74626. * @param onLoad callback called when the texture is loaded (defaults to null)
  74627. */
  74628. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74629. /**
  74630. * Finish the loading sequence of a texture flagged as delayed load.
  74631. * @hidden
  74632. */
  74633. delayLoad(): void;
  74634. private _prepareRowForTextureGeneration;
  74635. /**
  74636. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74637. * @returns the transform matrix of the texture.
  74638. */
  74639. getTextureMatrix(): Matrix;
  74640. /**
  74641. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74642. * @returns The reflection texture transform
  74643. */
  74644. getReflectionTextureMatrix(): Matrix;
  74645. /**
  74646. * Clones the texture.
  74647. * @returns the cloned texture
  74648. */
  74649. clone(): Texture;
  74650. /**
  74651. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74652. * @returns The JSON representation of the texture
  74653. */
  74654. serialize(): any;
  74655. /**
  74656. * Get the current class name of the texture useful for serialization or dynamic coding.
  74657. * @returns "Texture"
  74658. */
  74659. getClassName(): string;
  74660. /**
  74661. * Dispose the texture and release its associated resources.
  74662. */
  74663. dispose(): void;
  74664. /**
  74665. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74666. * @param parsedTexture Define the JSON representation of the texture
  74667. * @param scene Define the scene the parsed texture should be instantiated in
  74668. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74669. * @returns The parsed texture if successful
  74670. */
  74671. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74672. /**
  74673. * Creates a texture from its base 64 representation.
  74674. * @param data Define the base64 payload without the data: prefix
  74675. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74676. * @param scene Define the scene the texture should belong to
  74677. * @param noMipmap Forces the texture to not create mip map information if true
  74678. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74679. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74680. * @param onLoad define a callback triggered when the texture has been loaded
  74681. * @param onError define a callback triggered when an error occurred during the loading session
  74682. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74683. * @returns the created texture
  74684. */
  74685. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74686. /**
  74687. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74688. * @param data Define the base64 payload without the data: prefix
  74689. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74690. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74691. * @param scene Define the scene the texture should belong to
  74692. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74693. * @param noMipmap Forces the texture to not create mip map information if true
  74694. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74695. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74696. * @param onLoad define a callback triggered when the texture has been loaded
  74697. * @param onError define a callback triggered when an error occurred during the loading session
  74698. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74699. * @returns the created texture
  74700. */
  74701. 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;
  74702. }
  74703. }
  74704. declare module BABYLON {
  74705. /**
  74706. * Raw texture can help creating a texture directly from an array of data.
  74707. * This can be super useful if you either get the data from an uncompressed source or
  74708. * if you wish to create your texture pixel by pixel.
  74709. */
  74710. export class RawTexture extends Texture {
  74711. /**
  74712. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74713. */
  74714. format: number;
  74715. private _engine;
  74716. /**
  74717. * Instantiates a new RawTexture.
  74718. * Raw texture can help creating a texture directly from an array of data.
  74719. * This can be super useful if you either get the data from an uncompressed source or
  74720. * if you wish to create your texture pixel by pixel.
  74721. * @param data define the array of data to use to create the texture
  74722. * @param width define the width of the texture
  74723. * @param height define the height of the texture
  74724. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74725. * @param scene define the scene the texture belongs to
  74726. * @param generateMipMaps define whether mip maps should be generated or not
  74727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74730. */
  74731. constructor(data: ArrayBufferView, width: number, height: number,
  74732. /**
  74733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74734. */
  74735. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  74736. /**
  74737. * Updates the texture underlying data.
  74738. * @param data Define the new data of the texture
  74739. */
  74740. update(data: ArrayBufferView): void;
  74741. /**
  74742. * Creates a luminance texture from some data.
  74743. * @param data Define the texture data
  74744. * @param width Define the width of the texture
  74745. * @param height Define the height of the texture
  74746. * @param scene Define the scene the texture belongs to
  74747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74750. * @returns the luminance texture
  74751. */
  74752. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74753. /**
  74754. * Creates a luminance alpha texture from some data.
  74755. * @param data Define the texture data
  74756. * @param width Define the width of the texture
  74757. * @param height Define the height of the texture
  74758. * @param scene Define the scene the texture belongs to
  74759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74762. * @returns the luminance alpha texture
  74763. */
  74764. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74765. /**
  74766. * Creates an alpha texture from some data.
  74767. * @param data Define the texture data
  74768. * @param width Define the width of the texture
  74769. * @param height Define the height of the texture
  74770. * @param scene Define the scene the texture belongs to
  74771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74774. * @returns the alpha texture
  74775. */
  74776. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74777. /**
  74778. * Creates a RGB texture from some data.
  74779. * @param data Define the texture data
  74780. * @param width Define the width of the texture
  74781. * @param height Define the height of the texture
  74782. * @param scene Define the scene the texture belongs to
  74783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74786. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74787. * @returns the RGB alpha texture
  74788. */
  74789. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74790. /**
  74791. * Creates a RGBA texture from some data.
  74792. * @param data Define the texture data
  74793. * @param width Define the width of the texture
  74794. * @param height Define the height of the texture
  74795. * @param scene Define the scene the texture belongs to
  74796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74800. * @returns the RGBA texture
  74801. */
  74802. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74803. /**
  74804. * Creates a R texture from some data.
  74805. * @param data Define the texture data
  74806. * @param width Define the width of the texture
  74807. * @param height Define the height of the texture
  74808. * @param scene Define the scene the texture belongs to
  74809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74813. * @returns the R texture
  74814. */
  74815. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74816. }
  74817. }
  74818. declare module BABYLON {
  74819. /**
  74820. * Defines a runtime animation
  74821. */
  74822. export class RuntimeAnimation {
  74823. private _events;
  74824. /**
  74825. * The current frame of the runtime animation
  74826. */
  74827. private _currentFrame;
  74828. /**
  74829. * The animation used by the runtime animation
  74830. */
  74831. private _animation;
  74832. /**
  74833. * The target of the runtime animation
  74834. */
  74835. private _target;
  74836. /**
  74837. * The initiating animatable
  74838. */
  74839. private _host;
  74840. /**
  74841. * The original value of the runtime animation
  74842. */
  74843. private _originalValue;
  74844. /**
  74845. * The original blend value of the runtime animation
  74846. */
  74847. private _originalBlendValue;
  74848. /**
  74849. * The offsets cache of the runtime animation
  74850. */
  74851. private _offsetsCache;
  74852. /**
  74853. * The high limits cache of the runtime animation
  74854. */
  74855. private _highLimitsCache;
  74856. /**
  74857. * Specifies if the runtime animation has been stopped
  74858. */
  74859. private _stopped;
  74860. /**
  74861. * The blending factor of the runtime animation
  74862. */
  74863. private _blendingFactor;
  74864. /**
  74865. * The BabylonJS scene
  74866. */
  74867. private _scene;
  74868. /**
  74869. * The current value of the runtime animation
  74870. */
  74871. private _currentValue;
  74872. /** @hidden */
  74873. _workValue: any;
  74874. /**
  74875. * The active target of the runtime animation
  74876. */
  74877. private _activeTarget;
  74878. /**
  74879. * The target path of the runtime animation
  74880. */
  74881. private _targetPath;
  74882. /**
  74883. * The weight of the runtime animation
  74884. */
  74885. private _weight;
  74886. /**
  74887. * The ratio offset of the runtime animation
  74888. */
  74889. private _ratioOffset;
  74890. /**
  74891. * The previous delay of the runtime animation
  74892. */
  74893. private _previousDelay;
  74894. /**
  74895. * The previous ratio of the runtime animation
  74896. */
  74897. private _previousRatio;
  74898. /**
  74899. * Gets the current frame of the runtime animation
  74900. */
  74901. readonly currentFrame: number;
  74902. /**
  74903. * Gets the weight of the runtime animation
  74904. */
  74905. readonly weight: number;
  74906. /**
  74907. * Gets the current value of the runtime animation
  74908. */
  74909. readonly currentValue: any;
  74910. /**
  74911. * Gets the target path of the runtime animation
  74912. */
  74913. readonly targetPath: string;
  74914. /**
  74915. * Gets the actual target of the runtime animation
  74916. */
  74917. readonly target: any;
  74918. /**
  74919. * Create a new RuntimeAnimation object
  74920. * @param target defines the target of the animation
  74921. * @param animation defines the source animation object
  74922. * @param scene defines the hosting scene
  74923. * @param host defines the initiating Animatable
  74924. */
  74925. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  74926. /**
  74927. * Gets the animation from the runtime animation
  74928. */
  74929. readonly animation: Animation;
  74930. /**
  74931. * Resets the runtime animation to the beginning
  74932. * @param restoreOriginal defines whether to restore the target property to the original value
  74933. */
  74934. reset(restoreOriginal?: boolean): void;
  74935. /**
  74936. * Specifies if the runtime animation is stopped
  74937. * @returns Boolean specifying if the runtime animation is stopped
  74938. */
  74939. isStopped(): boolean;
  74940. /**
  74941. * Disposes of the runtime animation
  74942. */
  74943. dispose(): void;
  74944. /**
  74945. * Interpolates the animation from the current frame
  74946. * @param currentFrame The frame to interpolate the animation to
  74947. * @param repeatCount The number of times that the animation should loop
  74948. * @param loopMode The type of looping mode to use
  74949. * @param offsetValue Animation offset value
  74950. * @param highLimitValue The high limit value
  74951. * @returns The interpolated value
  74952. */
  74953. private _interpolate;
  74954. /**
  74955. * Apply the interpolated value to the target
  74956. * @param currentValue defines the value computed by the animation
  74957. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  74958. */
  74959. setValue(currentValue: any, weight?: number): void;
  74960. private _setValue;
  74961. /**
  74962. * Gets the loop pmode of the runtime animation
  74963. * @returns Loop Mode
  74964. */
  74965. private _getCorrectLoopMode;
  74966. /**
  74967. * Move the current animation to a given frame
  74968. * @param frame defines the frame to move to
  74969. */
  74970. goToFrame(frame: number): void;
  74971. /**
  74972. * @hidden Internal use only
  74973. */
  74974. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  74975. /**
  74976. * Execute the current animation
  74977. * @param delay defines the delay to add to the current frame
  74978. * @param from defines the lower bound of the animation range
  74979. * @param to defines the upper bound of the animation range
  74980. * @param loop defines if the current animation must loop
  74981. * @param speedRatio defines the current speed ratio
  74982. * @param weight defines the weight of the animation (default is -1 so no weight)
  74983. * @param onLoop optional callback called when animation loops
  74984. * @returns a boolean indicating if the animation is running
  74985. */
  74986. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  74987. }
  74988. }
  74989. declare module BABYLON {
  74990. /**
  74991. * Class used to store an actual running animation
  74992. */
  74993. export class Animatable {
  74994. /** defines the target object */
  74995. target: any;
  74996. /** defines the starting frame number (default is 0) */
  74997. fromFrame: number;
  74998. /** defines the ending frame number (default is 100) */
  74999. toFrame: number;
  75000. /** defines if the animation must loop (default is false) */
  75001. loopAnimation: boolean;
  75002. /** defines a callback to call when animation ends if it is not looping */
  75003. onAnimationEnd?: (() => void) | null | undefined;
  75004. /** defines a callback to call when animation loops */
  75005. onAnimationLoop?: (() => void) | null | undefined;
  75006. private _localDelayOffset;
  75007. private _pausedDelay;
  75008. private _runtimeAnimations;
  75009. private _paused;
  75010. private _scene;
  75011. private _speedRatio;
  75012. private _weight;
  75013. private _syncRoot;
  75014. /**
  75015. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75016. * This will only apply for non looping animation (default is true)
  75017. */
  75018. disposeOnEnd: boolean;
  75019. /**
  75020. * Gets a boolean indicating if the animation has started
  75021. */
  75022. animationStarted: boolean;
  75023. /**
  75024. * Observer raised when the animation ends
  75025. */
  75026. onAnimationEndObservable: Observable<Animatable>;
  75027. /**
  75028. * Observer raised when the animation loops
  75029. */
  75030. onAnimationLoopObservable: Observable<Animatable>;
  75031. /**
  75032. * Gets the root Animatable used to synchronize and normalize animations
  75033. */
  75034. readonly syncRoot: Animatable;
  75035. /**
  75036. * Gets the current frame of the first RuntimeAnimation
  75037. * Used to synchronize Animatables
  75038. */
  75039. readonly masterFrame: number;
  75040. /**
  75041. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75042. */
  75043. weight: number;
  75044. /**
  75045. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75046. */
  75047. speedRatio: number;
  75048. /**
  75049. * Creates a new Animatable
  75050. * @param scene defines the hosting scene
  75051. * @param target defines the target object
  75052. * @param fromFrame defines the starting frame number (default is 0)
  75053. * @param toFrame defines the ending frame number (default is 100)
  75054. * @param loopAnimation defines if the animation must loop (default is false)
  75055. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75056. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75057. * @param animations defines a group of animation to add to the new Animatable
  75058. * @param onAnimationLoop defines a callback to call when animation loops
  75059. */
  75060. constructor(scene: Scene,
  75061. /** defines the target object */
  75062. target: any,
  75063. /** defines the starting frame number (default is 0) */
  75064. fromFrame?: number,
  75065. /** defines the ending frame number (default is 100) */
  75066. toFrame?: number,
  75067. /** defines if the animation must loop (default is false) */
  75068. loopAnimation?: boolean, speedRatio?: number,
  75069. /** defines a callback to call when animation ends if it is not looping */
  75070. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75071. /** defines a callback to call when animation loops */
  75072. onAnimationLoop?: (() => void) | null | undefined);
  75073. /**
  75074. * Synchronize and normalize current Animatable with a source Animatable
  75075. * This is useful when using animation weights and when animations are not of the same length
  75076. * @param root defines the root Animatable to synchronize with
  75077. * @returns the current Animatable
  75078. */
  75079. syncWith(root: Animatable): Animatable;
  75080. /**
  75081. * Gets the list of runtime animations
  75082. * @returns an array of RuntimeAnimation
  75083. */
  75084. getAnimations(): RuntimeAnimation[];
  75085. /**
  75086. * Adds more animations to the current animatable
  75087. * @param target defines the target of the animations
  75088. * @param animations defines the new animations to add
  75089. */
  75090. appendAnimations(target: any, animations: Animation[]): void;
  75091. /**
  75092. * Gets the source animation for a specific property
  75093. * @param property defines the propertyu to look for
  75094. * @returns null or the source animation for the given property
  75095. */
  75096. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75097. /**
  75098. * Gets the runtime animation for a specific property
  75099. * @param property defines the propertyu to look for
  75100. * @returns null or the runtime animation for the given property
  75101. */
  75102. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75103. /**
  75104. * Resets the animatable to its original state
  75105. */
  75106. reset(): void;
  75107. /**
  75108. * Allows the animatable to blend with current running animations
  75109. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75110. * @param blendingSpeed defines the blending speed to use
  75111. */
  75112. enableBlending(blendingSpeed: number): void;
  75113. /**
  75114. * Disable animation blending
  75115. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75116. */
  75117. disableBlending(): void;
  75118. /**
  75119. * Jump directly to a given frame
  75120. * @param frame defines the frame to jump to
  75121. */
  75122. goToFrame(frame: number): void;
  75123. /**
  75124. * Pause the animation
  75125. */
  75126. pause(): void;
  75127. /**
  75128. * Restart the animation
  75129. */
  75130. restart(): void;
  75131. private _raiseOnAnimationEnd;
  75132. /**
  75133. * Stop and delete the current animation
  75134. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75135. * @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)
  75136. */
  75137. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75138. /**
  75139. * Wait asynchronously for the animation to end
  75140. * @returns a promise which will be fullfilled when the animation ends
  75141. */
  75142. waitAsync(): Promise<Animatable>;
  75143. /** @hidden */
  75144. _animate(delay: number): boolean;
  75145. }
  75146. interface Scene {
  75147. /** @hidden */
  75148. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75149. /** @hidden */
  75150. _processLateAnimationBindingsForMatrices(holder: {
  75151. totalWeight: number;
  75152. animations: RuntimeAnimation[];
  75153. originalValue: Matrix;
  75154. }): any;
  75155. /** @hidden */
  75156. _processLateAnimationBindingsForQuaternions(holder: {
  75157. totalWeight: number;
  75158. animations: RuntimeAnimation[];
  75159. originalValue: Quaternion;
  75160. }, refQuaternion: Quaternion): Quaternion;
  75161. /** @hidden */
  75162. _processLateAnimationBindings(): void;
  75163. /**
  75164. * Will start the animation sequence of a given target
  75165. * @param target defines the target
  75166. * @param from defines from which frame should animation start
  75167. * @param to defines until which frame should animation run.
  75168. * @param weight defines the weight to apply to the animation (1.0 by default)
  75169. * @param loop defines if the animation loops
  75170. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75171. * @param onAnimationEnd defines the function to be executed when the animation ends
  75172. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75173. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75174. * @param onAnimationLoop defines the callback to call when an animation loops
  75175. * @returns the animatable object created for this animation
  75176. */
  75177. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75178. /**
  75179. * Will start the animation sequence of a given target
  75180. * @param target defines the target
  75181. * @param from defines from which frame should animation start
  75182. * @param to defines until which frame should animation run.
  75183. * @param loop defines if the animation loops
  75184. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75185. * @param onAnimationEnd defines the function to be executed when the animation ends
  75186. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75187. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75188. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75189. * @param onAnimationLoop defines the callback to call when an animation loops
  75190. * @returns the animatable object created for this animation
  75191. */
  75192. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75193. /**
  75194. * Will start the animation sequence of a given target and its hierarchy
  75195. * @param target defines the target
  75196. * @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.
  75197. * @param from defines from which frame should animation start
  75198. * @param to defines until which frame should animation run.
  75199. * @param loop defines if the animation loops
  75200. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75201. * @param onAnimationEnd defines the function to be executed when the animation ends
  75202. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75203. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75204. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75205. * @param onAnimationLoop defines the callback to call when an animation loops
  75206. * @returns the list of created animatables
  75207. */
  75208. 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[];
  75209. /**
  75210. * Begin a new animation on a given node
  75211. * @param target defines the target where the animation will take place
  75212. * @param animations defines the list of animations to start
  75213. * @param from defines the initial value
  75214. * @param to defines the final value
  75215. * @param loop defines if you want animation to loop (off by default)
  75216. * @param speedRatio defines the speed ratio to apply to all animations
  75217. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75218. * @param onAnimationLoop defines the callback to call when an animation loops
  75219. * @returns the list of created animatables
  75220. */
  75221. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75222. /**
  75223. * Begin a new animation on a given node and its hierarchy
  75224. * @param target defines the root node where the animation will take place
  75225. * @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.
  75226. * @param animations defines the list of animations to start
  75227. * @param from defines the initial value
  75228. * @param to defines the final value
  75229. * @param loop defines if you want animation to loop (off by default)
  75230. * @param speedRatio defines the speed ratio to apply to all animations
  75231. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75232. * @param onAnimationLoop defines the callback to call when an animation loops
  75233. * @returns the list of animatables created for all nodes
  75234. */
  75235. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75236. /**
  75237. * Gets the animatable associated with a specific target
  75238. * @param target defines the target of the animatable
  75239. * @returns the required animatable if found
  75240. */
  75241. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75242. /**
  75243. * Gets all animatables associated with a given target
  75244. * @param target defines the target to look animatables for
  75245. * @returns an array of Animatables
  75246. */
  75247. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75248. /**
  75249. * Will stop the animation of the given target
  75250. * @param target - the target
  75251. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75252. * @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)
  75253. */
  75254. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75255. /**
  75256. * Stops and removes all animations that have been applied to the scene
  75257. */
  75258. stopAllAnimations(): void;
  75259. }
  75260. interface Bone {
  75261. /**
  75262. * Copy an animation range from another bone
  75263. * @param source defines the source bone
  75264. * @param rangeName defines the range name to copy
  75265. * @param frameOffset defines the frame offset
  75266. * @param rescaleAsRequired defines if rescaling must be applied if required
  75267. * @param skelDimensionsRatio defines the scaling ratio
  75268. * @returns true if operation was successful
  75269. */
  75270. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75271. }
  75272. }
  75273. declare module BABYLON {
  75274. /**
  75275. * Class used to handle skinning animations
  75276. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75277. */
  75278. export class Skeleton implements IAnimatable {
  75279. /** defines the skeleton name */
  75280. name: string;
  75281. /** defines the skeleton Id */
  75282. id: string;
  75283. /**
  75284. * Defines the list of child bones
  75285. */
  75286. bones: Bone[];
  75287. /**
  75288. * Defines an estimate of the dimension of the skeleton at rest
  75289. */
  75290. dimensionsAtRest: Vector3;
  75291. /**
  75292. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75293. */
  75294. needInitialSkinMatrix: boolean;
  75295. /**
  75296. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75297. */
  75298. overrideMesh: Nullable<AbstractMesh>;
  75299. /**
  75300. * Gets the list of animations attached to this skeleton
  75301. */
  75302. animations: Array<Animation>;
  75303. private _scene;
  75304. private _isDirty;
  75305. private _transformMatrices;
  75306. private _transformMatrixTexture;
  75307. private _meshesWithPoseMatrix;
  75308. private _animatables;
  75309. private _identity;
  75310. private _synchronizedWithMesh;
  75311. private _ranges;
  75312. private _lastAbsoluteTransformsUpdateId;
  75313. private _canUseTextureForBones;
  75314. /** @hidden */
  75315. _numBonesWithLinkedTransformNode: number;
  75316. /**
  75317. * Specifies if the skeleton should be serialized
  75318. */
  75319. doNotSerialize: boolean;
  75320. /**
  75321. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75322. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75323. */
  75324. useTextureToStoreBoneMatrices: boolean;
  75325. private _animationPropertiesOverride;
  75326. /**
  75327. * Gets or sets the animation properties override
  75328. */
  75329. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75330. /**
  75331. * An observable triggered before computing the skeleton's matrices
  75332. */
  75333. onBeforeComputeObservable: Observable<Skeleton>;
  75334. /**
  75335. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75336. */
  75337. readonly isUsingTextureForMatrices: boolean;
  75338. /**
  75339. * Creates a new skeleton
  75340. * @param name defines the skeleton name
  75341. * @param id defines the skeleton Id
  75342. * @param scene defines the hosting scene
  75343. */
  75344. constructor(
  75345. /** defines the skeleton name */
  75346. name: string,
  75347. /** defines the skeleton Id */
  75348. id: string, scene: Scene);
  75349. /**
  75350. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75351. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75352. * @returns a Float32Array containing matrices data
  75353. */
  75354. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75355. /**
  75356. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75357. * @returns a raw texture containing the data
  75358. */
  75359. getTransformMatrixTexture(): Nullable<RawTexture>;
  75360. /**
  75361. * Gets the current hosting scene
  75362. * @returns a scene object
  75363. */
  75364. getScene(): Scene;
  75365. /**
  75366. * Gets a string representing the current skeleton data
  75367. * @param fullDetails defines a boolean indicating if we want a verbose version
  75368. * @returns a string representing the current skeleton data
  75369. */
  75370. toString(fullDetails?: boolean): string;
  75371. /**
  75372. * Get bone's index searching by name
  75373. * @param name defines bone's name to search for
  75374. * @return the indice of the bone. Returns -1 if not found
  75375. */
  75376. getBoneIndexByName(name: string): number;
  75377. /**
  75378. * Creater a new animation range
  75379. * @param name defines the name of the range
  75380. * @param from defines the start key
  75381. * @param to defines the end key
  75382. */
  75383. createAnimationRange(name: string, from: number, to: number): void;
  75384. /**
  75385. * Delete a specific animation range
  75386. * @param name defines the name of the range
  75387. * @param deleteFrames defines if frames must be removed as well
  75388. */
  75389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75390. /**
  75391. * Gets a specific animation range
  75392. * @param name defines the name of the range to look for
  75393. * @returns the requested animation range or null if not found
  75394. */
  75395. getAnimationRange(name: string): Nullable<AnimationRange>;
  75396. /**
  75397. * Gets the list of all animation ranges defined on this skeleton
  75398. * @returns an array
  75399. */
  75400. getAnimationRanges(): Nullable<AnimationRange>[];
  75401. /**
  75402. * Copy animation range from a source skeleton.
  75403. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75404. * @param source defines the source skeleton
  75405. * @param name defines the name of the range to copy
  75406. * @param rescaleAsRequired defines if rescaling must be applied if required
  75407. * @returns true if operation was successful
  75408. */
  75409. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75410. /**
  75411. * Forces the skeleton to go to rest pose
  75412. */
  75413. returnToRest(): void;
  75414. private _getHighestAnimationFrame;
  75415. /**
  75416. * Begin a specific animation range
  75417. * @param name defines the name of the range to start
  75418. * @param loop defines if looping must be turned on (false by default)
  75419. * @param speedRatio defines the speed ratio to apply (1 by default)
  75420. * @param onAnimationEnd defines a callback which will be called when animation will end
  75421. * @returns a new animatable
  75422. */
  75423. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75424. /** @hidden */
  75425. _markAsDirty(): void;
  75426. /** @hidden */
  75427. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75428. /** @hidden */
  75429. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75430. private _computeTransformMatrices;
  75431. /**
  75432. * Build all resources required to render a skeleton
  75433. */
  75434. prepare(): void;
  75435. /**
  75436. * Gets the list of animatables currently running for this skeleton
  75437. * @returns an array of animatables
  75438. */
  75439. getAnimatables(): IAnimatable[];
  75440. /**
  75441. * Clone the current skeleton
  75442. * @param name defines the name of the new skeleton
  75443. * @param id defines the id of the enw skeleton
  75444. * @returns the new skeleton
  75445. */
  75446. clone(name: string, id: string): Skeleton;
  75447. /**
  75448. * Enable animation blending for this skeleton
  75449. * @param blendingSpeed defines the blending speed to apply
  75450. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75451. */
  75452. enableBlending(blendingSpeed?: number): void;
  75453. /**
  75454. * Releases all resources associated with the current skeleton
  75455. */
  75456. dispose(): void;
  75457. /**
  75458. * Serialize the skeleton in a JSON object
  75459. * @returns a JSON object
  75460. */
  75461. serialize(): any;
  75462. /**
  75463. * Creates a new skeleton from serialized data
  75464. * @param parsedSkeleton defines the serialized data
  75465. * @param scene defines the hosting scene
  75466. * @returns a new skeleton
  75467. */
  75468. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75469. /**
  75470. * Compute all node absolute transforms
  75471. * @param forceUpdate defines if computation must be done even if cache is up to date
  75472. */
  75473. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75474. /**
  75475. * Gets the root pose matrix
  75476. * @returns a matrix
  75477. */
  75478. getPoseMatrix(): Nullable<Matrix>;
  75479. /**
  75480. * Sorts bones per internal index
  75481. */
  75482. sortBones(): void;
  75483. private _sortBones;
  75484. }
  75485. }
  75486. declare module BABYLON {
  75487. /**
  75488. * Defines a target to use with MorphTargetManager
  75489. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75490. */
  75491. export class MorphTarget implements IAnimatable {
  75492. /** defines the name of the target */
  75493. name: string;
  75494. /**
  75495. * Gets or sets the list of animations
  75496. */
  75497. animations: Animation[];
  75498. private _scene;
  75499. private _positions;
  75500. private _normals;
  75501. private _tangents;
  75502. private _influence;
  75503. /**
  75504. * Observable raised when the influence changes
  75505. */
  75506. onInfluenceChanged: Observable<boolean>;
  75507. /** @hidden */
  75508. _onDataLayoutChanged: Observable<void>;
  75509. /**
  75510. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  75511. */
  75512. influence: number;
  75513. /**
  75514. * Gets or sets the id of the morph Target
  75515. */
  75516. id: string;
  75517. private _animationPropertiesOverride;
  75518. /**
  75519. * Gets or sets the animation properties override
  75520. */
  75521. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75522. /**
  75523. * Creates a new MorphTarget
  75524. * @param name defines the name of the target
  75525. * @param influence defines the influence to use
  75526. * @param scene defines the scene the morphtarget belongs to
  75527. */
  75528. constructor(
  75529. /** defines the name of the target */
  75530. name: string, influence?: number, scene?: Nullable<Scene>);
  75531. /**
  75532. * Gets a boolean defining if the target contains position data
  75533. */
  75534. readonly hasPositions: boolean;
  75535. /**
  75536. * Gets a boolean defining if the target contains normal data
  75537. */
  75538. readonly hasNormals: boolean;
  75539. /**
  75540. * Gets a boolean defining if the target contains tangent data
  75541. */
  75542. readonly hasTangents: boolean;
  75543. /**
  75544. * Affects position data to this target
  75545. * @param data defines the position data to use
  75546. */
  75547. setPositions(data: Nullable<FloatArray>): void;
  75548. /**
  75549. * Gets the position data stored in this target
  75550. * @returns a FloatArray containing the position data (or null if not present)
  75551. */
  75552. getPositions(): Nullable<FloatArray>;
  75553. /**
  75554. * Affects normal data to this target
  75555. * @param data defines the normal data to use
  75556. */
  75557. setNormals(data: Nullable<FloatArray>): void;
  75558. /**
  75559. * Gets the normal data stored in this target
  75560. * @returns a FloatArray containing the normal data (or null if not present)
  75561. */
  75562. getNormals(): Nullable<FloatArray>;
  75563. /**
  75564. * Affects tangent data to this target
  75565. * @param data defines the tangent data to use
  75566. */
  75567. setTangents(data: Nullable<FloatArray>): void;
  75568. /**
  75569. * Gets the tangent data stored in this target
  75570. * @returns a FloatArray containing the tangent data (or null if not present)
  75571. */
  75572. getTangents(): Nullable<FloatArray>;
  75573. /**
  75574. * Serializes the current target into a Serialization object
  75575. * @returns the serialized object
  75576. */
  75577. serialize(): any;
  75578. /**
  75579. * Returns the string "MorphTarget"
  75580. * @returns "MorphTarget"
  75581. */
  75582. getClassName(): string;
  75583. /**
  75584. * Creates a new target from serialized data
  75585. * @param serializationObject defines the serialized data to use
  75586. * @returns a new MorphTarget
  75587. */
  75588. static Parse(serializationObject: any): MorphTarget;
  75589. /**
  75590. * Creates a MorphTarget from mesh data
  75591. * @param mesh defines the source mesh
  75592. * @param name defines the name to use for the new target
  75593. * @param influence defines the influence to attach to the target
  75594. * @returns a new MorphTarget
  75595. */
  75596. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  75597. }
  75598. }
  75599. declare module BABYLON {
  75600. /**
  75601. * This class is used to deform meshes using morphing between different targets
  75602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75603. */
  75604. export class MorphTargetManager {
  75605. private _targets;
  75606. private _targetInfluenceChangedObservers;
  75607. private _targetDataLayoutChangedObservers;
  75608. private _activeTargets;
  75609. private _scene;
  75610. private _influences;
  75611. private _supportsNormals;
  75612. private _supportsTangents;
  75613. private _vertexCount;
  75614. private _uniqueId;
  75615. private _tempInfluences;
  75616. /**
  75617. * Creates a new MorphTargetManager
  75618. * @param scene defines the current scene
  75619. */
  75620. constructor(scene?: Nullable<Scene>);
  75621. /**
  75622. * Gets the unique ID of this manager
  75623. */
  75624. readonly uniqueId: number;
  75625. /**
  75626. * Gets the number of vertices handled by this manager
  75627. */
  75628. readonly vertexCount: number;
  75629. /**
  75630. * Gets a boolean indicating if this manager supports morphing of normals
  75631. */
  75632. readonly supportsNormals: boolean;
  75633. /**
  75634. * Gets a boolean indicating if this manager supports morphing of tangents
  75635. */
  75636. readonly supportsTangents: boolean;
  75637. /**
  75638. * Gets the number of targets stored in this manager
  75639. */
  75640. readonly numTargets: number;
  75641. /**
  75642. * Gets the number of influencers (ie. the number of targets with influences > 0)
  75643. */
  75644. readonly numInfluencers: number;
  75645. /**
  75646. * Gets the list of influences (one per target)
  75647. */
  75648. readonly influences: Float32Array;
  75649. /**
  75650. * Gets the active target at specified index. An active target is a target with an influence > 0
  75651. * @param index defines the index to check
  75652. * @returns the requested target
  75653. */
  75654. getActiveTarget(index: number): MorphTarget;
  75655. /**
  75656. * Gets the target at specified index
  75657. * @param index defines the index to check
  75658. * @returns the requested target
  75659. */
  75660. getTarget(index: number): MorphTarget;
  75661. /**
  75662. * Add a new target to this manager
  75663. * @param target defines the target to add
  75664. */
  75665. addTarget(target: MorphTarget): void;
  75666. /**
  75667. * Removes a target from the manager
  75668. * @param target defines the target to remove
  75669. */
  75670. removeTarget(target: MorphTarget): void;
  75671. /**
  75672. * Serializes the current manager into a Serialization object
  75673. * @returns the serialized object
  75674. */
  75675. serialize(): any;
  75676. private _syncActiveTargets;
  75677. /**
  75678. * Syncrhonize the targets with all the meshes using this morph target manager
  75679. */
  75680. synchronize(): void;
  75681. /**
  75682. * Creates a new MorphTargetManager from serialized data
  75683. * @param serializationObject defines the serialized data
  75684. * @param scene defines the hosting scene
  75685. * @returns the new MorphTargetManager
  75686. */
  75687. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  75688. }
  75689. }
  75690. declare module BABYLON {
  75691. /**
  75692. * Mesh representing the gorund
  75693. */
  75694. export class GroundMesh extends Mesh {
  75695. /** If octree should be generated */
  75696. generateOctree: boolean;
  75697. private _heightQuads;
  75698. /** @hidden */
  75699. _subdivisionsX: number;
  75700. /** @hidden */
  75701. _subdivisionsY: number;
  75702. /** @hidden */
  75703. _width: number;
  75704. /** @hidden */
  75705. _height: number;
  75706. /** @hidden */
  75707. _minX: number;
  75708. /** @hidden */
  75709. _maxX: number;
  75710. /** @hidden */
  75711. _minZ: number;
  75712. /** @hidden */
  75713. _maxZ: number;
  75714. constructor(name: string, scene: Scene);
  75715. /**
  75716. * "GroundMesh"
  75717. * @returns "GroundMesh"
  75718. */
  75719. getClassName(): string;
  75720. /**
  75721. * The minimum of x and y subdivisions
  75722. */
  75723. readonly subdivisions: number;
  75724. /**
  75725. * X subdivisions
  75726. */
  75727. readonly subdivisionsX: number;
  75728. /**
  75729. * Y subdivisions
  75730. */
  75731. readonly subdivisionsY: number;
  75732. /**
  75733. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75734. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75735. * @param chunksCount the number of subdivisions for x and y
  75736. * @param octreeBlocksSize (Default: 32)
  75737. */
  75738. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75739. /**
  75740. * Returns a height (y) value in the Worl system :
  75741. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75742. * @param x x coordinate
  75743. * @param z z coordinate
  75744. * @returns the ground y position if (x, z) are outside the ground surface.
  75745. */
  75746. getHeightAtCoordinates(x: number, z: number): number;
  75747. /**
  75748. * Returns a normalized vector (Vector3) orthogonal to the ground
  75749. * at the ground coordinates (x, z) expressed in the World system.
  75750. * @param x x coordinate
  75751. * @param z z coordinate
  75752. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75753. */
  75754. getNormalAtCoordinates(x: number, z: number): Vector3;
  75755. /**
  75756. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75757. * at the ground coordinates (x, z) expressed in the World system.
  75758. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75759. * @param x x coordinate
  75760. * @param z z coordinate
  75761. * @param ref vector to store the result
  75762. * @returns the GroundMesh.
  75763. */
  75764. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75765. /**
  75766. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75767. * if the ground has been updated.
  75768. * This can be used in the render loop.
  75769. * @returns the GroundMesh.
  75770. */
  75771. updateCoordinateHeights(): GroundMesh;
  75772. private _getFacetAt;
  75773. private _initHeightQuads;
  75774. private _computeHeightQuads;
  75775. /**
  75776. * Serializes this ground mesh
  75777. * @param serializationObject object to write serialization to
  75778. */
  75779. serialize(serializationObject: any): void;
  75780. /**
  75781. * Parses a serialized ground mesh
  75782. * @param parsedMesh the serialized mesh
  75783. * @param scene the scene to create the ground mesh in
  75784. * @returns the created ground mesh
  75785. */
  75786. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75787. }
  75788. }
  75789. declare module BABYLON {
  75790. /**
  75791. * Interface for Physics-Joint data
  75792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75793. */
  75794. export interface PhysicsJointData {
  75795. /**
  75796. * The main pivot of the joint
  75797. */
  75798. mainPivot?: Vector3;
  75799. /**
  75800. * The connected pivot of the joint
  75801. */
  75802. connectedPivot?: Vector3;
  75803. /**
  75804. * The main axis of the joint
  75805. */
  75806. mainAxis?: Vector3;
  75807. /**
  75808. * The connected axis of the joint
  75809. */
  75810. connectedAxis?: Vector3;
  75811. /**
  75812. * The collision of the joint
  75813. */
  75814. collision?: boolean;
  75815. /**
  75816. * Native Oimo/Cannon/Energy data
  75817. */
  75818. nativeParams?: any;
  75819. }
  75820. /**
  75821. * This is a holder class for the physics joint created by the physics plugin
  75822. * It holds a set of functions to control the underlying joint
  75823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75824. */
  75825. export class PhysicsJoint {
  75826. /**
  75827. * The type of the physics joint
  75828. */
  75829. type: number;
  75830. /**
  75831. * The data for the physics joint
  75832. */
  75833. jointData: PhysicsJointData;
  75834. private _physicsJoint;
  75835. protected _physicsPlugin: IPhysicsEnginePlugin;
  75836. /**
  75837. * Initializes the physics joint
  75838. * @param type The type of the physics joint
  75839. * @param jointData The data for the physics joint
  75840. */
  75841. constructor(
  75842. /**
  75843. * The type of the physics joint
  75844. */
  75845. type: number,
  75846. /**
  75847. * The data for the physics joint
  75848. */
  75849. jointData: PhysicsJointData);
  75850. /**
  75851. * Gets the physics joint
  75852. */
  75853. /**
  75854. * Sets the physics joint
  75855. */
  75856. physicsJoint: any;
  75857. /**
  75858. * Sets the physics plugin
  75859. */
  75860. physicsPlugin: IPhysicsEnginePlugin;
  75861. /**
  75862. * Execute a function that is physics-plugin specific.
  75863. * @param {Function} func the function that will be executed.
  75864. * It accepts two parameters: the physics world and the physics joint
  75865. */
  75866. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75867. /**
  75868. * Distance-Joint type
  75869. */
  75870. static DistanceJoint: number;
  75871. /**
  75872. * Hinge-Joint type
  75873. */
  75874. static HingeJoint: number;
  75875. /**
  75876. * Ball-and-Socket joint type
  75877. */
  75878. static BallAndSocketJoint: number;
  75879. /**
  75880. * Wheel-Joint type
  75881. */
  75882. static WheelJoint: number;
  75883. /**
  75884. * Slider-Joint type
  75885. */
  75886. static SliderJoint: number;
  75887. /**
  75888. * Prismatic-Joint type
  75889. */
  75890. static PrismaticJoint: number;
  75891. /**
  75892. * Universal-Joint type
  75893. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75894. */
  75895. static UniversalJoint: number;
  75896. /**
  75897. * Hinge-Joint 2 type
  75898. */
  75899. static Hinge2Joint: number;
  75900. /**
  75901. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75902. */
  75903. static PointToPointJoint: number;
  75904. /**
  75905. * Spring-Joint type
  75906. */
  75907. static SpringJoint: number;
  75908. /**
  75909. * Lock-Joint type
  75910. */
  75911. static LockJoint: number;
  75912. }
  75913. /**
  75914. * A class representing a physics distance joint
  75915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75916. */
  75917. export class DistanceJoint extends PhysicsJoint {
  75918. /**
  75919. *
  75920. * @param jointData The data for the Distance-Joint
  75921. */
  75922. constructor(jointData: DistanceJointData);
  75923. /**
  75924. * Update the predefined distance.
  75925. * @param maxDistance The maximum preferred distance
  75926. * @param minDistance The minimum preferred distance
  75927. */
  75928. updateDistance(maxDistance: number, minDistance?: number): void;
  75929. }
  75930. /**
  75931. * Represents a Motor-Enabled Joint
  75932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75933. */
  75934. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75935. /**
  75936. * Initializes the Motor-Enabled Joint
  75937. * @param type The type of the joint
  75938. * @param jointData The physica joint data for the joint
  75939. */
  75940. constructor(type: number, jointData: PhysicsJointData);
  75941. /**
  75942. * Set the motor values.
  75943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75944. * @param force the force to apply
  75945. * @param maxForce max force for this motor.
  75946. */
  75947. setMotor(force?: number, maxForce?: number): void;
  75948. /**
  75949. * Set the motor's limits.
  75950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75951. * @param upperLimit The upper limit of the motor
  75952. * @param lowerLimit The lower limit of the motor
  75953. */
  75954. setLimit(upperLimit: number, lowerLimit?: number): void;
  75955. }
  75956. /**
  75957. * This class represents a single physics Hinge-Joint
  75958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75959. */
  75960. export class HingeJoint extends MotorEnabledJoint {
  75961. /**
  75962. * Initializes the Hinge-Joint
  75963. * @param jointData The joint data for the Hinge-Joint
  75964. */
  75965. constructor(jointData: PhysicsJointData);
  75966. /**
  75967. * Set the motor values.
  75968. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75969. * @param {number} force the force to apply
  75970. * @param {number} maxForce max force for this motor.
  75971. */
  75972. setMotor(force?: number, maxForce?: number): void;
  75973. /**
  75974. * Set the motor's limits.
  75975. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75976. * @param upperLimit The upper limit of the motor
  75977. * @param lowerLimit The lower limit of the motor
  75978. */
  75979. setLimit(upperLimit: number, lowerLimit?: number): void;
  75980. }
  75981. /**
  75982. * This class represents a dual hinge physics joint (same as wheel joint)
  75983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75984. */
  75985. export class Hinge2Joint extends MotorEnabledJoint {
  75986. /**
  75987. * Initializes the Hinge2-Joint
  75988. * @param jointData The joint data for the Hinge2-Joint
  75989. */
  75990. constructor(jointData: PhysicsJointData);
  75991. /**
  75992. * Set the motor values.
  75993. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75994. * @param {number} targetSpeed the speed the motor is to reach
  75995. * @param {number} maxForce max force for this motor.
  75996. * @param {motorIndex} the motor's index, 0 or 1.
  75997. */
  75998. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75999. /**
  76000. * Set the motor limits.
  76001. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76002. * @param {number} upperLimit the upper limit
  76003. * @param {number} lowerLimit lower limit
  76004. * @param {motorIndex} the motor's index, 0 or 1.
  76005. */
  76006. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76007. }
  76008. /**
  76009. * Interface for a motor enabled joint
  76010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76011. */
  76012. export interface IMotorEnabledJoint {
  76013. /**
  76014. * Physics joint
  76015. */
  76016. physicsJoint: any;
  76017. /**
  76018. * Sets the motor of the motor-enabled joint
  76019. * @param force The force of the motor
  76020. * @param maxForce The maximum force of the motor
  76021. * @param motorIndex The index of the motor
  76022. */
  76023. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76024. /**
  76025. * Sets the limit of the motor
  76026. * @param upperLimit The upper limit of the motor
  76027. * @param lowerLimit The lower limit of the motor
  76028. * @param motorIndex The index of the motor
  76029. */
  76030. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76031. }
  76032. /**
  76033. * Joint data for a Distance-Joint
  76034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76035. */
  76036. export interface DistanceJointData extends PhysicsJointData {
  76037. /**
  76038. * Max distance the 2 joint objects can be apart
  76039. */
  76040. maxDistance: number;
  76041. }
  76042. /**
  76043. * Joint data from a spring joint
  76044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76045. */
  76046. export interface SpringJointData extends PhysicsJointData {
  76047. /**
  76048. * Length of the spring
  76049. */
  76050. length: number;
  76051. /**
  76052. * Stiffness of the spring
  76053. */
  76054. stiffness: number;
  76055. /**
  76056. * Damping of the spring
  76057. */
  76058. damping: number;
  76059. /** this callback will be called when applying the force to the impostors. */
  76060. forceApplicationCallback: () => void;
  76061. }
  76062. }
  76063. declare module BABYLON {
  76064. /**
  76065. * Interface used to describe a physics joint
  76066. */
  76067. export interface PhysicsImpostorJoint {
  76068. /** Defines the main impostor to which the joint is linked */
  76069. mainImpostor: PhysicsImpostor;
  76070. /** Defines the impostor that is connected to the main impostor using this joint */
  76071. connectedImpostor: PhysicsImpostor;
  76072. /** Defines the joint itself */
  76073. joint: PhysicsJoint;
  76074. }
  76075. /** @hidden */
  76076. export interface IPhysicsEnginePlugin {
  76077. world: any;
  76078. name: string;
  76079. setGravity(gravity: Vector3): void;
  76080. setTimeStep(timeStep: number): void;
  76081. getTimeStep(): number;
  76082. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76083. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76085. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76086. removePhysicsBody(impostor: PhysicsImpostor): void;
  76087. generateJoint(joint: PhysicsImpostorJoint): void;
  76088. removeJoint(joint: PhysicsImpostorJoint): void;
  76089. isSupported(): boolean;
  76090. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76091. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76092. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76093. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76094. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76095. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76096. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76097. getBodyMass(impostor: PhysicsImpostor): number;
  76098. getBodyFriction(impostor: PhysicsImpostor): number;
  76099. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76100. getBodyRestitution(impostor: PhysicsImpostor): number;
  76101. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76102. sleepBody(impostor: PhysicsImpostor): void;
  76103. wakeUpBody(impostor: PhysicsImpostor): void;
  76104. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76105. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76106. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76107. getRadius(impostor: PhysicsImpostor): number;
  76108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76109. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76110. dispose(): void;
  76111. }
  76112. /**
  76113. * Interface used to define a physics engine
  76114. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76115. */
  76116. export interface IPhysicsEngine {
  76117. /**
  76118. * Gets the gravity vector used by the simulation
  76119. */
  76120. gravity: Vector3;
  76121. /**
  76122. * Sets the gravity vector used by the simulation
  76123. * @param gravity defines the gravity vector to use
  76124. */
  76125. setGravity(gravity: Vector3): void;
  76126. /**
  76127. * Set the time step of the physics engine.
  76128. * Default is 1/60.
  76129. * To slow it down, enter 1/600 for example.
  76130. * To speed it up, 1/30
  76131. * @param newTimeStep the new timestep to apply to this world.
  76132. */
  76133. setTimeStep(newTimeStep: number): void;
  76134. /**
  76135. * Get the time step of the physics engine.
  76136. * @returns the current time step
  76137. */
  76138. getTimeStep(): number;
  76139. /**
  76140. * Release all resources
  76141. */
  76142. dispose(): void;
  76143. /**
  76144. * Gets the name of the current physics plugin
  76145. * @returns the name of the plugin
  76146. */
  76147. getPhysicsPluginName(): string;
  76148. /**
  76149. * Adding a new impostor for the impostor tracking.
  76150. * This will be done by the impostor itself.
  76151. * @param impostor the impostor to add
  76152. */
  76153. addImpostor(impostor: PhysicsImpostor): void;
  76154. /**
  76155. * Remove an impostor from the engine.
  76156. * This impostor and its mesh will not longer be updated by the physics engine.
  76157. * @param impostor the impostor to remove
  76158. */
  76159. removeImpostor(impostor: PhysicsImpostor): void;
  76160. /**
  76161. * Add a joint to the physics engine
  76162. * @param mainImpostor defines the main impostor to which the joint is added.
  76163. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76164. * @param joint defines the joint that will connect both impostors.
  76165. */
  76166. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76167. /**
  76168. * Removes a joint from the simulation
  76169. * @param mainImpostor defines the impostor used with the joint
  76170. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76171. * @param joint defines the joint to remove
  76172. */
  76173. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76174. /**
  76175. * Gets the current plugin used to run the simulation
  76176. * @returns current plugin
  76177. */
  76178. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76179. /**
  76180. * Gets the list of physic impostors
  76181. * @returns an array of PhysicsImpostor
  76182. */
  76183. getImpostors(): Array<PhysicsImpostor>;
  76184. /**
  76185. * Gets the impostor for a physics enabled object
  76186. * @param object defines the object impersonated by the impostor
  76187. * @returns the PhysicsImpostor or null if not found
  76188. */
  76189. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76190. /**
  76191. * Gets the impostor for a physics body object
  76192. * @param body defines physics body used by the impostor
  76193. * @returns the PhysicsImpostor or null if not found
  76194. */
  76195. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76196. /**
  76197. * Called by the scene. No need to call it.
  76198. * @param delta defines the timespam between frames
  76199. */
  76200. _step(delta: number): void;
  76201. }
  76202. }
  76203. declare module BABYLON {
  76204. /**
  76205. * The interface for the physics imposter parameters
  76206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76207. */
  76208. export interface PhysicsImpostorParameters {
  76209. /**
  76210. * The mass of the physics imposter
  76211. */
  76212. mass: number;
  76213. /**
  76214. * The friction of the physics imposter
  76215. */
  76216. friction?: number;
  76217. /**
  76218. * The coefficient of restitution of the physics imposter
  76219. */
  76220. restitution?: number;
  76221. /**
  76222. * The native options of the physics imposter
  76223. */
  76224. nativeOptions?: any;
  76225. /**
  76226. * Specifies if the parent should be ignored
  76227. */
  76228. ignoreParent?: boolean;
  76229. /**
  76230. * Specifies if bi-directional transformations should be disabled
  76231. */
  76232. disableBidirectionalTransformation?: boolean;
  76233. }
  76234. /**
  76235. * Interface for a physics-enabled object
  76236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76237. */
  76238. export interface IPhysicsEnabledObject {
  76239. /**
  76240. * The position of the physics-enabled object
  76241. */
  76242. position: Vector3;
  76243. /**
  76244. * The rotation of the physics-enabled object
  76245. */
  76246. rotationQuaternion: Nullable<Quaternion>;
  76247. /**
  76248. * The scale of the physics-enabled object
  76249. */
  76250. scaling: Vector3;
  76251. /**
  76252. * The rotation of the physics-enabled object
  76253. */
  76254. rotation?: Vector3;
  76255. /**
  76256. * The parent of the physics-enabled object
  76257. */
  76258. parent?: any;
  76259. /**
  76260. * The bounding info of the physics-enabled object
  76261. * @returns The bounding info of the physics-enabled object
  76262. */
  76263. getBoundingInfo(): BoundingInfo;
  76264. /**
  76265. * Computes the world matrix
  76266. * @param force Specifies if the world matrix should be computed by force
  76267. * @returns A world matrix
  76268. */
  76269. computeWorldMatrix(force: boolean): Matrix;
  76270. /**
  76271. * Gets the world matrix
  76272. * @returns A world matrix
  76273. */
  76274. getWorldMatrix?(): Matrix;
  76275. /**
  76276. * Gets the child meshes
  76277. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76278. * @returns An array of abstract meshes
  76279. */
  76280. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76281. /**
  76282. * Gets the vertex data
  76283. * @param kind The type of vertex data
  76284. * @returns A nullable array of numbers, or a float32 array
  76285. */
  76286. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76287. /**
  76288. * Gets the indices from the mesh
  76289. * @returns A nullable array of index arrays
  76290. */
  76291. getIndices?(): Nullable<IndicesArray>;
  76292. /**
  76293. * Gets the scene from the mesh
  76294. * @returns the indices array or null
  76295. */
  76296. getScene?(): Scene;
  76297. /**
  76298. * Gets the absolute position from the mesh
  76299. * @returns the absolute position
  76300. */
  76301. getAbsolutePosition(): Vector3;
  76302. /**
  76303. * Gets the absolute pivot point from the mesh
  76304. * @returns the absolute pivot point
  76305. */
  76306. getAbsolutePivotPoint(): Vector3;
  76307. /**
  76308. * Rotates the mesh
  76309. * @param axis The axis of rotation
  76310. * @param amount The amount of rotation
  76311. * @param space The space of the rotation
  76312. * @returns The rotation transform node
  76313. */
  76314. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76315. /**
  76316. * Translates the mesh
  76317. * @param axis The axis of translation
  76318. * @param distance The distance of translation
  76319. * @param space The space of the translation
  76320. * @returns The transform node
  76321. */
  76322. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76323. /**
  76324. * Sets the absolute position of the mesh
  76325. * @param absolutePosition The absolute position of the mesh
  76326. * @returns The transform node
  76327. */
  76328. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76329. /**
  76330. * Gets the class name of the mesh
  76331. * @returns The class name
  76332. */
  76333. getClassName(): string;
  76334. }
  76335. /**
  76336. * Represents a physics imposter
  76337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76338. */
  76339. export class PhysicsImpostor {
  76340. /**
  76341. * The physics-enabled object used as the physics imposter
  76342. */
  76343. object: IPhysicsEnabledObject;
  76344. /**
  76345. * The type of the physics imposter
  76346. */
  76347. type: number;
  76348. private _options;
  76349. private _scene?;
  76350. /**
  76351. * The default object size of the imposter
  76352. */
  76353. static DEFAULT_OBJECT_SIZE: Vector3;
  76354. /**
  76355. * The identity quaternion of the imposter
  76356. */
  76357. static IDENTITY_QUATERNION: Quaternion;
  76358. /** @hidden */
  76359. _pluginData: any;
  76360. private _physicsEngine;
  76361. private _physicsBody;
  76362. private _bodyUpdateRequired;
  76363. private _onBeforePhysicsStepCallbacks;
  76364. private _onAfterPhysicsStepCallbacks;
  76365. /** @hidden */
  76366. _onPhysicsCollideCallbacks: Array<{
  76367. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76368. otherImpostors: Array<PhysicsImpostor>;
  76369. }>;
  76370. private _deltaPosition;
  76371. private _deltaRotation;
  76372. private _deltaRotationConjugated;
  76373. private _parent;
  76374. private _isDisposed;
  76375. private static _tmpVecs;
  76376. private static _tmpQuat;
  76377. /**
  76378. * Specifies if the physics imposter is disposed
  76379. */
  76380. readonly isDisposed: boolean;
  76381. /**
  76382. * Gets the mass of the physics imposter
  76383. */
  76384. mass: number;
  76385. /**
  76386. * Gets the coefficient of friction
  76387. */
  76388. /**
  76389. * Sets the coefficient of friction
  76390. */
  76391. friction: number;
  76392. /**
  76393. * Gets the coefficient of restitution
  76394. */
  76395. /**
  76396. * Sets the coefficient of restitution
  76397. */
  76398. restitution: number;
  76399. /**
  76400. * The unique id of the physics imposter
  76401. * set by the physics engine when adding this impostor to the array
  76402. */
  76403. uniqueId: number;
  76404. private _joints;
  76405. /**
  76406. * Initializes the physics imposter
  76407. * @param object The physics-enabled object used as the physics imposter
  76408. * @param type The type of the physics imposter
  76409. * @param _options The options for the physics imposter
  76410. * @param _scene The Babylon scene
  76411. */
  76412. constructor(
  76413. /**
  76414. * The physics-enabled object used as the physics imposter
  76415. */
  76416. object: IPhysicsEnabledObject,
  76417. /**
  76418. * The type of the physics imposter
  76419. */
  76420. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76421. /**
  76422. * This function will completly initialize this impostor.
  76423. * It will create a new body - but only if this mesh has no parent.
  76424. * If it has, this impostor will not be used other than to define the impostor
  76425. * of the child mesh.
  76426. * @hidden
  76427. */
  76428. _init(): void;
  76429. private _getPhysicsParent;
  76430. /**
  76431. * Should a new body be generated.
  76432. * @returns boolean specifying if body initialization is required
  76433. */
  76434. isBodyInitRequired(): boolean;
  76435. /**
  76436. * Sets the updated scaling
  76437. * @param updated Specifies if the scaling is updated
  76438. */
  76439. setScalingUpdated(): void;
  76440. /**
  76441. * Force a regeneration of this or the parent's impostor's body.
  76442. * Use under cautious - This will remove all joints already implemented.
  76443. */
  76444. forceUpdate(): void;
  76445. /**
  76446. * Gets the body that holds this impostor. Either its own, or its parent.
  76447. */
  76448. /**
  76449. * Set the physics body. Used mainly by the physics engine/plugin
  76450. */
  76451. physicsBody: any;
  76452. /**
  76453. * Get the parent of the physics imposter
  76454. * @returns Physics imposter or null
  76455. */
  76456. /**
  76457. * Sets the parent of the physics imposter
  76458. */
  76459. parent: Nullable<PhysicsImpostor>;
  76460. /**
  76461. * Resets the update flags
  76462. */
  76463. resetUpdateFlags(): void;
  76464. /**
  76465. * Gets the object extend size
  76466. * @returns the object extend size
  76467. */
  76468. getObjectExtendSize(): Vector3;
  76469. /**
  76470. * Gets the object center
  76471. * @returns The object center
  76472. */
  76473. getObjectCenter(): Vector3;
  76474. /**
  76475. * Get a specific parametes from the options parameter
  76476. * @param paramName The object parameter name
  76477. * @returns The object parameter
  76478. */
  76479. getParam(paramName: string): any;
  76480. /**
  76481. * Sets a specific parameter in the options given to the physics plugin
  76482. * @param paramName The parameter name
  76483. * @param value The value of the parameter
  76484. */
  76485. setParam(paramName: string, value: number): void;
  76486. /**
  76487. * Specifically change the body's mass option. Won't recreate the physics body object
  76488. * @param mass The mass of the physics imposter
  76489. */
  76490. setMass(mass: number): void;
  76491. /**
  76492. * Gets the linear velocity
  76493. * @returns linear velocity or null
  76494. */
  76495. getLinearVelocity(): Nullable<Vector3>;
  76496. /**
  76497. * Sets the linear velocity
  76498. * @param velocity linear velocity or null
  76499. */
  76500. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76501. /**
  76502. * Gets the angular velocity
  76503. * @returns angular velocity or null
  76504. */
  76505. getAngularVelocity(): Nullable<Vector3>;
  76506. /**
  76507. * Sets the angular velocity
  76508. * @param velocity The velocity or null
  76509. */
  76510. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76511. /**
  76512. * Execute a function with the physics plugin native code
  76513. * Provide a function the will have two variables - the world object and the physics body object
  76514. * @param func The function to execute with the physics plugin native code
  76515. */
  76516. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76517. /**
  76518. * Register a function that will be executed before the physics world is stepping forward
  76519. * @param func The function to execute before the physics world is stepped forward
  76520. */
  76521. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76522. /**
  76523. * Unregister a function that will be executed before the physics world is stepping forward
  76524. * @param func The function to execute before the physics world is stepped forward
  76525. */
  76526. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76527. /**
  76528. * Register a function that will be executed after the physics step
  76529. * @param func The function to execute after physics step
  76530. */
  76531. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76532. /**
  76533. * Unregisters a function that will be executed after the physics step
  76534. * @param func The function to execute after physics step
  76535. */
  76536. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76537. /**
  76538. * register a function that will be executed when this impostor collides against a different body
  76539. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76540. * @param func Callback that is executed on collision
  76541. */
  76542. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76543. /**
  76544. * Unregisters the physics imposter on contact
  76545. * @param collideAgainst The physics object to collide against
  76546. * @param func Callback to execute on collision
  76547. */
  76548. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76549. private _tmpQuat;
  76550. private _tmpQuat2;
  76551. /**
  76552. * Get the parent rotation
  76553. * @returns The parent rotation
  76554. */
  76555. getParentsRotation(): Quaternion;
  76556. /**
  76557. * this function is executed by the physics engine.
  76558. */
  76559. beforeStep: () => void;
  76560. /**
  76561. * this function is executed by the physics engine
  76562. */
  76563. afterStep: () => void;
  76564. /**
  76565. * Legacy collision detection event support
  76566. */
  76567. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76568. /**
  76569. * event and body object due to cannon's event-based architecture.
  76570. */
  76571. onCollide: (e: {
  76572. body: any;
  76573. }) => void;
  76574. /**
  76575. * Apply a force
  76576. * @param force The force to apply
  76577. * @param contactPoint The contact point for the force
  76578. * @returns The physics imposter
  76579. */
  76580. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76581. /**
  76582. * Apply an impulse
  76583. * @param force The impulse force
  76584. * @param contactPoint The contact point for the impulse force
  76585. * @returns The physics imposter
  76586. */
  76587. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76588. /**
  76589. * A help function to create a joint
  76590. * @param otherImpostor A physics imposter used to create a joint
  76591. * @param jointType The type of joint
  76592. * @param jointData The data for the joint
  76593. * @returns The physics imposter
  76594. */
  76595. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76596. /**
  76597. * Add a joint to this impostor with a different impostor
  76598. * @param otherImpostor A physics imposter used to add a joint
  76599. * @param joint The joint to add
  76600. * @returns The physics imposter
  76601. */
  76602. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76603. /**
  76604. * Will keep this body still, in a sleep mode.
  76605. * @returns the physics imposter
  76606. */
  76607. sleep(): PhysicsImpostor;
  76608. /**
  76609. * Wake the body up.
  76610. * @returns The physics imposter
  76611. */
  76612. wakeUp(): PhysicsImpostor;
  76613. /**
  76614. * Clones the physics imposter
  76615. * @param newObject The physics imposter clones to this physics-enabled object
  76616. * @returns A nullable physics imposter
  76617. */
  76618. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76619. /**
  76620. * Disposes the physics imposter
  76621. */
  76622. dispose(): void;
  76623. /**
  76624. * Sets the delta position
  76625. * @param position The delta position amount
  76626. */
  76627. setDeltaPosition(position: Vector3): void;
  76628. /**
  76629. * Sets the delta rotation
  76630. * @param rotation The delta rotation amount
  76631. */
  76632. setDeltaRotation(rotation: Quaternion): void;
  76633. /**
  76634. * Gets the box size of the physics imposter and stores the result in the input parameter
  76635. * @param result Stores the box size
  76636. * @returns The physics imposter
  76637. */
  76638. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76639. /**
  76640. * Gets the radius of the physics imposter
  76641. * @returns Radius of the physics imposter
  76642. */
  76643. getRadius(): number;
  76644. /**
  76645. * Sync a bone with this impostor
  76646. * @param bone The bone to sync to the impostor.
  76647. * @param boneMesh The mesh that the bone is influencing.
  76648. * @param jointPivot The pivot of the joint / bone in local space.
  76649. * @param distToJoint Optional distance from the impostor to the joint.
  76650. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76651. */
  76652. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76653. /**
  76654. * Sync impostor to a bone
  76655. * @param bone The bone that the impostor will be synced to.
  76656. * @param boneMesh The mesh that the bone is influencing.
  76657. * @param jointPivot The pivot of the joint / bone in local space.
  76658. * @param distToJoint Optional distance from the impostor to the joint.
  76659. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76660. * @param boneAxis Optional vector3 axis the bone is aligned with
  76661. */
  76662. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76663. /**
  76664. * No-Imposter type
  76665. */
  76666. static NoImpostor: number;
  76667. /**
  76668. * Sphere-Imposter type
  76669. */
  76670. static SphereImpostor: number;
  76671. /**
  76672. * Box-Imposter type
  76673. */
  76674. static BoxImpostor: number;
  76675. /**
  76676. * Plane-Imposter type
  76677. */
  76678. static PlaneImpostor: number;
  76679. /**
  76680. * Mesh-imposter type
  76681. */
  76682. static MeshImpostor: number;
  76683. /**
  76684. * Cylinder-Imposter type
  76685. */
  76686. static CylinderImpostor: number;
  76687. /**
  76688. * Particle-Imposter type
  76689. */
  76690. static ParticleImpostor: number;
  76691. /**
  76692. * Heightmap-Imposter type
  76693. */
  76694. static HeightmapImpostor: number;
  76695. }
  76696. }
  76697. declare module BABYLON {
  76698. /**
  76699. * Class used to represent a specific level of detail of a mesh
  76700. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76701. */
  76702. export class MeshLODLevel {
  76703. /** Defines the distance where this level should star being displayed */
  76704. distance: number;
  76705. /** Defines the mesh to use to render this level */
  76706. mesh: Nullable<Mesh>;
  76707. /**
  76708. * Creates a new LOD level
  76709. * @param distance defines the distance where this level should star being displayed
  76710. * @param mesh defines the mesh to use to render this level
  76711. */
  76712. constructor(
  76713. /** Defines the distance where this level should star being displayed */
  76714. distance: number,
  76715. /** Defines the mesh to use to render this level */
  76716. mesh: Nullable<Mesh>);
  76717. }
  76718. /**
  76719. * @hidden
  76720. **/
  76721. export class _CreationDataStorage {
  76722. closePath?: boolean;
  76723. closeArray?: boolean;
  76724. idx: number[];
  76725. dashSize: number;
  76726. gapSize: number;
  76727. path3D: Path3D;
  76728. pathArray: Vector3[][];
  76729. arc: number;
  76730. radius: number;
  76731. cap: number;
  76732. tessellation: number;
  76733. }
  76734. /**
  76735. * @hidden
  76736. **/
  76737. class _InstanceDataStorage {
  76738. visibleInstances: any;
  76739. renderIdForInstances: number[];
  76740. batchCache: _InstancesBatch;
  76741. instancesBufferSize: number;
  76742. instancesBuffer: Nullable<Buffer>;
  76743. instancesData: Float32Array;
  76744. overridenInstanceCount: number;
  76745. }
  76746. /**
  76747. * @hidden
  76748. **/
  76749. export class _InstancesBatch {
  76750. mustReturn: boolean;
  76751. visibleInstances: Nullable<InstancedMesh[]>[];
  76752. renderSelf: boolean[];
  76753. }
  76754. /**
  76755. * Class used to represent renderable models
  76756. */
  76757. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76758. /**
  76759. * Mesh side orientation : usually the external or front surface
  76760. */
  76761. static readonly FRONTSIDE: number;
  76762. /**
  76763. * Mesh side orientation : usually the internal or back surface
  76764. */
  76765. static readonly BACKSIDE: number;
  76766. /**
  76767. * Mesh side orientation : both internal and external or front and back surfaces
  76768. */
  76769. static readonly DOUBLESIDE: number;
  76770. /**
  76771. * Mesh side orientation : by default, `FRONTSIDE`
  76772. */
  76773. static readonly DEFAULTSIDE: number;
  76774. /**
  76775. * Mesh cap setting : no cap
  76776. */
  76777. static readonly NO_CAP: number;
  76778. /**
  76779. * Mesh cap setting : one cap at the beginning of the mesh
  76780. */
  76781. static readonly CAP_START: number;
  76782. /**
  76783. * Mesh cap setting : one cap at the end of the mesh
  76784. */
  76785. static readonly CAP_END: number;
  76786. /**
  76787. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76788. */
  76789. static readonly CAP_ALL: number;
  76790. /**
  76791. * Gets the default side orientation.
  76792. * @param orientation the orientation to value to attempt to get
  76793. * @returns the default orientation
  76794. * @hidden
  76795. */
  76796. static _GetDefaultSideOrientation(orientation?: number): number;
  76797. private _onBeforeRenderObservable;
  76798. private _onBeforeBindObservable;
  76799. private _onAfterRenderObservable;
  76800. private _onBeforeDrawObservable;
  76801. /**
  76802. * An event triggered before rendering the mesh
  76803. */
  76804. readonly onBeforeRenderObservable: Observable<Mesh>;
  76805. /**
  76806. * An event triggered before binding the mesh
  76807. */
  76808. readonly onBeforeBindObservable: Observable<Mesh>;
  76809. /**
  76810. * An event triggered after rendering the mesh
  76811. */
  76812. readonly onAfterRenderObservable: Observable<Mesh>;
  76813. /**
  76814. * An event triggered before drawing the mesh
  76815. */
  76816. readonly onBeforeDrawObservable: Observable<Mesh>;
  76817. private _onBeforeDrawObserver;
  76818. /**
  76819. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76820. */
  76821. onBeforeDraw: () => void;
  76822. /**
  76823. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76824. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76825. */
  76826. delayLoadState: number;
  76827. /**
  76828. * Gets the list of instances created from this mesh
  76829. * it is not supposed to be modified manually.
  76830. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76831. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76832. */
  76833. instances: InstancedMesh[];
  76834. /**
  76835. * Gets the file containing delay loading data for this mesh
  76836. */
  76837. delayLoadingFile: string;
  76838. /** @hidden */
  76839. _binaryInfo: any;
  76840. private _LODLevels;
  76841. /**
  76842. * User defined function used to change how LOD level selection is done
  76843. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76844. */
  76845. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76846. private _morphTargetManager;
  76847. /**
  76848. * Gets or sets the morph target manager
  76849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76850. */
  76851. morphTargetManager: Nullable<MorphTargetManager>;
  76852. /** @hidden */
  76853. _creationDataStorage: Nullable<_CreationDataStorage>;
  76854. /** @hidden */
  76855. _geometry: Nullable<Geometry>;
  76856. /** @hidden */
  76857. _delayInfo: Array<string>;
  76858. /** @hidden */
  76859. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76860. /** @hidden */
  76861. _instanceDataStorage: _InstanceDataStorage;
  76862. private _effectiveMaterial;
  76863. /** @hidden */
  76864. _shouldGenerateFlatShading: boolean;
  76865. private _preActivateId;
  76866. /** @hidden */
  76867. _originalBuilderSideOrientation: number;
  76868. /**
  76869. * Use this property to change the original side orientation defined at construction time
  76870. */
  76871. overrideMaterialSideOrientation: Nullable<number>;
  76872. private _areNormalsFrozen;
  76873. private _sourcePositions;
  76874. private _sourceNormals;
  76875. private _source;
  76876. private meshMap;
  76877. /**
  76878. * Gets the source mesh (the one used to clone this one from)
  76879. */
  76880. readonly source: Nullable<Mesh>;
  76881. /**
  76882. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76883. */
  76884. isUnIndexed: boolean;
  76885. /**
  76886. * @constructor
  76887. * @param name The value used by scene.getMeshByName() to do a lookup.
  76888. * @param scene The scene to add this mesh to.
  76889. * @param parent The parent of this mesh, if it has one
  76890. * @param source An optional Mesh from which geometry is shared, cloned.
  76891. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76892. * When false, achieved by calling a clone(), also passing False.
  76893. * This will make creation of children, recursive.
  76894. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76895. */
  76896. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76897. /**
  76898. * Gets the class name
  76899. * @returns the string "Mesh".
  76900. */
  76901. getClassName(): string;
  76902. /** @hidden */
  76903. readonly _isMesh: boolean;
  76904. /**
  76905. * Returns a description of this mesh
  76906. * @param fullDetails define if full details about this mesh must be used
  76907. * @returns a descriptive string representing this mesh
  76908. */
  76909. toString(fullDetails?: boolean): string;
  76910. /** @hidden */
  76911. _unBindEffect(): void;
  76912. /**
  76913. * Gets a boolean indicating if this mesh has LOD
  76914. */
  76915. readonly hasLODLevels: boolean;
  76916. /**
  76917. * Gets the list of MeshLODLevel associated with the current mesh
  76918. * @returns an array of MeshLODLevel
  76919. */
  76920. getLODLevels(): MeshLODLevel[];
  76921. private _sortLODLevels;
  76922. /**
  76923. * Add a mesh as LOD level triggered at the given distance.
  76924. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76925. * @param distance The distance from the center of the object to show this level
  76926. * @param mesh The mesh to be added as LOD level (can be null)
  76927. * @return This mesh (for chaining)
  76928. */
  76929. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76930. /**
  76931. * Returns the LOD level mesh at the passed distance or null if not found.
  76932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76933. * @param distance The distance from the center of the object to show this level
  76934. * @returns a Mesh or `null`
  76935. */
  76936. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76937. /**
  76938. * Remove a mesh from the LOD array
  76939. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76940. * @param mesh defines the mesh to be removed
  76941. * @return This mesh (for chaining)
  76942. */
  76943. removeLODLevel(mesh: Mesh): Mesh;
  76944. /**
  76945. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76947. * @param camera defines the camera to use to compute distance
  76948. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76949. * @return This mesh (for chaining)
  76950. */
  76951. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76952. /**
  76953. * Gets the mesh internal Geometry object
  76954. */
  76955. readonly geometry: Nullable<Geometry>;
  76956. /**
  76957. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76958. * @returns the total number of vertices
  76959. */
  76960. getTotalVertices(): number;
  76961. /**
  76962. * Returns the content of an associated vertex buffer
  76963. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76964. * - VertexBuffer.PositionKind
  76965. * - VertexBuffer.UVKind
  76966. * - VertexBuffer.UV2Kind
  76967. * - VertexBuffer.UV3Kind
  76968. * - VertexBuffer.UV4Kind
  76969. * - VertexBuffer.UV5Kind
  76970. * - VertexBuffer.UV6Kind
  76971. * - VertexBuffer.ColorKind
  76972. * - VertexBuffer.MatricesIndicesKind
  76973. * - VertexBuffer.MatricesIndicesExtraKind
  76974. * - VertexBuffer.MatricesWeightsKind
  76975. * - VertexBuffer.MatricesWeightsExtraKind
  76976. * @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
  76977. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76978. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76979. */
  76980. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76981. /**
  76982. * Returns the mesh VertexBuffer object from the requested `kind`
  76983. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76984. * - VertexBuffer.PositionKind
  76985. * - VertexBuffer.UVKind
  76986. * - VertexBuffer.UV2Kind
  76987. * - VertexBuffer.UV3Kind
  76988. * - VertexBuffer.UV4Kind
  76989. * - VertexBuffer.UV5Kind
  76990. * - VertexBuffer.UV6Kind
  76991. * - VertexBuffer.ColorKind
  76992. * - VertexBuffer.MatricesIndicesKind
  76993. * - VertexBuffer.MatricesIndicesExtraKind
  76994. * - VertexBuffer.MatricesWeightsKind
  76995. * - VertexBuffer.MatricesWeightsExtraKind
  76996. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76997. */
  76998. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76999. /**
  77000. * Tests if a specific vertex buffer is associated with this mesh
  77001. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77002. * - VertexBuffer.PositionKind
  77003. * - VertexBuffer.UVKind
  77004. * - VertexBuffer.UV2Kind
  77005. * - VertexBuffer.UV3Kind
  77006. * - VertexBuffer.UV4Kind
  77007. * - VertexBuffer.UV5Kind
  77008. * - VertexBuffer.UV6Kind
  77009. * - VertexBuffer.ColorKind
  77010. * - VertexBuffer.MatricesIndicesKind
  77011. * - VertexBuffer.MatricesIndicesExtraKind
  77012. * - VertexBuffer.MatricesWeightsKind
  77013. * - VertexBuffer.MatricesWeightsExtraKind
  77014. * @returns a boolean
  77015. */
  77016. isVerticesDataPresent(kind: string): boolean;
  77017. /**
  77018. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77019. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77020. * - VertexBuffer.PositionKind
  77021. * - VertexBuffer.UVKind
  77022. * - VertexBuffer.UV2Kind
  77023. * - VertexBuffer.UV3Kind
  77024. * - VertexBuffer.UV4Kind
  77025. * - VertexBuffer.UV5Kind
  77026. * - VertexBuffer.UV6Kind
  77027. * - VertexBuffer.ColorKind
  77028. * - VertexBuffer.MatricesIndicesKind
  77029. * - VertexBuffer.MatricesIndicesExtraKind
  77030. * - VertexBuffer.MatricesWeightsKind
  77031. * - VertexBuffer.MatricesWeightsExtraKind
  77032. * @returns a boolean
  77033. */
  77034. isVertexBufferUpdatable(kind: string): boolean;
  77035. /**
  77036. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77038. * - VertexBuffer.PositionKind
  77039. * - VertexBuffer.UVKind
  77040. * - VertexBuffer.UV2Kind
  77041. * - VertexBuffer.UV3Kind
  77042. * - VertexBuffer.UV4Kind
  77043. * - VertexBuffer.UV5Kind
  77044. * - VertexBuffer.UV6Kind
  77045. * - VertexBuffer.ColorKind
  77046. * - VertexBuffer.MatricesIndicesKind
  77047. * - VertexBuffer.MatricesIndicesExtraKind
  77048. * - VertexBuffer.MatricesWeightsKind
  77049. * - VertexBuffer.MatricesWeightsExtraKind
  77050. * @returns an array of strings
  77051. */
  77052. getVerticesDataKinds(): string[];
  77053. /**
  77054. * Returns a positive integer : the total number of indices in this mesh geometry.
  77055. * @returns the numner of indices or zero if the mesh has no geometry.
  77056. */
  77057. getTotalIndices(): number;
  77058. /**
  77059. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77060. * @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.
  77061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77062. * @returns the indices array or an empty array if the mesh has no geometry
  77063. */
  77064. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77065. readonly isBlocked: boolean;
  77066. /**
  77067. * Determine if the current mesh is ready to be rendered
  77068. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77069. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77070. * @returns true if all associated assets are ready (material, textures, shaders)
  77071. */
  77072. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77073. /**
  77074. * 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.
  77075. */
  77076. readonly areNormalsFrozen: boolean;
  77077. /**
  77078. * 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.
  77079. * @returns the current mesh
  77080. */
  77081. freezeNormals(): Mesh;
  77082. /**
  77083. * 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
  77084. * @returns the current mesh
  77085. */
  77086. unfreezeNormals(): Mesh;
  77087. /**
  77088. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77089. */
  77090. overridenInstanceCount: number;
  77091. /** @hidden */
  77092. _preActivate(): Mesh;
  77093. /** @hidden */
  77094. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77095. /** @hidden */
  77096. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77097. /**
  77098. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77099. * This means the mesh underlying bounding box and sphere are recomputed.
  77100. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77101. * @returns the current mesh
  77102. */
  77103. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77104. /** @hidden */
  77105. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77106. /**
  77107. * This function will subdivide the mesh into multiple submeshes
  77108. * @param count defines the expected number of submeshes
  77109. */
  77110. subdivide(count: number): void;
  77111. /**
  77112. * Copy a FloatArray into a specific associated vertex buffer
  77113. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77114. * - VertexBuffer.PositionKind
  77115. * - VertexBuffer.UVKind
  77116. * - VertexBuffer.UV2Kind
  77117. * - VertexBuffer.UV3Kind
  77118. * - VertexBuffer.UV4Kind
  77119. * - VertexBuffer.UV5Kind
  77120. * - VertexBuffer.UV6Kind
  77121. * - VertexBuffer.ColorKind
  77122. * - VertexBuffer.MatricesIndicesKind
  77123. * - VertexBuffer.MatricesIndicesExtraKind
  77124. * - VertexBuffer.MatricesWeightsKind
  77125. * - VertexBuffer.MatricesWeightsExtraKind
  77126. * @param data defines the data source
  77127. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77128. * @param stride defines the data stride size (can be null)
  77129. * @returns the current mesh
  77130. */
  77131. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77132. /**
  77133. * Flags an associated vertex buffer as updatable
  77134. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77135. * - VertexBuffer.PositionKind
  77136. * - VertexBuffer.UVKind
  77137. * - VertexBuffer.UV2Kind
  77138. * - VertexBuffer.UV3Kind
  77139. * - VertexBuffer.UV4Kind
  77140. * - VertexBuffer.UV5Kind
  77141. * - VertexBuffer.UV6Kind
  77142. * - VertexBuffer.ColorKind
  77143. * - VertexBuffer.MatricesIndicesKind
  77144. * - VertexBuffer.MatricesIndicesExtraKind
  77145. * - VertexBuffer.MatricesWeightsKind
  77146. * - VertexBuffer.MatricesWeightsExtraKind
  77147. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77148. */
  77149. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77150. /**
  77151. * Sets the mesh global Vertex Buffer
  77152. * @param buffer defines the buffer to use
  77153. * @returns the current mesh
  77154. */
  77155. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77156. /**
  77157. * Update a specific associated vertex buffer
  77158. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77159. * - VertexBuffer.PositionKind
  77160. * - VertexBuffer.UVKind
  77161. * - VertexBuffer.UV2Kind
  77162. * - VertexBuffer.UV3Kind
  77163. * - VertexBuffer.UV4Kind
  77164. * - VertexBuffer.UV5Kind
  77165. * - VertexBuffer.UV6Kind
  77166. * - VertexBuffer.ColorKind
  77167. * - VertexBuffer.MatricesIndicesKind
  77168. * - VertexBuffer.MatricesIndicesExtraKind
  77169. * - VertexBuffer.MatricesWeightsKind
  77170. * - VertexBuffer.MatricesWeightsExtraKind
  77171. * @param data defines the data source
  77172. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77173. * @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)
  77174. * @returns the current mesh
  77175. */
  77176. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77177. /**
  77178. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77179. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77180. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77181. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77182. * @returns the current mesh
  77183. */
  77184. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77185. /**
  77186. * Creates a un-shared specific occurence of the geometry for the mesh.
  77187. * @returns the current mesh
  77188. */
  77189. makeGeometryUnique(): Mesh;
  77190. /**
  77191. * Set the index buffer of this mesh
  77192. * @param indices defines the source data
  77193. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77194. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77195. * @returns the current mesh
  77196. */
  77197. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77198. /**
  77199. * Update the current index buffer
  77200. * @param indices defines the source data
  77201. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77202. * @returns the current mesh
  77203. */
  77204. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77205. /**
  77206. * Invert the geometry to move from a right handed system to a left handed one.
  77207. * @returns the current mesh
  77208. */
  77209. toLeftHanded(): Mesh;
  77210. /** @hidden */
  77211. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77212. /** @hidden */
  77213. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77214. /**
  77215. * Registers for this mesh a javascript function called just before the rendering process
  77216. * @param func defines the function to call before rendering this mesh
  77217. * @returns the current mesh
  77218. */
  77219. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77220. /**
  77221. * Disposes a previously registered javascript function called before the rendering
  77222. * @param func defines the function to remove
  77223. * @returns the current mesh
  77224. */
  77225. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77226. /**
  77227. * Registers for this mesh a javascript function called just after the rendering is complete
  77228. * @param func defines the function to call after rendering this mesh
  77229. * @returns the current mesh
  77230. */
  77231. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77232. /**
  77233. * Disposes a previously registered javascript function called after the rendering.
  77234. * @param func defines the function to remove
  77235. * @returns the current mesh
  77236. */
  77237. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77238. /** @hidden */
  77239. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77240. /** @hidden */
  77241. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77242. /** @hidden */
  77243. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77244. /**
  77245. * 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
  77246. * @param subMesh defines the subMesh to render
  77247. * @param enableAlphaMode defines if alpha mode can be changed
  77248. * @returns the current mesh
  77249. */
  77250. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77251. private _onBeforeDraw;
  77252. /**
  77253. * Renormalize the mesh and patch it up if there are no weights
  77254. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77255. * However in the case of zero weights then we set just a single influence to 1.
  77256. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77257. */
  77258. cleanMatrixWeights(): void;
  77259. private normalizeSkinFourWeights;
  77260. private normalizeSkinWeightsAndExtra;
  77261. /**
  77262. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77263. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77264. * the user know there was an issue with importing the mesh
  77265. * @returns a validation object with skinned, valid and report string
  77266. */
  77267. validateSkinning(): {
  77268. skinned: boolean;
  77269. valid: boolean;
  77270. report: string;
  77271. };
  77272. /** @hidden */
  77273. _checkDelayState(): Mesh;
  77274. private _queueLoad;
  77275. /**
  77276. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77277. * A mesh is in the frustum if its bounding box intersects the frustum
  77278. * @param frustumPlanes defines the frustum to test
  77279. * @returns true if the mesh is in the frustum planes
  77280. */
  77281. isInFrustum(frustumPlanes: Plane[]): boolean;
  77282. /**
  77283. * Sets the mesh material by the material or multiMaterial `id` property
  77284. * @param id is a string identifying the material or the multiMaterial
  77285. * @returns the current mesh
  77286. */
  77287. setMaterialByID(id: string): Mesh;
  77288. /**
  77289. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77290. * @returns an array of IAnimatable
  77291. */
  77292. getAnimatables(): IAnimatable[];
  77293. /**
  77294. * Modifies the mesh geometry according to the passed transformation matrix.
  77295. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77296. * The mesh normals are modified using the same transformation.
  77297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77298. * @param transform defines the transform matrix to use
  77299. * @see http://doc.babylonjs.com/resources/baking_transformations
  77300. * @returns the current mesh
  77301. */
  77302. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77303. /**
  77304. * Modifies the mesh geometry according to its own current World Matrix.
  77305. * The mesh World Matrix is then reset.
  77306. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77307. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77308. * @see http://doc.babylonjs.com/resources/baking_transformations
  77309. * @returns the current mesh
  77310. */
  77311. bakeCurrentTransformIntoVertices(): Mesh;
  77312. /** @hidden */
  77313. readonly _positions: Nullable<Vector3[]>;
  77314. /** @hidden */
  77315. _resetPointsArrayCache(): Mesh;
  77316. /** @hidden */
  77317. _generatePointsArray(): boolean;
  77318. /**
  77319. * Returns a new Mesh object generated from the current mesh properties.
  77320. * This method must not get confused with createInstance()
  77321. * @param name is a string, the name given to the new mesh
  77322. * @param newParent can be any Node object (default `null`)
  77323. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77324. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77325. * @returns a new mesh
  77326. */
  77327. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77328. /**
  77329. * Releases resources associated with this mesh.
  77330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77332. */
  77333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77334. /**
  77335. * Modifies the mesh geometry according to a displacement map.
  77336. * 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.
  77337. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77338. * @param url is a string, the URL from the image file is to be downloaded.
  77339. * @param minHeight is the lower limit of the displacement.
  77340. * @param maxHeight is the upper limit of the displacement.
  77341. * @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.
  77342. * @param uvOffset is an optional vector2 used to offset UV.
  77343. * @param uvScale is an optional vector2 used to scale UV.
  77344. * @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.
  77345. * @returns the Mesh.
  77346. */
  77347. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77348. /**
  77349. * Modifies the mesh geometry according to a displacementMap buffer.
  77350. * 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.
  77351. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77352. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77353. * @param heightMapWidth is the width of the buffer image.
  77354. * @param heightMapHeight is the height of the buffer image.
  77355. * @param minHeight is the lower limit of the displacement.
  77356. * @param maxHeight is the upper limit of the displacement.
  77357. * @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.
  77358. * @param uvOffset is an optional vector2 used to offset UV.
  77359. * @param uvScale is an optional vector2 used to scale UV.
  77360. * @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.
  77361. * @returns the Mesh.
  77362. */
  77363. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77364. /**
  77365. * Modify the mesh to get a flat shading rendering.
  77366. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77367. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77368. * @returns current mesh
  77369. */
  77370. convertToFlatShadedMesh(): Mesh;
  77371. /**
  77372. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77373. * In other words, more vertices, no more indices and a single bigger VBO.
  77374. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77375. * @returns current mesh
  77376. */
  77377. convertToUnIndexedMesh(): Mesh;
  77378. /**
  77379. * Inverses facet orientations.
  77380. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77381. * @param flipNormals will also inverts the normals
  77382. * @returns current mesh
  77383. */
  77384. flipFaces(flipNormals?: boolean): Mesh;
  77385. /** @hidden */
  77386. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77387. /** @hidden */
  77388. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77389. /**
  77390. * Creates a new InstancedMesh object from the mesh model.
  77391. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77392. * @param name defines the name of the new instance
  77393. * @returns a new InstancedMesh
  77394. */
  77395. createInstance(name: string): InstancedMesh;
  77396. /**
  77397. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77398. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77399. * @returns the current mesh
  77400. */
  77401. synchronizeInstances(): Mesh;
  77402. /**
  77403. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77404. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77405. * This should be used together with the simplification to avoid disappearing triangles.
  77406. * @param successCallback an optional success callback to be called after the optimization finished.
  77407. * @returns the current mesh
  77408. */
  77409. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77410. /**
  77411. * Serialize current mesh
  77412. * @param serializationObject defines the object which will receive the serialization data
  77413. */
  77414. serialize(serializationObject: any): void;
  77415. /** @hidden */
  77416. _syncGeometryWithMorphTargetManager(): void;
  77417. /** @hidden */
  77418. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77419. /**
  77420. * Returns a new Mesh object parsed from the source provided.
  77421. * @param parsedMesh is the source
  77422. * @param scene defines the hosting scene
  77423. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77424. * @returns a new Mesh
  77425. */
  77426. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77427. /**
  77428. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77429. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77430. * @param name defines the name of the mesh to create
  77431. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77432. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77433. * @param closePath creates a seam between the first and the last points of each path of the path array
  77434. * @param offset is taken in account only if the `pathArray` is containing a single path
  77435. * @param scene defines the hosting scene
  77436. * @param updatable defines if the mesh must be flagged as updatable
  77437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77438. * @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)
  77439. * @returns a new Mesh
  77440. */
  77441. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77442. /**
  77443. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77444. * @param name defines the name of the mesh to create
  77445. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77446. * @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
  77447. * @param scene defines the hosting scene
  77448. * @param updatable defines if the mesh must be flagged as updatable
  77449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77450. * @returns a new Mesh
  77451. */
  77452. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77453. /**
  77454. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77455. * @param name defines the name of the mesh to create
  77456. * @param size sets the size (float) of each box side (default 1)
  77457. * @param scene defines the hosting scene
  77458. * @param updatable defines if the mesh must be flagged as updatable
  77459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77460. * @returns a new Mesh
  77461. */
  77462. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77463. /**
  77464. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77465. * @param name defines the name of the mesh to create
  77466. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77467. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77468. * @param scene defines the hosting scene
  77469. * @param updatable defines if the mesh must be flagged as updatable
  77470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77471. * @returns a new Mesh
  77472. */
  77473. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77474. /**
  77475. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77476. * @param name defines the name of the mesh to create
  77477. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77478. * @param diameterTop set the top cap diameter (floats, default 1)
  77479. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77480. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77481. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77482. * @param scene defines the hosting scene
  77483. * @param updatable defines if the mesh must be flagged as updatable
  77484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77485. * @returns a new Mesh
  77486. */
  77487. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77488. /**
  77489. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77490. * @param name defines the name of the mesh to create
  77491. * @param diameter sets the diameter size (float) of the torus (default 1)
  77492. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77493. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77494. * @param scene defines the hosting scene
  77495. * @param updatable defines if the mesh must be flagged as updatable
  77496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77497. * @returns a new Mesh
  77498. */
  77499. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77500. /**
  77501. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77502. * @param name defines the name of the mesh to create
  77503. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77504. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77505. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77506. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77507. * @param p the number of windings on X axis (positive integers, default 2)
  77508. * @param q the number of windings on Y axis (positive integers, default 3)
  77509. * @param scene defines the hosting scene
  77510. * @param updatable defines if the mesh must be flagged as updatable
  77511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77512. * @returns a new Mesh
  77513. */
  77514. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77515. /**
  77516. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77517. * @param name defines the name of the mesh to create
  77518. * @param points is an array successive Vector3
  77519. * @param scene defines the hosting scene
  77520. * @param updatable defines if the mesh must be flagged as updatable
  77521. * @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).
  77522. * @returns a new Mesh
  77523. */
  77524. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77525. /**
  77526. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77527. * @param name defines the name of the mesh to create
  77528. * @param points is an array successive Vector3
  77529. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77530. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77531. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77532. * @param scene defines the hosting scene
  77533. * @param updatable defines if the mesh must be flagged as updatable
  77534. * @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)
  77535. * @returns a new Mesh
  77536. */
  77537. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77538. /**
  77539. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77540. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77541. * 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.
  77542. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77543. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77544. * Remember you can only change the shape positions, not their number when updating a polygon.
  77545. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77546. * @param name defines the name of the mesh to create
  77547. * @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
  77548. * @param scene defines the hosting scene
  77549. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77550. * @param updatable defines if the mesh must be flagged as updatable
  77551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77552. * @param earcutInjection can be used to inject your own earcut reference
  77553. * @returns a new Mesh
  77554. */
  77555. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77556. /**
  77557. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77558. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77559. * @param name defines the name of the mesh to create
  77560. * @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
  77561. * @param depth defines the height of extrusion
  77562. * @param scene defines the hosting scene
  77563. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77564. * @param updatable defines if the mesh must be flagged as updatable
  77565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77566. * @param earcutInjection can be used to inject your own earcut reference
  77567. * @returns a new Mesh
  77568. */
  77569. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77570. /**
  77571. * Creates an extruded shape mesh.
  77572. * 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
  77573. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77574. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77575. * @param name defines the name of the mesh to create
  77576. * @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
  77577. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77578. * @param scale is the value to scale the shape
  77579. * @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
  77580. * @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
  77581. * @param scene defines the hosting scene
  77582. * @param updatable defines if the mesh must be flagged as updatable
  77583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77584. * @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)
  77585. * @returns a new Mesh
  77586. */
  77587. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77588. /**
  77589. * Creates an custom extruded shape mesh.
  77590. * The custom extrusion is a parametric shape.
  77591. * It has no predefined shape. Its final shape will depend on the input parameters.
  77592. * Please consider using the same method from the MeshBuilder class instead
  77593. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77594. * @param name defines the name of the mesh to create
  77595. * @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
  77596. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77597. * @param scaleFunction is a custom Javascript function called on each path point
  77598. * @param rotationFunction is a custom Javascript function called on each path point
  77599. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77600. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77601. * @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
  77602. * @param scene defines the hosting scene
  77603. * @param updatable defines if the mesh must be flagged as updatable
  77604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77605. * @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)
  77606. * @returns a new Mesh
  77607. */
  77608. 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;
  77609. /**
  77610. * Creates lathe mesh.
  77611. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77612. * Please consider using the same method from the MeshBuilder class instead
  77613. * @param name defines the name of the mesh to create
  77614. * @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
  77615. * @param radius is the radius value of the lathe
  77616. * @param tessellation is the side number of the lathe.
  77617. * @param scene defines the hosting scene
  77618. * @param updatable defines if the mesh must be flagged as updatable
  77619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77620. * @returns a new Mesh
  77621. */
  77622. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77623. /**
  77624. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77625. * @param name defines the name of the mesh to create
  77626. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77627. * @param scene defines the hosting scene
  77628. * @param updatable defines if the mesh must be flagged as updatable
  77629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77630. * @returns a new Mesh
  77631. */
  77632. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77633. /**
  77634. * Creates a ground mesh.
  77635. * Please consider using the same method from the MeshBuilder class instead
  77636. * @param name defines the name of the mesh to create
  77637. * @param width set the width of the ground
  77638. * @param height set the height of the ground
  77639. * @param subdivisions sets the number of subdivisions per side
  77640. * @param scene defines the hosting scene
  77641. * @param updatable defines if the mesh must be flagged as updatable
  77642. * @returns a new Mesh
  77643. */
  77644. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77645. /**
  77646. * Creates a tiled ground mesh.
  77647. * Please consider using the same method from the MeshBuilder class instead
  77648. * @param name defines the name of the mesh to create
  77649. * @param xmin set the ground minimum X coordinate
  77650. * @param zmin set the ground minimum Y coordinate
  77651. * @param xmax set the ground maximum X coordinate
  77652. * @param zmax set the ground maximum Z coordinate
  77653. * @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
  77654. * @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
  77655. * @param scene defines the hosting scene
  77656. * @param updatable defines if the mesh must be flagged as updatable
  77657. * @returns a new Mesh
  77658. */
  77659. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77660. w: number;
  77661. h: number;
  77662. }, precision: {
  77663. w: number;
  77664. h: number;
  77665. }, scene: Scene, updatable?: boolean): Mesh;
  77666. /**
  77667. * Creates a ground mesh from a height map.
  77668. * Please consider using the same method from the MeshBuilder class instead
  77669. * @see http://doc.babylonjs.com/babylon101/height_map
  77670. * @param name defines the name of the mesh to create
  77671. * @param url sets the URL of the height map image resource
  77672. * @param width set the ground width size
  77673. * @param height set the ground height size
  77674. * @param subdivisions sets the number of subdivision per side
  77675. * @param minHeight is the minimum altitude on the ground
  77676. * @param maxHeight is the maximum altitude on the ground
  77677. * @param scene defines the hosting scene
  77678. * @param updatable defines if the mesh must be flagged as updatable
  77679. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77680. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77681. * @returns a new Mesh
  77682. */
  77683. 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;
  77684. /**
  77685. * Creates a tube mesh.
  77686. * The tube is a parametric shape.
  77687. * It has no predefined shape. Its final shape will depend on the input parameters.
  77688. * Please consider using the same method from the MeshBuilder class instead
  77689. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77690. * @param name defines the name of the mesh to create
  77691. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77692. * @param radius sets the tube radius size
  77693. * @param tessellation is the number of sides on the tubular surface
  77694. * @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
  77695. * @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
  77696. * @param scene defines the hosting scene
  77697. * @param updatable defines if the mesh must be flagged as updatable
  77698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77699. * @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)
  77700. * @returns a new Mesh
  77701. */
  77702. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77703. (i: number, distance: number): number;
  77704. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77705. /**
  77706. * Creates a polyhedron mesh.
  77707. * Please consider using the same method from the MeshBuilder class instead.
  77708. * * 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
  77709. * * The parameter `size` (positive float, default 1) sets the polygon size
  77710. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77711. * * 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`
  77712. * * 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
  77713. * * 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)`)
  77714. * * 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
  77715. * * 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
  77716. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77717. * * If you create a double-sided mesh, you can choose what parts of 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
  77718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77719. * @param name defines the name of the mesh to create
  77720. * @param options defines the options used to create the mesh
  77721. * @param scene defines the hosting scene
  77722. * @returns a new Mesh
  77723. */
  77724. static CreatePolyhedron(name: string, options: {
  77725. type?: number;
  77726. size?: number;
  77727. sizeX?: number;
  77728. sizeY?: number;
  77729. sizeZ?: number;
  77730. custom?: any;
  77731. faceUV?: Vector4[];
  77732. faceColors?: Color4[];
  77733. updatable?: boolean;
  77734. sideOrientation?: number;
  77735. }, scene: Scene): Mesh;
  77736. /**
  77737. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77738. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77739. * * 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`)
  77740. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77741. * * 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
  77742. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77743. * * If you create a double-sided mesh, you can choose what parts of 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
  77744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77745. * @param name defines the name of the mesh
  77746. * @param options defines the options used to create the mesh
  77747. * @param scene defines the hosting scene
  77748. * @returns a new Mesh
  77749. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77750. */
  77751. static CreateIcoSphere(name: string, options: {
  77752. radius?: number;
  77753. flat?: boolean;
  77754. subdivisions?: number;
  77755. sideOrientation?: number;
  77756. updatable?: boolean;
  77757. }, scene: Scene): Mesh;
  77758. /**
  77759. * Creates a decal mesh.
  77760. * Please consider using the same method from the MeshBuilder class instead.
  77761. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77762. * @param name defines the name of the mesh
  77763. * @param sourceMesh defines the mesh receiving the decal
  77764. * @param position sets the position of the decal in world coordinates
  77765. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77766. * @param size sets the decal scaling
  77767. * @param angle sets the angle to rotate the decal
  77768. * @returns a new Mesh
  77769. */
  77770. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77771. /**
  77772. * Prepare internal position array for software CPU skinning
  77773. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77774. */
  77775. setPositionsForCPUSkinning(): Float32Array;
  77776. /**
  77777. * Prepare internal normal array for software CPU skinning
  77778. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77779. */
  77780. setNormalsForCPUSkinning(): Float32Array;
  77781. /**
  77782. * Updates the vertex buffer by applying transformation from the bones
  77783. * @param skeleton defines the skeleton to apply to current mesh
  77784. * @returns the current mesh
  77785. */
  77786. applySkeleton(skeleton: Skeleton): Mesh;
  77787. /**
  77788. * 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
  77789. * @param meshes defines the list of meshes to scan
  77790. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77791. */
  77792. static MinMax(meshes: AbstractMesh[]): {
  77793. min: Vector3;
  77794. max: Vector3;
  77795. };
  77796. /**
  77797. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77798. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77799. * @returns a vector3
  77800. */
  77801. static Center(meshesOrMinMaxVector: {
  77802. min: Vector3;
  77803. max: Vector3;
  77804. } | AbstractMesh[]): Vector3;
  77805. /**
  77806. * Merge the array of meshes into a single mesh for performance reasons.
  77807. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77808. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77809. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77810. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77811. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77812. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77813. * @returns a new mesh
  77814. */
  77815. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77816. /** @hidden */
  77817. addInstance(instance: InstancedMesh): void;
  77818. /** @hidden */
  77819. removeInstance(instance: InstancedMesh): void;
  77820. }
  77821. }
  77822. declare module BABYLON {
  77823. /**
  77824. * Base class for the main features of a material in Babylon.js
  77825. */
  77826. export class Material implements IAnimatable {
  77827. /**
  77828. * Returns the triangle fill mode
  77829. */
  77830. static readonly TriangleFillMode: number;
  77831. /**
  77832. * Returns the wireframe mode
  77833. */
  77834. static readonly WireFrameFillMode: number;
  77835. /**
  77836. * Returns the point fill mode
  77837. */
  77838. static readonly PointFillMode: number;
  77839. /**
  77840. * Returns the point list draw mode
  77841. */
  77842. static readonly PointListDrawMode: number;
  77843. /**
  77844. * Returns the line list draw mode
  77845. */
  77846. static readonly LineListDrawMode: number;
  77847. /**
  77848. * Returns the line loop draw mode
  77849. */
  77850. static readonly LineLoopDrawMode: number;
  77851. /**
  77852. * Returns the line strip draw mode
  77853. */
  77854. static readonly LineStripDrawMode: number;
  77855. /**
  77856. * Returns the triangle strip draw mode
  77857. */
  77858. static readonly TriangleStripDrawMode: number;
  77859. /**
  77860. * Returns the triangle fan draw mode
  77861. */
  77862. static readonly TriangleFanDrawMode: number;
  77863. /**
  77864. * Stores the clock-wise side orientation
  77865. */
  77866. static readonly ClockWiseSideOrientation: number;
  77867. /**
  77868. * Stores the counter clock-wise side orientation
  77869. */
  77870. static readonly CounterClockWiseSideOrientation: number;
  77871. /**
  77872. * The dirty texture flag value
  77873. */
  77874. static readonly TextureDirtyFlag: number;
  77875. /**
  77876. * The dirty light flag value
  77877. */
  77878. static readonly LightDirtyFlag: number;
  77879. /**
  77880. * The dirty fresnel flag value
  77881. */
  77882. static readonly FresnelDirtyFlag: number;
  77883. /**
  77884. * The dirty attribute flag value
  77885. */
  77886. static readonly AttributesDirtyFlag: number;
  77887. /**
  77888. * The dirty misc flag value
  77889. */
  77890. static readonly MiscDirtyFlag: number;
  77891. /**
  77892. * The all dirty flag value
  77893. */
  77894. static readonly AllDirtyFlag: number;
  77895. /**
  77896. * The ID of the material
  77897. */
  77898. id: string;
  77899. /**
  77900. * Gets or sets the unique id of the material
  77901. */
  77902. uniqueId: number;
  77903. /**
  77904. * The name of the material
  77905. */
  77906. name: string;
  77907. /**
  77908. * Gets or sets user defined metadata
  77909. */
  77910. metadata: any;
  77911. /**
  77912. * For internal use only. Please do not use.
  77913. */
  77914. reservedDataStore: any;
  77915. /**
  77916. * Specifies if the ready state should be checked on each call
  77917. */
  77918. checkReadyOnEveryCall: boolean;
  77919. /**
  77920. * Specifies if the ready state should be checked once
  77921. */
  77922. checkReadyOnlyOnce: boolean;
  77923. /**
  77924. * The state of the material
  77925. */
  77926. state: string;
  77927. /**
  77928. * The alpha value of the material
  77929. */
  77930. protected _alpha: number;
  77931. /**
  77932. * Sets the alpha value of the material
  77933. */
  77934. /**
  77935. * Gets the alpha value of the material
  77936. */
  77937. alpha: number;
  77938. /**
  77939. * Specifies if back face culling is enabled
  77940. */
  77941. protected _backFaceCulling: boolean;
  77942. /**
  77943. * Sets the back-face culling state
  77944. */
  77945. /**
  77946. * Gets the back-face culling state
  77947. */
  77948. backFaceCulling: boolean;
  77949. /**
  77950. * Stores the value for side orientation
  77951. */
  77952. sideOrientation: number;
  77953. /**
  77954. * Callback triggered when the material is compiled
  77955. */
  77956. onCompiled: (effect: Effect) => void;
  77957. /**
  77958. * Callback triggered when an error occurs
  77959. */
  77960. onError: (effect: Effect, errors: string) => void;
  77961. /**
  77962. * Callback triggered to get the render target textures
  77963. */
  77964. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  77965. /**
  77966. * Gets a boolean indicating that current material needs to register RTT
  77967. */
  77968. readonly hasRenderTargetTextures: boolean;
  77969. /**
  77970. * Specifies if the material should be serialized
  77971. */
  77972. doNotSerialize: boolean;
  77973. /**
  77974. * @hidden
  77975. */
  77976. _storeEffectOnSubMeshes: boolean;
  77977. /**
  77978. * Stores the animations for the material
  77979. */
  77980. animations: Array<Animation>;
  77981. /**
  77982. * An event triggered when the material is disposed
  77983. */
  77984. onDisposeObservable: Observable<Material>;
  77985. /**
  77986. * An observer which watches for dispose events
  77987. */
  77988. private _onDisposeObserver;
  77989. private _onUnBindObservable;
  77990. /**
  77991. * Called during a dispose event
  77992. */
  77993. onDispose: () => void;
  77994. private _onBindObservable;
  77995. /**
  77996. * An event triggered when the material is bound
  77997. */
  77998. readonly onBindObservable: Observable<AbstractMesh>;
  77999. /**
  78000. * An observer which watches for bind events
  78001. */
  78002. private _onBindObserver;
  78003. /**
  78004. * Called during a bind event
  78005. */
  78006. onBind: (Mesh: AbstractMesh) => void;
  78007. /**
  78008. * An event triggered when the material is unbound
  78009. */
  78010. readonly onUnBindObservable: Observable<Material>;
  78011. /**
  78012. * Stores the value of the alpha mode
  78013. */
  78014. private _alphaMode;
  78015. /**
  78016. * Sets the value of the alpha mode.
  78017. *
  78018. * | Value | Type | Description |
  78019. * | --- | --- | --- |
  78020. * | 0 | ALPHA_DISABLE | |
  78021. * | 1 | ALPHA_ADD | |
  78022. * | 2 | ALPHA_COMBINE | |
  78023. * | 3 | ALPHA_SUBTRACT | |
  78024. * | 4 | ALPHA_MULTIPLY | |
  78025. * | 5 | ALPHA_MAXIMIZED | |
  78026. * | 6 | ALPHA_ONEONE | |
  78027. * | 7 | ALPHA_PREMULTIPLIED | |
  78028. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78029. * | 9 | ALPHA_INTERPOLATE | |
  78030. * | 10 | ALPHA_SCREENMODE | |
  78031. *
  78032. */
  78033. /**
  78034. * Gets the value of the alpha mode
  78035. */
  78036. alphaMode: number;
  78037. /**
  78038. * Stores the state of the need depth pre-pass value
  78039. */
  78040. private _needDepthPrePass;
  78041. /**
  78042. * Sets the need depth pre-pass value
  78043. */
  78044. /**
  78045. * Gets the depth pre-pass value
  78046. */
  78047. needDepthPrePass: boolean;
  78048. /**
  78049. * Specifies if depth writing should be disabled
  78050. */
  78051. disableDepthWrite: boolean;
  78052. /**
  78053. * Specifies if depth writing should be forced
  78054. */
  78055. forceDepthWrite: boolean;
  78056. /**
  78057. * Specifies if there should be a separate pass for culling
  78058. */
  78059. separateCullingPass: boolean;
  78060. /**
  78061. * Stores the state specifing if fog should be enabled
  78062. */
  78063. private _fogEnabled;
  78064. /**
  78065. * Sets the state for enabling fog
  78066. */
  78067. /**
  78068. * Gets the value of the fog enabled state
  78069. */
  78070. fogEnabled: boolean;
  78071. /**
  78072. * Stores the size of points
  78073. */
  78074. pointSize: number;
  78075. /**
  78076. * Stores the z offset value
  78077. */
  78078. zOffset: number;
  78079. /**
  78080. * Gets a value specifying if wireframe mode is enabled
  78081. */
  78082. /**
  78083. * Sets the state of wireframe mode
  78084. */
  78085. wireframe: boolean;
  78086. /**
  78087. * Gets the value specifying if point clouds are enabled
  78088. */
  78089. /**
  78090. * Sets the state of point cloud mode
  78091. */
  78092. pointsCloud: boolean;
  78093. /**
  78094. * Gets the material fill mode
  78095. */
  78096. /**
  78097. * Sets the material fill mode
  78098. */
  78099. fillMode: number;
  78100. /**
  78101. * @hidden
  78102. * Stores the effects for the material
  78103. */
  78104. _effect: Nullable<Effect>;
  78105. /**
  78106. * @hidden
  78107. * Specifies if the material was previously ready
  78108. */
  78109. _wasPreviouslyReady: boolean;
  78110. /**
  78111. * Specifies if uniform buffers should be used
  78112. */
  78113. private _useUBO;
  78114. /**
  78115. * Stores a reference to the scene
  78116. */
  78117. private _scene;
  78118. /**
  78119. * Stores the fill mode state
  78120. */
  78121. private _fillMode;
  78122. /**
  78123. * Specifies if the depth write state should be cached
  78124. */
  78125. private _cachedDepthWriteState;
  78126. /**
  78127. * Stores the uniform buffer
  78128. */
  78129. protected _uniformBuffer: UniformBuffer;
  78130. /** @hidden */
  78131. _indexInSceneMaterialArray: number;
  78132. /** @hidden */
  78133. meshMap: Nullable<{
  78134. [id: string]: AbstractMesh | undefined;
  78135. }>;
  78136. /**
  78137. * Creates a material instance
  78138. * @param name defines the name of the material
  78139. * @param scene defines the scene to reference
  78140. * @param doNotAdd specifies if the material should be added to the scene
  78141. */
  78142. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78143. /**
  78144. * Returns a string representation of the current material
  78145. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78146. * @returns a string with material information
  78147. */
  78148. toString(fullDetails?: boolean): string;
  78149. /**
  78150. * Gets the class name of the material
  78151. * @returns a string with the class name of the material
  78152. */
  78153. getClassName(): string;
  78154. /**
  78155. * Specifies if updates for the material been locked
  78156. */
  78157. readonly isFrozen: boolean;
  78158. /**
  78159. * Locks updates for the material
  78160. */
  78161. freeze(): void;
  78162. /**
  78163. * Unlocks updates for the material
  78164. */
  78165. unfreeze(): void;
  78166. /**
  78167. * Specifies if the material is ready to be used
  78168. * @param mesh defines the mesh to check
  78169. * @param useInstances specifies if instances should be used
  78170. * @returns a boolean indicating if the material is ready to be used
  78171. */
  78172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78173. /**
  78174. * Specifies that the submesh is ready to be used
  78175. * @param mesh defines the mesh to check
  78176. * @param subMesh defines which submesh to check
  78177. * @param useInstances specifies that instances should be used
  78178. * @returns a boolean indicating that the submesh is ready or not
  78179. */
  78180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78181. /**
  78182. * Returns the material effect
  78183. * @returns the effect associated with the material
  78184. */
  78185. getEffect(): Nullable<Effect>;
  78186. /**
  78187. * Returns the current scene
  78188. * @returns a Scene
  78189. */
  78190. getScene(): Scene;
  78191. /**
  78192. * Specifies if the material will require alpha blending
  78193. * @returns a boolean specifying if alpha blending is needed
  78194. */
  78195. needAlphaBlending(): boolean;
  78196. /**
  78197. * Specifies if the mesh will require alpha blending
  78198. * @param mesh defines the mesh to check
  78199. * @returns a boolean specifying if alpha blending is needed for the mesh
  78200. */
  78201. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78202. /**
  78203. * Specifies if this material should be rendered in alpha test mode
  78204. * @returns a boolean specifying if an alpha test is needed.
  78205. */
  78206. needAlphaTesting(): boolean;
  78207. /**
  78208. * Gets the texture used for the alpha test
  78209. * @returns the texture to use for alpha testing
  78210. */
  78211. getAlphaTestTexture(): Nullable<BaseTexture>;
  78212. /**
  78213. * Marks the material to indicate that it needs to be re-calculated
  78214. */
  78215. markDirty(): void;
  78216. /** @hidden */
  78217. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78218. /**
  78219. * Binds the material to the mesh
  78220. * @param world defines the world transformation matrix
  78221. * @param mesh defines the mesh to bind the material to
  78222. */
  78223. bind(world: Matrix, mesh?: Mesh): void;
  78224. /**
  78225. * Binds the submesh to the material
  78226. * @param world defines the world transformation matrix
  78227. * @param mesh defines the mesh containing the submesh
  78228. * @param subMesh defines the submesh to bind the material to
  78229. */
  78230. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78231. /**
  78232. * Binds the world matrix to the material
  78233. * @param world defines the world transformation matrix
  78234. */
  78235. bindOnlyWorldMatrix(world: Matrix): void;
  78236. /**
  78237. * Binds the scene's uniform buffer to the effect.
  78238. * @param effect defines the effect to bind to the scene uniform buffer
  78239. * @param sceneUbo defines the uniform buffer storing scene data
  78240. */
  78241. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78242. /**
  78243. * Binds the view matrix to the effect
  78244. * @param effect defines the effect to bind the view matrix to
  78245. */
  78246. bindView(effect: Effect): void;
  78247. /**
  78248. * Binds the view projection matrix to the effect
  78249. * @param effect defines the effect to bind the view projection matrix to
  78250. */
  78251. bindViewProjection(effect: Effect): void;
  78252. /**
  78253. * Specifies if material alpha testing should be turned on for the mesh
  78254. * @param mesh defines the mesh to check
  78255. */
  78256. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78257. /**
  78258. * Processes to execute after binding the material to a mesh
  78259. * @param mesh defines the rendered mesh
  78260. */
  78261. protected _afterBind(mesh?: Mesh): void;
  78262. /**
  78263. * Unbinds the material from the mesh
  78264. */
  78265. unbind(): void;
  78266. /**
  78267. * Gets the active textures from the material
  78268. * @returns an array of textures
  78269. */
  78270. getActiveTextures(): BaseTexture[];
  78271. /**
  78272. * Specifies if the material uses a texture
  78273. * @param texture defines the texture to check against the material
  78274. * @returns a boolean specifying if the material uses the texture
  78275. */
  78276. hasTexture(texture: BaseTexture): boolean;
  78277. /**
  78278. * Makes a duplicate of the material, and gives it a new name
  78279. * @param name defines the new name for the duplicated material
  78280. * @returns the cloned material
  78281. */
  78282. clone(name: string): Nullable<Material>;
  78283. /**
  78284. * Gets the meshes bound to the material
  78285. * @returns an array of meshes bound to the material
  78286. */
  78287. getBindedMeshes(): AbstractMesh[];
  78288. /**
  78289. * Force shader compilation
  78290. * @param mesh defines the mesh associated with this material
  78291. * @param onCompiled defines a function to execute once the material is compiled
  78292. * @param options defines the options to configure the compilation
  78293. */
  78294. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78295. clipPlane: boolean;
  78296. }>): void;
  78297. /**
  78298. * Force shader compilation
  78299. * @param mesh defines the mesh that will use this material
  78300. * @param options defines additional options for compiling the shaders
  78301. * @returns a promise that resolves when the compilation completes
  78302. */
  78303. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78304. clipPlane: boolean;
  78305. }>): Promise<void>;
  78306. private static readonly _ImageProcessingDirtyCallBack;
  78307. private static readonly _TextureDirtyCallBack;
  78308. private static readonly _FresnelDirtyCallBack;
  78309. private static readonly _MiscDirtyCallBack;
  78310. private static readonly _LightsDirtyCallBack;
  78311. private static readonly _AttributeDirtyCallBack;
  78312. private static _FresnelAndMiscDirtyCallBack;
  78313. private static _TextureAndMiscDirtyCallBack;
  78314. private static readonly _DirtyCallbackArray;
  78315. private static readonly _RunDirtyCallBacks;
  78316. /**
  78317. * Marks a define in the material to indicate that it needs to be re-computed
  78318. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78319. */
  78320. markAsDirty(flag: number): void;
  78321. /**
  78322. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78323. * @param func defines a function which checks material defines against the submeshes
  78324. */
  78325. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78326. /**
  78327. * Indicates that image processing needs to be re-calculated for all submeshes
  78328. */
  78329. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78330. /**
  78331. * Indicates that textures need to be re-calculated for all submeshes
  78332. */
  78333. protected _markAllSubMeshesAsTexturesDirty(): void;
  78334. /**
  78335. * Indicates that fresnel needs to be re-calculated for all submeshes
  78336. */
  78337. protected _markAllSubMeshesAsFresnelDirty(): void;
  78338. /**
  78339. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78340. */
  78341. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78342. /**
  78343. * Indicates that lights need to be re-calculated for all submeshes
  78344. */
  78345. protected _markAllSubMeshesAsLightsDirty(): void;
  78346. /**
  78347. * Indicates that attributes need to be re-calculated for all submeshes
  78348. */
  78349. protected _markAllSubMeshesAsAttributesDirty(): void;
  78350. /**
  78351. * Indicates that misc needs to be re-calculated for all submeshes
  78352. */
  78353. protected _markAllSubMeshesAsMiscDirty(): void;
  78354. /**
  78355. * Indicates that textures and misc need to be re-calculated for all submeshes
  78356. */
  78357. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78358. /**
  78359. * Disposes the material
  78360. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78361. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78362. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78363. */
  78364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78365. /** @hidden */
  78366. private releaseVertexArrayObject;
  78367. /**
  78368. * Serializes this material
  78369. * @returns the serialized material object
  78370. */
  78371. serialize(): any;
  78372. /**
  78373. * Creates a material from parsed material data
  78374. * @param parsedMaterial defines parsed material data
  78375. * @param scene defines the hosting scene
  78376. * @param rootUrl defines the root URL to use to load textures
  78377. * @returns a new material
  78378. */
  78379. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /**
  78384. * Base class for submeshes
  78385. */
  78386. export class BaseSubMesh {
  78387. /** @hidden */
  78388. _materialDefines: Nullable<MaterialDefines>;
  78389. /** @hidden */
  78390. _materialEffect: Nullable<Effect>;
  78391. /**
  78392. * Gets associated effect
  78393. */
  78394. readonly effect: Nullable<Effect>;
  78395. /**
  78396. * Sets associated effect (effect used to render this submesh)
  78397. * @param effect defines the effect to associate with
  78398. * @param defines defines the set of defines used to compile this effect
  78399. */
  78400. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78401. }
  78402. /**
  78403. * Defines a subdivision inside a mesh
  78404. */
  78405. export class SubMesh extends BaseSubMesh implements ICullable {
  78406. /** the material index to use */
  78407. materialIndex: number;
  78408. /** vertex index start */
  78409. verticesStart: number;
  78410. /** vertices count */
  78411. verticesCount: number;
  78412. /** index start */
  78413. indexStart: number;
  78414. /** indices count */
  78415. indexCount: number;
  78416. /** @hidden */
  78417. _linesIndexCount: number;
  78418. private _mesh;
  78419. private _renderingMesh;
  78420. private _boundingInfo;
  78421. private _linesIndexBuffer;
  78422. /** @hidden */
  78423. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78424. /** @hidden */
  78425. _trianglePlanes: Plane[];
  78426. /** @hidden */
  78427. _lastColliderTransformMatrix: Matrix;
  78428. /** @hidden */
  78429. _renderId: number;
  78430. /** @hidden */
  78431. _alphaIndex: number;
  78432. /** @hidden */
  78433. _distanceToCamera: number;
  78434. /** @hidden */
  78435. _id: number;
  78436. private _currentMaterial;
  78437. /**
  78438. * Add a new submesh to a mesh
  78439. * @param materialIndex defines the material index to use
  78440. * @param verticesStart defines vertex index start
  78441. * @param verticesCount defines vertices count
  78442. * @param indexStart defines index start
  78443. * @param indexCount defines indices count
  78444. * @param mesh defines the parent mesh
  78445. * @param renderingMesh defines an optional rendering mesh
  78446. * @param createBoundingBox defines if bounding box should be created for this submesh
  78447. * @returns the new submesh
  78448. */
  78449. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78450. /**
  78451. * Creates a new submesh
  78452. * @param materialIndex defines the material index to use
  78453. * @param verticesStart defines vertex index start
  78454. * @param verticesCount defines vertices count
  78455. * @param indexStart defines index start
  78456. * @param indexCount defines indices count
  78457. * @param mesh defines the parent mesh
  78458. * @param renderingMesh defines an optional rendering mesh
  78459. * @param createBoundingBox defines if bounding box should be created for this submesh
  78460. */
  78461. constructor(
  78462. /** the material index to use */
  78463. materialIndex: number,
  78464. /** vertex index start */
  78465. verticesStart: number,
  78466. /** vertices count */
  78467. verticesCount: number,
  78468. /** index start */
  78469. indexStart: number,
  78470. /** indices count */
  78471. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78472. /**
  78473. * Returns true if this submesh covers the entire parent mesh
  78474. * @ignorenaming
  78475. */
  78476. readonly IsGlobal: boolean;
  78477. /**
  78478. * Returns the submesh BoudingInfo object
  78479. * @returns current bounding info (or mesh's one if the submesh is global)
  78480. */
  78481. getBoundingInfo(): BoundingInfo;
  78482. /**
  78483. * Sets the submesh BoundingInfo
  78484. * @param boundingInfo defines the new bounding info to use
  78485. * @returns the SubMesh
  78486. */
  78487. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  78488. /**
  78489. * Returns the mesh of the current submesh
  78490. * @return the parent mesh
  78491. */
  78492. getMesh(): AbstractMesh;
  78493. /**
  78494. * Returns the rendering mesh of the submesh
  78495. * @returns the rendering mesh (could be different from parent mesh)
  78496. */
  78497. getRenderingMesh(): Mesh;
  78498. /**
  78499. * Returns the submesh material
  78500. * @returns null or the current material
  78501. */
  78502. getMaterial(): Nullable<Material>;
  78503. /**
  78504. * Sets a new updated BoundingInfo object to the submesh
  78505. * @returns the SubMesh
  78506. */
  78507. refreshBoundingInfo(): SubMesh;
  78508. /** @hidden */
  78509. _checkCollision(collider: Collider): boolean;
  78510. /**
  78511. * Updates the submesh BoundingInfo
  78512. * @param world defines the world matrix to use to update the bounding info
  78513. * @returns the submesh
  78514. */
  78515. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  78516. /**
  78517. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  78518. * @param frustumPlanes defines the frustum planes
  78519. * @returns true if the submesh is intersecting with the frustum
  78520. */
  78521. isInFrustum(frustumPlanes: Plane[]): boolean;
  78522. /**
  78523. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  78524. * @param frustumPlanes defines the frustum planes
  78525. * @returns true if the submesh is inside the frustum
  78526. */
  78527. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78528. /**
  78529. * Renders the submesh
  78530. * @param enableAlphaMode defines if alpha needs to be used
  78531. * @returns the submesh
  78532. */
  78533. render(enableAlphaMode: boolean): SubMesh;
  78534. /**
  78535. * @hidden
  78536. */
  78537. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  78538. /**
  78539. * Checks if the submesh intersects with a ray
  78540. * @param ray defines the ray to test
  78541. * @returns true is the passed ray intersects the submesh bounding box
  78542. */
  78543. canIntersects(ray: Ray): boolean;
  78544. /**
  78545. * Intersects current submesh with a ray
  78546. * @param ray defines the ray to test
  78547. * @param positions defines mesh's positions array
  78548. * @param indices defines mesh's indices array
  78549. * @param fastCheck defines if only bounding info should be used
  78550. * @returns intersection info or null if no intersection
  78551. */
  78552. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  78553. /** @hidden */
  78554. private _intersectLines;
  78555. /** @hidden */
  78556. private _intersectTriangles;
  78557. /** @hidden */
  78558. _rebuild(): void;
  78559. /**
  78560. * Creates a new submesh from the passed mesh
  78561. * @param newMesh defines the new hosting mesh
  78562. * @param newRenderingMesh defines an optional rendering mesh
  78563. * @returns the new submesh
  78564. */
  78565. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  78566. /**
  78567. * Release associated resources
  78568. */
  78569. dispose(): void;
  78570. /**
  78571. * Gets the class name
  78572. * @returns the string "SubMesh".
  78573. */
  78574. getClassName(): string;
  78575. /**
  78576. * Creates a new submesh from indices data
  78577. * @param materialIndex the index of the main mesh material
  78578. * @param startIndex the index where to start the copy in the mesh indices array
  78579. * @param indexCount the number of indices to copy then from the startIndex
  78580. * @param mesh the main mesh to create the submesh from
  78581. * @param renderingMesh the optional rendering mesh
  78582. * @returns a new submesh
  78583. */
  78584. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  78585. }
  78586. }
  78587. declare module BABYLON {
  78588. /**
  78589. * Class used to store geometry data (vertex buffers + index buffer)
  78590. */
  78591. export class Geometry implements IGetSetVerticesData {
  78592. /**
  78593. * Gets or sets the ID of the geometry
  78594. */
  78595. id: string;
  78596. /**
  78597. * Gets or sets the unique ID of the geometry
  78598. */
  78599. uniqueId: number;
  78600. /**
  78601. * Gets the delay loading state of the geometry (none by default which means not delayed)
  78602. */
  78603. delayLoadState: number;
  78604. /**
  78605. * Gets the file containing the data to load when running in delay load state
  78606. */
  78607. delayLoadingFile: Nullable<string>;
  78608. /**
  78609. * Callback called when the geometry is updated
  78610. */
  78611. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  78612. private _scene;
  78613. private _engine;
  78614. private _meshes;
  78615. private _totalVertices;
  78616. /** @hidden */
  78617. _indices: IndicesArray;
  78618. /** @hidden */
  78619. _vertexBuffers: {
  78620. [key: string]: VertexBuffer;
  78621. };
  78622. private _isDisposed;
  78623. private _extend;
  78624. private _boundingBias;
  78625. /** @hidden */
  78626. _delayInfo: Array<string>;
  78627. private _indexBuffer;
  78628. private _indexBufferIsUpdatable;
  78629. /** @hidden */
  78630. _boundingInfo: Nullable<BoundingInfo>;
  78631. /** @hidden */
  78632. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  78633. /** @hidden */
  78634. _softwareSkinningFrameId: number;
  78635. private _vertexArrayObjects;
  78636. private _updatable;
  78637. /** @hidden */
  78638. _positions: Nullable<Vector3[]>;
  78639. /**
  78640. * 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
  78641. */
  78642. /**
  78643. * 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
  78644. */
  78645. boundingBias: Vector2;
  78646. /**
  78647. * Static function used to attach a new empty geometry to a mesh
  78648. * @param mesh defines the mesh to attach the geometry to
  78649. * @returns the new Geometry
  78650. */
  78651. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  78652. /**
  78653. * Creates a new geometry
  78654. * @param id defines the unique ID
  78655. * @param scene defines the hosting scene
  78656. * @param vertexData defines the VertexData used to get geometry data
  78657. * @param updatable defines if geometry must be updatable (false by default)
  78658. * @param mesh defines the mesh that will be associated with the geometry
  78659. */
  78660. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  78661. /**
  78662. * Gets the current extend of the geometry
  78663. */
  78664. readonly extend: {
  78665. minimum: Vector3;
  78666. maximum: Vector3;
  78667. };
  78668. /**
  78669. * Gets the hosting scene
  78670. * @returns the hosting Scene
  78671. */
  78672. getScene(): Scene;
  78673. /**
  78674. * Gets the hosting engine
  78675. * @returns the hosting Engine
  78676. */
  78677. getEngine(): Engine;
  78678. /**
  78679. * Defines if the geometry is ready to use
  78680. * @returns true if the geometry is ready to be used
  78681. */
  78682. isReady(): boolean;
  78683. /**
  78684. * Gets a value indicating that the geometry should not be serialized
  78685. */
  78686. readonly doNotSerialize: boolean;
  78687. /** @hidden */
  78688. _rebuild(): void;
  78689. /**
  78690. * Affects all geometry data in one call
  78691. * @param vertexData defines the geometry data
  78692. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  78693. */
  78694. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  78695. /**
  78696. * Set specific vertex data
  78697. * @param kind defines the data kind (Position, normal, etc...)
  78698. * @param data defines the vertex data to use
  78699. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78700. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78701. */
  78702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  78703. /**
  78704. * Removes a specific vertex data
  78705. * @param kind defines the data kind (Position, normal, etc...)
  78706. */
  78707. removeVerticesData(kind: string): void;
  78708. /**
  78709. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  78710. * @param buffer defines the vertex buffer to use
  78711. * @param totalVertices defines the total number of vertices for position kind (could be null)
  78712. */
  78713. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  78714. /**
  78715. * Update a specific vertex buffer
  78716. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  78717. * It will do nothing if the buffer is not updatable
  78718. * @param kind defines the data kind (Position, normal, etc...)
  78719. * @param data defines the data to use
  78720. * @param offset defines the offset in the target buffer where to store the data
  78721. * @param useBytes set to true if the offset is in bytes
  78722. */
  78723. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  78724. /**
  78725. * Update a specific vertex buffer
  78726. * This function will create a new buffer if the current one is not updatable
  78727. * @param kind defines the data kind (Position, normal, etc...)
  78728. * @param data defines the data to use
  78729. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  78730. */
  78731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  78732. private _updateBoundingInfo;
  78733. /** @hidden */
  78734. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  78735. /**
  78736. * Gets total number of vertices
  78737. * @returns the total number of vertices
  78738. */
  78739. getTotalVertices(): number;
  78740. /**
  78741. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78742. * @param kind defines the data kind (Position, normal, etc...)
  78743. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78745. * @returns a float array containing vertex data
  78746. */
  78747. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78748. /**
  78749. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  78750. * @param kind defines the data kind (Position, normal, etc...)
  78751. * @returns true if the vertex buffer with the specified kind is updatable
  78752. */
  78753. isVertexBufferUpdatable(kind: string): boolean;
  78754. /**
  78755. * Gets a specific vertex buffer
  78756. * @param kind defines the data kind (Position, normal, etc...)
  78757. * @returns a VertexBuffer
  78758. */
  78759. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78760. /**
  78761. * Returns all vertex buffers
  78762. * @return an object holding all vertex buffers indexed by kind
  78763. */
  78764. getVertexBuffers(): Nullable<{
  78765. [key: string]: VertexBuffer;
  78766. }>;
  78767. /**
  78768. * Gets a boolean indicating if specific vertex buffer is present
  78769. * @param kind defines the data kind (Position, normal, etc...)
  78770. * @returns true if data is present
  78771. */
  78772. isVerticesDataPresent(kind: string): boolean;
  78773. /**
  78774. * Gets a list of all attached data kinds (Position, normal, etc...)
  78775. * @returns a list of string containing all kinds
  78776. */
  78777. getVerticesDataKinds(): string[];
  78778. /**
  78779. * Update index buffer
  78780. * @param indices defines the indices to store in the index buffer
  78781. * @param offset defines the offset in the target buffer where to store the data
  78782. */
  78783. updateIndices(indices: IndicesArray, offset?: number): void;
  78784. /**
  78785. * Creates a new index buffer
  78786. * @param indices defines the indices to store in the index buffer
  78787. * @param totalVertices defines the total number of vertices (could be null)
  78788. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78789. */
  78790. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  78791. /**
  78792. * Return the total number of indices
  78793. * @returns the total number of indices
  78794. */
  78795. getTotalIndices(): number;
  78796. /**
  78797. * Gets the index buffer array
  78798. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78800. * @returns the index buffer array
  78801. */
  78802. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78803. /**
  78804. * Gets the index buffer
  78805. * @return the index buffer
  78806. */
  78807. getIndexBuffer(): Nullable<WebGLBuffer>;
  78808. /** @hidden */
  78809. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  78810. /**
  78811. * Release the associated resources for a specific mesh
  78812. * @param mesh defines the source mesh
  78813. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  78814. */
  78815. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  78816. /**
  78817. * Apply current geometry to a given mesh
  78818. * @param mesh defines the mesh to apply geometry to
  78819. */
  78820. applyToMesh(mesh: Mesh): void;
  78821. private _updateExtend;
  78822. private _applyToMesh;
  78823. private notifyUpdate;
  78824. /**
  78825. * Load the geometry if it was flagged as delay loaded
  78826. * @param scene defines the hosting scene
  78827. * @param onLoaded defines a callback called when the geometry is loaded
  78828. */
  78829. load(scene: Scene, onLoaded?: () => void): void;
  78830. private _queueLoad;
  78831. /**
  78832. * Invert the geometry to move from a right handed system to a left handed one.
  78833. */
  78834. toLeftHanded(): void;
  78835. /** @hidden */
  78836. _resetPointsArrayCache(): void;
  78837. /** @hidden */
  78838. _generatePointsArray(): boolean;
  78839. /**
  78840. * Gets a value indicating if the geometry is disposed
  78841. * @returns true if the geometry was disposed
  78842. */
  78843. isDisposed(): boolean;
  78844. private _disposeVertexArrayObjects;
  78845. /**
  78846. * Free all associated resources
  78847. */
  78848. dispose(): void;
  78849. /**
  78850. * Clone the current geometry into a new geometry
  78851. * @param id defines the unique ID of the new geometry
  78852. * @returns a new geometry object
  78853. */
  78854. copy(id: string): Geometry;
  78855. /**
  78856. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78857. * @return a JSON representation of the current geometry data (without the vertices data)
  78858. */
  78859. serialize(): any;
  78860. private toNumberArray;
  78861. /**
  78862. * Serialize all vertices data into a JSON oject
  78863. * @returns a JSON representation of the current geometry data
  78864. */
  78865. serializeVerticeData(): any;
  78866. /**
  78867. * Extracts a clone of a mesh geometry
  78868. * @param mesh defines the source mesh
  78869. * @param id defines the unique ID of the new geometry object
  78870. * @returns the new geometry object
  78871. */
  78872. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  78873. /**
  78874. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78875. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78876. * Be aware Math.random() could cause collisions, but:
  78877. * "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"
  78878. * @returns a string containing a new GUID
  78879. */
  78880. static RandomId(): string;
  78881. /** @hidden */
  78882. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  78883. private static _CleanMatricesWeights;
  78884. /**
  78885. * Create a new geometry from persisted data (Using .babylon file format)
  78886. * @param parsedVertexData defines the persisted data
  78887. * @param scene defines the hosting scene
  78888. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78889. * @returns the new geometry object
  78890. */
  78891. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  78892. }
  78893. }
  78894. declare module BABYLON {
  78895. /**
  78896. * Define an interface for all classes that will get and set the data on vertices
  78897. */
  78898. export interface IGetSetVerticesData {
  78899. /**
  78900. * Gets a boolean indicating if specific vertex data is present
  78901. * @param kind defines the vertex data kind to use
  78902. * @returns true is data kind is present
  78903. */
  78904. isVerticesDataPresent(kind: string): boolean;
  78905. /**
  78906. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78907. * @param kind defines the data kind (Position, normal, etc...)
  78908. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78910. * @returns a float array containing vertex data
  78911. */
  78912. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78913. /**
  78914. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78915. * @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.
  78916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78917. * @returns the indices array or an empty array if the mesh has no geometry
  78918. */
  78919. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78920. /**
  78921. * Set specific vertex data
  78922. * @param kind defines the data kind (Position, normal, etc...)
  78923. * @param data defines the vertex data to use
  78924. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78925. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78926. */
  78927. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  78928. /**
  78929. * Update a specific associated vertex buffer
  78930. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78931. * - VertexBuffer.PositionKind
  78932. * - VertexBuffer.UVKind
  78933. * - VertexBuffer.UV2Kind
  78934. * - VertexBuffer.UV3Kind
  78935. * - VertexBuffer.UV4Kind
  78936. * - VertexBuffer.UV5Kind
  78937. * - VertexBuffer.UV6Kind
  78938. * - VertexBuffer.ColorKind
  78939. * - VertexBuffer.MatricesIndicesKind
  78940. * - VertexBuffer.MatricesIndicesExtraKind
  78941. * - VertexBuffer.MatricesWeightsKind
  78942. * - VertexBuffer.MatricesWeightsExtraKind
  78943. * @param data defines the data source
  78944. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78945. * @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)
  78946. */
  78947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  78948. /**
  78949. * Creates a new index buffer
  78950. * @param indices defines the indices to store in the index buffer
  78951. * @param totalVertices defines the total number of vertices (could be null)
  78952. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78953. */
  78954. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  78955. }
  78956. /**
  78957. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  78958. */
  78959. export class VertexData {
  78960. /**
  78961. * Mesh side orientation : usually the external or front surface
  78962. */
  78963. static readonly FRONTSIDE: number;
  78964. /**
  78965. * Mesh side orientation : usually the internal or back surface
  78966. */
  78967. static readonly BACKSIDE: number;
  78968. /**
  78969. * Mesh side orientation : both internal and external or front and back surfaces
  78970. */
  78971. static readonly DOUBLESIDE: number;
  78972. /**
  78973. * Mesh side orientation : by default, `FRONTSIDE`
  78974. */
  78975. static readonly DEFAULTSIDE: number;
  78976. /**
  78977. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  78978. */
  78979. positions: Nullable<FloatArray>;
  78980. /**
  78981. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  78982. */
  78983. normals: Nullable<FloatArray>;
  78984. /**
  78985. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  78986. */
  78987. tangents: Nullable<FloatArray>;
  78988. /**
  78989. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78990. */
  78991. uvs: Nullable<FloatArray>;
  78992. /**
  78993. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78994. */
  78995. uvs2: Nullable<FloatArray>;
  78996. /**
  78997. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78998. */
  78999. uvs3: Nullable<FloatArray>;
  79000. /**
  79001. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79002. */
  79003. uvs4: Nullable<FloatArray>;
  79004. /**
  79005. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79006. */
  79007. uvs5: Nullable<FloatArray>;
  79008. /**
  79009. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79010. */
  79011. uvs6: Nullable<FloatArray>;
  79012. /**
  79013. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79014. */
  79015. colors: Nullable<FloatArray>;
  79016. /**
  79017. * 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).
  79018. */
  79019. matricesIndices: Nullable<FloatArray>;
  79020. /**
  79021. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79022. */
  79023. matricesWeights: Nullable<FloatArray>;
  79024. /**
  79025. * An array extending the number of possible indices
  79026. */
  79027. matricesIndicesExtra: Nullable<FloatArray>;
  79028. /**
  79029. * An array extending the number of possible weights when the number of indices is extended
  79030. */
  79031. matricesWeightsExtra: Nullable<FloatArray>;
  79032. /**
  79033. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79034. */
  79035. indices: Nullable<IndicesArray>;
  79036. /**
  79037. * Uses the passed data array to set the set the values for the specified kind of data
  79038. * @param data a linear array of floating numbers
  79039. * @param kind the type of data that is being set, eg positions, colors etc
  79040. */
  79041. set(data: FloatArray, kind: string): void;
  79042. /**
  79043. * Associates the vertexData to the passed Mesh.
  79044. * Sets it as updatable or not (default `false`)
  79045. * @param mesh the mesh the vertexData is applied to
  79046. * @param updatable when used and having the value true allows new data to update the vertexData
  79047. * @returns the VertexData
  79048. */
  79049. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79050. /**
  79051. * Associates the vertexData to the passed Geometry.
  79052. * Sets it as updatable or not (default `false`)
  79053. * @param geometry the geometry the vertexData is applied to
  79054. * @param updatable when used and having the value true allows new data to update the vertexData
  79055. * @returns VertexData
  79056. */
  79057. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79058. /**
  79059. * Updates the associated mesh
  79060. * @param mesh the mesh to be updated
  79061. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79062. * @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
  79063. * @returns VertexData
  79064. */
  79065. updateMesh(mesh: Mesh): VertexData;
  79066. /**
  79067. * Updates the associated geometry
  79068. * @param geometry the geometry to be updated
  79069. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79070. * @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
  79071. * @returns VertexData.
  79072. */
  79073. updateGeometry(geometry: Geometry): VertexData;
  79074. private _applyTo;
  79075. private _update;
  79076. /**
  79077. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79078. * @param matrix the transforming matrix
  79079. * @returns the VertexData
  79080. */
  79081. transform(matrix: Matrix): VertexData;
  79082. /**
  79083. * Merges the passed VertexData into the current one
  79084. * @param other the VertexData to be merged into the current one
  79085. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79086. * @returns the modified VertexData
  79087. */
  79088. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79089. private _mergeElement;
  79090. private _validate;
  79091. /**
  79092. * Serializes the VertexData
  79093. * @returns a serialized object
  79094. */
  79095. serialize(): any;
  79096. /**
  79097. * Extracts the vertexData from a mesh
  79098. * @param mesh the mesh from which to extract the VertexData
  79099. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79100. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79101. * @returns the object VertexData associated to the passed mesh
  79102. */
  79103. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79104. /**
  79105. * Extracts the vertexData from the geometry
  79106. * @param geometry the geometry from which to extract the VertexData
  79107. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79108. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79109. * @returns the object VertexData associated to the passed mesh
  79110. */
  79111. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79112. private static _ExtractFrom;
  79113. /**
  79114. * Creates the VertexData for a Ribbon
  79115. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79116. * * pathArray array of paths, each of which an array of successive Vector3
  79117. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79118. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79119. * * 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
  79120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79121. * * 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)
  79122. * * 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)
  79123. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79124. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79125. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79126. * @returns the VertexData of the ribbon
  79127. */
  79128. static CreateRibbon(options: {
  79129. pathArray: Vector3[][];
  79130. closeArray?: boolean;
  79131. closePath?: boolean;
  79132. offset?: number;
  79133. sideOrientation?: number;
  79134. frontUVs?: Vector4;
  79135. backUVs?: Vector4;
  79136. invertUV?: boolean;
  79137. uvs?: Vector2[];
  79138. colors?: Color4[];
  79139. }): VertexData;
  79140. /**
  79141. * Creates the VertexData for a box
  79142. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79143. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79144. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79145. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79146. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79147. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79148. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79150. * * 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)
  79151. * * 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)
  79152. * @returns the VertexData of the box
  79153. */
  79154. static CreateBox(options: {
  79155. size?: number;
  79156. width?: number;
  79157. height?: number;
  79158. depth?: number;
  79159. faceUV?: Vector4[];
  79160. faceColors?: Color4[];
  79161. sideOrientation?: number;
  79162. frontUVs?: Vector4;
  79163. backUVs?: Vector4;
  79164. }): VertexData;
  79165. /**
  79166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79168. * * segments sets the number of horizontal strips optional, default 32
  79169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79173. * * 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
  79174. * * 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
  79175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79176. * * 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)
  79177. * * 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)
  79178. * @returns the VertexData of the ellipsoid
  79179. */
  79180. static CreateSphere(options: {
  79181. segments?: number;
  79182. diameter?: number;
  79183. diameterX?: number;
  79184. diameterY?: number;
  79185. diameterZ?: number;
  79186. arc?: number;
  79187. slice?: number;
  79188. sideOrientation?: number;
  79189. frontUVs?: Vector4;
  79190. backUVs?: Vector4;
  79191. }): VertexData;
  79192. /**
  79193. * Creates the VertexData for a cylinder, cone or prism
  79194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79195. * * height sets the height (y direction) of the cylinder, optional, default 2
  79196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79201. * * 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
  79202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79207. * * 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)
  79208. * * 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)
  79209. * @returns the VertexData of the cylinder, cone or prism
  79210. */
  79211. static CreateCylinder(options: {
  79212. height?: number;
  79213. diameterTop?: number;
  79214. diameterBottom?: number;
  79215. diameter?: number;
  79216. tessellation?: number;
  79217. subdivisions?: number;
  79218. arc?: number;
  79219. faceColors?: Color4[];
  79220. faceUV?: Vector4[];
  79221. hasRings?: boolean;
  79222. enclose?: boolean;
  79223. sideOrientation?: number;
  79224. frontUVs?: Vector4;
  79225. backUVs?: Vector4;
  79226. }): VertexData;
  79227. /**
  79228. * Creates the VertexData for a torus
  79229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79230. * * diameter the diameter of the torus, optional default 1
  79231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79234. * * 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)
  79235. * * 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)
  79236. * @returns the VertexData of the torus
  79237. */
  79238. static CreateTorus(options: {
  79239. diameter?: number;
  79240. thickness?: number;
  79241. tessellation?: number;
  79242. sideOrientation?: number;
  79243. frontUVs?: Vector4;
  79244. backUVs?: Vector4;
  79245. }): VertexData;
  79246. /**
  79247. * Creates the VertexData of the LineSystem
  79248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79249. * - lines an array of lines, each line being an array of successive Vector3
  79250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79251. * @returns the VertexData of the LineSystem
  79252. */
  79253. static CreateLineSystem(options: {
  79254. lines: Vector3[][];
  79255. colors?: Nullable<Color4[][]>;
  79256. }): VertexData;
  79257. /**
  79258. * Create the VertexData for a DashedLines
  79259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79260. * - points an array successive Vector3
  79261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79263. * - dashNb the intended total number of dashes, optional, default 200
  79264. * @returns the VertexData for the DashedLines
  79265. */
  79266. static CreateDashedLines(options: {
  79267. points: Vector3[];
  79268. dashSize?: number;
  79269. gapSize?: number;
  79270. dashNb?: number;
  79271. }): VertexData;
  79272. /**
  79273. * Creates the VertexData for a Ground
  79274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79275. * - width the width (x direction) of the ground, optional, default 1
  79276. * - height the height (z direction) of the ground, optional, default 1
  79277. * - subdivisions the number of subdivisions per side, optional, default 1
  79278. * @returns the VertexData of the Ground
  79279. */
  79280. static CreateGround(options: {
  79281. width?: number;
  79282. height?: number;
  79283. subdivisions?: number;
  79284. subdivisionsX?: number;
  79285. subdivisionsY?: number;
  79286. }): VertexData;
  79287. /**
  79288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79290. * * xmin the ground minimum X coordinate, optional, default -1
  79291. * * zmin the ground minimum Z coordinate, optional, default -1
  79292. * * xmax the ground maximum X coordinate, optional, default 1
  79293. * * zmax the ground maximum Z coordinate, optional, default 1
  79294. * * 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}
  79295. * * 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}
  79296. * @returns the VertexData of the TiledGround
  79297. */
  79298. static CreateTiledGround(options: {
  79299. xmin: number;
  79300. zmin: number;
  79301. xmax: number;
  79302. zmax: number;
  79303. subdivisions?: {
  79304. w: number;
  79305. h: number;
  79306. };
  79307. precision?: {
  79308. w: number;
  79309. h: number;
  79310. };
  79311. }): VertexData;
  79312. /**
  79313. * Creates the VertexData of the Ground designed from a heightmap
  79314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79315. * * width the width (x direction) of the ground
  79316. * * height the height (z direction) of the ground
  79317. * * subdivisions the number of subdivisions per side
  79318. * * minHeight the minimum altitude on the ground, optional, default 0
  79319. * * maxHeight the maximum altitude on the ground, optional default 1
  79320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79321. * * buffer the array holding the image color data
  79322. * * bufferWidth the width of image
  79323. * * bufferHeight the height of image
  79324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79325. * @returns the VertexData of the Ground designed from a heightmap
  79326. */
  79327. static CreateGroundFromHeightMap(options: {
  79328. width: number;
  79329. height: number;
  79330. subdivisions: number;
  79331. minHeight: number;
  79332. maxHeight: number;
  79333. colorFilter: Color3;
  79334. buffer: Uint8Array;
  79335. bufferWidth: number;
  79336. bufferHeight: number;
  79337. alphaFilter: number;
  79338. }): VertexData;
  79339. /**
  79340. * Creates the VertexData for a Plane
  79341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79342. * * size sets the width and height of the plane to the value of size, optional default 1
  79343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79346. * * 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)
  79347. * * 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)
  79348. * @returns the VertexData of the box
  79349. */
  79350. static CreatePlane(options: {
  79351. size?: number;
  79352. width?: number;
  79353. height?: number;
  79354. sideOrientation?: number;
  79355. frontUVs?: Vector4;
  79356. backUVs?: Vector4;
  79357. }): VertexData;
  79358. /**
  79359. * Creates the VertexData of the Disc or regular Polygon
  79360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79361. * * radius the radius of the disc, optional default 0.5
  79362. * * tessellation the number of polygon sides, optional, default 64
  79363. * * 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
  79364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79365. * * 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)
  79366. * * 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)
  79367. * @returns the VertexData of the box
  79368. */
  79369. static CreateDisc(options: {
  79370. radius?: number;
  79371. tessellation?: number;
  79372. arc?: number;
  79373. sideOrientation?: number;
  79374. frontUVs?: Vector4;
  79375. backUVs?: Vector4;
  79376. }): VertexData;
  79377. /**
  79378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79380. * @param polygon a mesh built from polygonTriangulation.build()
  79381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79384. * @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)
  79385. * @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)
  79386. * @returns the VertexData of the Polygon
  79387. */
  79388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79389. /**
  79390. * Creates the VertexData of the IcoSphere
  79391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79392. * * radius the radius of the IcoSphere, optional default 1
  79393. * * radiusX allows stretching in the x direction, optional, default radius
  79394. * * radiusY allows stretching in the y direction, optional, default radius
  79395. * * radiusZ allows stretching in the z direction, optional, default radius
  79396. * * flat when true creates a flat shaded mesh, optional, default true
  79397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79399. * * 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)
  79400. * * 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)
  79401. * @returns the VertexData of the IcoSphere
  79402. */
  79403. static CreateIcoSphere(options: {
  79404. radius?: number;
  79405. radiusX?: number;
  79406. radiusY?: number;
  79407. radiusZ?: number;
  79408. flat?: boolean;
  79409. subdivisions?: number;
  79410. sideOrientation?: number;
  79411. frontUVs?: Vector4;
  79412. backUVs?: Vector4;
  79413. }): VertexData;
  79414. /**
  79415. * Creates the VertexData for a Polyhedron
  79416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79417. * * type provided types are:
  79418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79419. * * 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)
  79420. * * size the size of the IcoSphere, optional default 1
  79421. * * sizeX allows stretching in the x direction, optional, default size
  79422. * * sizeY allows stretching in the y direction, optional, default size
  79423. * * sizeZ allows stretching in the z direction, optional, default size
  79424. * * 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
  79425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79427. * * flat when true creates a flat shaded mesh, optional, default true
  79428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79430. * * 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)
  79431. * * 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)
  79432. * @returns the VertexData of the Polyhedron
  79433. */
  79434. static CreatePolyhedron(options: {
  79435. type?: number;
  79436. size?: number;
  79437. sizeX?: number;
  79438. sizeY?: number;
  79439. sizeZ?: number;
  79440. custom?: any;
  79441. faceUV?: Vector4[];
  79442. faceColors?: Color4[];
  79443. flat?: boolean;
  79444. sideOrientation?: number;
  79445. frontUVs?: Vector4;
  79446. backUVs?: Vector4;
  79447. }): VertexData;
  79448. /**
  79449. * Creates the VertexData for a TorusKnot
  79450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79451. * * radius the radius of the torus knot, optional, default 2
  79452. * * tube the thickness of the tube, optional, default 0.5
  79453. * * radialSegments the number of sides on each tube segments, optional, default 32
  79454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79455. * * p the number of windings around the z axis, optional, default 2
  79456. * * q the number of windings around the x axis, optional, default 3
  79457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79458. * * 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)
  79459. * * 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)
  79460. * @returns the VertexData of the Torus Knot
  79461. */
  79462. static CreateTorusKnot(options: {
  79463. radius?: number;
  79464. tube?: number;
  79465. radialSegments?: number;
  79466. tubularSegments?: number;
  79467. p?: number;
  79468. q?: number;
  79469. sideOrientation?: number;
  79470. frontUVs?: Vector4;
  79471. backUVs?: Vector4;
  79472. }): VertexData;
  79473. /**
  79474. * Compute normals for given positions and indices
  79475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79479. * * facetNormals : optional array of facet normals (vector3)
  79480. * * facetPositions : optional array of facet positions (vector3)
  79481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79483. * * bInfo : optional bounding info, required for facetPartitioning computation
  79484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  79486. * * useRightHandedSystem: optional boolean to for right handed system computation
  79487. * * depthSort : optional boolean to enable the facet depth sort computation
  79488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  79489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  79490. */
  79491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  79492. facetNormals?: any;
  79493. facetPositions?: any;
  79494. facetPartitioning?: any;
  79495. ratio?: number;
  79496. bInfo?: any;
  79497. bbSize?: Vector3;
  79498. subDiv?: any;
  79499. useRightHandedSystem?: boolean;
  79500. depthSort?: boolean;
  79501. distanceTo?: Vector3;
  79502. depthSortedFacets?: any;
  79503. }): void;
  79504. /** @hidden */
  79505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  79506. /**
  79507. * Applies VertexData created from the imported parameters to the geometry
  79508. * @param parsedVertexData the parsed data from an imported file
  79509. * @param geometry the geometry to apply the VertexData to
  79510. */
  79511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  79512. }
  79513. }
  79514. declare module BABYLON {
  79515. /**
  79516. * Class containing static functions to help procedurally build meshes
  79517. */
  79518. export class DiscBuilder {
  79519. /**
  79520. * Creates a plane polygonal mesh. By default, this is a disc
  79521. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79522. * * 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
  79523. * * 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
  79524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79527. * @param name defines the name of the mesh
  79528. * @param options defines the options used to create the mesh
  79529. * @param scene defines the hosting scene
  79530. * @returns the plane polygonal mesh
  79531. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79532. */
  79533. static CreateDisc(name: string, options: {
  79534. radius?: number;
  79535. tessellation?: number;
  79536. arc?: number;
  79537. updatable?: boolean;
  79538. sideOrientation?: number;
  79539. frontUVs?: Vector4;
  79540. backUVs?: Vector4;
  79541. }, scene?: Nullable<Scene>): Mesh;
  79542. }
  79543. }
  79544. declare module BABYLON {
  79545. /**
  79546. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  79547. *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.
  79548. * The SPS is also a particle system. It provides some methods to manage the particles.
  79549. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  79550. *
  79551. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  79552. */
  79553. export class SolidParticleSystem implements IDisposable {
  79554. /**
  79555. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  79556. * Example : var p = SPS.particles[i];
  79557. */
  79558. particles: SolidParticle[];
  79559. /**
  79560. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  79561. */
  79562. nbParticles: number;
  79563. /**
  79564. * If the particles must ever face the camera (default false). Useful for planar particles.
  79565. */
  79566. billboard: boolean;
  79567. /**
  79568. * Recompute normals when adding a shape
  79569. */
  79570. recomputeNormals: boolean;
  79571. /**
  79572. * This a counter ofr your own usage. It's not set by any SPS functions.
  79573. */
  79574. counter: number;
  79575. /**
  79576. * The SPS name. This name is also given to the underlying mesh.
  79577. */
  79578. name: string;
  79579. /**
  79580. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  79581. */
  79582. mesh: Mesh;
  79583. /**
  79584. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  79585. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  79586. */
  79587. vars: any;
  79588. /**
  79589. * This array is populated when the SPS is set as 'pickable'.
  79590. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  79591. * Each element of this array is an object `{idx: int, faceId: int}`.
  79592. * `idx` is the picked particle index in the `SPS.particles` array
  79593. * `faceId` is the picked face index counted within this particle.
  79594. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  79595. */
  79596. pickedParticles: {
  79597. idx: number;
  79598. faceId: number;
  79599. }[];
  79600. /**
  79601. * This array is populated when `enableDepthSort` is set to true.
  79602. * Each element of this array is an instance of the class DepthSortedParticle.
  79603. */
  79604. depthSortedParticles: DepthSortedParticle[];
  79605. /**
  79606. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  79607. * @hidden
  79608. */
  79609. _bSphereOnly: boolean;
  79610. /**
  79611. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  79612. * @hidden
  79613. */
  79614. _bSphereRadiusFactor: number;
  79615. private _scene;
  79616. private _positions;
  79617. private _indices;
  79618. private _normals;
  79619. private _colors;
  79620. private _uvs;
  79621. private _indices32;
  79622. private _positions32;
  79623. private _normals32;
  79624. private _fixedNormal32;
  79625. private _colors32;
  79626. private _uvs32;
  79627. private _index;
  79628. private _updatable;
  79629. private _pickable;
  79630. private _isVisibilityBoxLocked;
  79631. private _alwaysVisible;
  79632. private _depthSort;
  79633. private _shapeCounter;
  79634. private _copy;
  79635. private _color;
  79636. private _computeParticleColor;
  79637. private _computeParticleTexture;
  79638. private _computeParticleRotation;
  79639. private _computeParticleVertex;
  79640. private _computeBoundingBox;
  79641. private _depthSortParticles;
  79642. private _camera;
  79643. private _mustUnrotateFixedNormals;
  79644. private _particlesIntersect;
  79645. private _needs32Bits;
  79646. /**
  79647. * Creates a SPS (Solid Particle System) object.
  79648. * @param name (String) is the SPS name, this will be the underlying mesh name.
  79649. * @param scene (Scene) is the scene in which the SPS is added.
  79650. * @param options defines the options of the sps e.g.
  79651. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  79652. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  79653. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  79654. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  79655. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  79656. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  79657. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  79658. */
  79659. constructor(name: string, scene: Scene, options?: {
  79660. updatable?: boolean;
  79661. isPickable?: boolean;
  79662. enableDepthSort?: boolean;
  79663. particleIntersection?: boolean;
  79664. boundingSphereOnly?: boolean;
  79665. bSphereRadiusFactor?: number;
  79666. });
  79667. /**
  79668. * Builds the SPS underlying mesh. Returns a standard Mesh.
  79669. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  79670. * @returns the created mesh
  79671. */
  79672. buildMesh(): Mesh;
  79673. /**
  79674. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  79675. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  79676. * Thus the particles generated from `digest()` have their property `position` set yet.
  79677. * @param mesh ( Mesh ) is the mesh to be digested
  79678. * @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
  79679. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  79680. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  79681. * @returns the current SPS
  79682. */
  79683. digest(mesh: Mesh, options?: {
  79684. facetNb?: number;
  79685. number?: number;
  79686. delta?: number;
  79687. }): SolidParticleSystem;
  79688. private _unrotateFixedNormals;
  79689. private _resetCopy;
  79690. private _meshBuilder;
  79691. private _posToShape;
  79692. private _uvsToShapeUV;
  79693. private _addParticle;
  79694. /**
  79695. * Adds some particles to the SPS from the model shape. Returns the shape id.
  79696. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  79697. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  79698. * @param nb (positive integer) the number of particles to be created from this model
  79699. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  79700. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  79701. * @returns the number of shapes in the system
  79702. */
  79703. addShape(mesh: Mesh, nb: number, options?: {
  79704. positionFunction?: any;
  79705. vertexFunction?: any;
  79706. }): number;
  79707. private _rebuildParticle;
  79708. /**
  79709. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  79710. * @returns the SPS.
  79711. */
  79712. rebuildMesh(): SolidParticleSystem;
  79713. /**
  79714. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  79715. * This method calls `updateParticle()` for each particle of the SPS.
  79716. * For an animated SPS, it is usually called within the render loop.
  79717. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  79718. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  79719. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  79720. * @returns the SPS.
  79721. */
  79722. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  79723. /**
  79724. * Disposes the SPS.
  79725. */
  79726. dispose(): void;
  79727. /**
  79728. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  79729. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79730. * @returns the SPS.
  79731. */
  79732. refreshVisibleSize(): SolidParticleSystem;
  79733. /**
  79734. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  79735. * @param size the size (float) of the visibility box
  79736. * note : this doesn't lock the SPS mesh bounding box.
  79737. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79738. */
  79739. setVisibilityBox(size: number): void;
  79740. /**
  79741. * Gets whether the SPS as always visible or not
  79742. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79743. */
  79744. /**
  79745. * Sets the SPS as always visible or not
  79746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79747. */
  79748. isAlwaysVisible: boolean;
  79749. /**
  79750. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79751. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79752. */
  79753. /**
  79754. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79755. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79756. */
  79757. isVisibilityBoxLocked: boolean;
  79758. /**
  79759. * Tells to `setParticles()` to compute the particle rotations or not.
  79760. * Default value : true. The SPS is faster when it's set to false.
  79761. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79762. */
  79763. /**
  79764. * Gets if `setParticles()` computes the particle rotations or not.
  79765. * Default value : true. The SPS is faster when it's set to false.
  79766. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79767. */
  79768. computeParticleRotation: boolean;
  79769. /**
  79770. * Tells to `setParticles()` to compute the particle colors or not.
  79771. * Default value : true. The SPS is faster when it's set to false.
  79772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79773. */
  79774. /**
  79775. * Gets if `setParticles()` computes the particle colors or not.
  79776. * Default value : true. The SPS is faster when it's set to false.
  79777. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79778. */
  79779. computeParticleColor: boolean;
  79780. /**
  79781. * Gets if `setParticles()` computes the particle textures or not.
  79782. * Default value : true. The SPS is faster when it's set to false.
  79783. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  79784. */
  79785. computeParticleTexture: boolean;
  79786. /**
  79787. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  79788. * Default value : false. The SPS is faster when it's set to false.
  79789. * Note : the particle custom vertex positions aren't stored values.
  79790. */
  79791. /**
  79792. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  79793. * Default value : false. The SPS is faster when it's set to false.
  79794. * Note : the particle custom vertex positions aren't stored values.
  79795. */
  79796. computeParticleVertex: boolean;
  79797. /**
  79798. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  79799. */
  79800. /**
  79801. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  79802. */
  79803. computeBoundingBox: boolean;
  79804. /**
  79805. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  79806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79807. * Default : `true`
  79808. */
  79809. /**
  79810. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  79811. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79812. * Default : `true`
  79813. */
  79814. depthSortParticles: boolean;
  79815. /**
  79816. * This function does nothing. It may be overwritten to set all the particle first values.
  79817. * The SPS doesn't call this function, you may have to call it by your own.
  79818. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79819. */
  79820. initParticles(): void;
  79821. /**
  79822. * This function does nothing. It may be overwritten to recycle a particle.
  79823. * The SPS doesn't call this function, you may have to call it by your own.
  79824. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79825. * @param particle The particle to recycle
  79826. * @returns the recycled particle
  79827. */
  79828. recycleParticle(particle: SolidParticle): SolidParticle;
  79829. /**
  79830. * Updates a particle : this function should be overwritten by the user.
  79831. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  79832. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79833. * @example : just set a particle position or velocity and recycle conditions
  79834. * @param particle The particle to update
  79835. * @returns the updated particle
  79836. */
  79837. updateParticle(particle: SolidParticle): SolidParticle;
  79838. /**
  79839. * Updates a vertex of a particle : it can be overwritten by the user.
  79840. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  79841. * @param particle the current particle
  79842. * @param vertex the current index of the current particle
  79843. * @param pt the index of the current vertex in the particle shape
  79844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  79845. * @example : just set a vertex particle position
  79846. * @returns the updated vertex
  79847. */
  79848. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  79849. /**
  79850. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  79851. * This does nothing and may be overwritten by the user.
  79852. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79853. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79854. * @param update the boolean update value actually passed to setParticles()
  79855. */
  79856. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79857. /**
  79858. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  79859. * This will be passed three parameters.
  79860. * This does nothing and may be overwritten by the user.
  79861. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79862. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79863. * @param update the boolean update value actually passed to setParticles()
  79864. */
  79865. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79866. }
  79867. }
  79868. declare module BABYLON {
  79869. /**
  79870. * Represents one particle of a solid particle system.
  79871. */
  79872. export class SolidParticle {
  79873. /**
  79874. * particle global index
  79875. */
  79876. idx: number;
  79877. /**
  79878. * The color of the particle
  79879. */
  79880. color: Nullable<Color4>;
  79881. /**
  79882. * The world space position of the particle.
  79883. */
  79884. position: Vector3;
  79885. /**
  79886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  79887. */
  79888. rotation: Vector3;
  79889. /**
  79890. * The world space rotation quaternion of the particle.
  79891. */
  79892. rotationQuaternion: Nullable<Quaternion>;
  79893. /**
  79894. * The scaling of the particle.
  79895. */
  79896. scaling: Vector3;
  79897. /**
  79898. * The uvs of the particle.
  79899. */
  79900. uvs: Vector4;
  79901. /**
  79902. * The current speed of the particle.
  79903. */
  79904. velocity: Vector3;
  79905. /**
  79906. * The pivot point in the particle local space.
  79907. */
  79908. pivot: Vector3;
  79909. /**
  79910. * Must the particle be translated from its pivot point in its local space ?
  79911. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  79912. * Default : false
  79913. */
  79914. translateFromPivot: boolean;
  79915. /**
  79916. * Is the particle active or not ?
  79917. */
  79918. alive: boolean;
  79919. /**
  79920. * Is the particle visible or not ?
  79921. */
  79922. isVisible: boolean;
  79923. /**
  79924. * Index of this particle in the global "positions" array (Internal use)
  79925. * @hidden
  79926. */
  79927. _pos: number;
  79928. /**
  79929. * @hidden Index of this particle in the global "indices" array (Internal use)
  79930. */
  79931. _ind: number;
  79932. /**
  79933. * @hidden ModelShape of this particle (Internal use)
  79934. */
  79935. _model: ModelShape;
  79936. /**
  79937. * ModelShape id of this particle
  79938. */
  79939. shapeId: number;
  79940. /**
  79941. * Index of the particle in its shape id (Internal use)
  79942. */
  79943. idxInShape: number;
  79944. /**
  79945. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  79946. */
  79947. _modelBoundingInfo: BoundingInfo;
  79948. /**
  79949. * @hidden Particle BoundingInfo object (Internal use)
  79950. */
  79951. _boundingInfo: BoundingInfo;
  79952. /**
  79953. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  79954. */
  79955. _sps: SolidParticleSystem;
  79956. /**
  79957. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  79958. */
  79959. _stillInvisible: boolean;
  79960. /**
  79961. * @hidden Last computed particle rotation matrix
  79962. */
  79963. _rotationMatrix: number[];
  79964. /**
  79965. * Parent particle Id, if any.
  79966. * Default null.
  79967. */
  79968. parentId: Nullable<number>;
  79969. /**
  79970. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  79971. * The possible values are :
  79972. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79973. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79976. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79977. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  79978. * */
  79979. cullingStrategy: number;
  79980. /**
  79981. * @hidden Internal global position in the SPS.
  79982. */
  79983. _globalPosition: Vector3;
  79984. /**
  79985. * Creates a Solid Particle object.
  79986. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  79987. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  79988. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  79989. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  79990. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  79991. * @param shapeId (integer) is the model shape identifier in the SPS.
  79992. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  79993. * @param sps defines the sps it is associated to
  79994. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  79995. */
  79996. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  79997. /**
  79998. * Legacy support, changed scale to scaling
  79999. */
  80000. /**
  80001. * Legacy support, changed scale to scaling
  80002. */
  80003. scale: Vector3;
  80004. /**
  80005. * Legacy support, changed quaternion to rotationQuaternion
  80006. */
  80007. /**
  80008. * Legacy support, changed quaternion to rotationQuaternion
  80009. */
  80010. quaternion: Nullable<Quaternion>;
  80011. /**
  80012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80015. * @returns true if it intersects
  80016. */
  80017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80018. /**
  80019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80020. * A particle is in the frustum if its bounding box intersects the frustum
  80021. * @param frustumPlanes defines the frustum to test
  80022. * @returns true if the particle is in the frustum planes
  80023. */
  80024. isInFrustum(frustumPlanes: Plane[]): boolean;
  80025. /**
  80026. * get the rotation matrix of the particle
  80027. * @hidden
  80028. */
  80029. getRotationMatrix(m: Matrix): void;
  80030. }
  80031. /**
  80032. * Represents the shape of the model used by one particle of a solid particle system.
  80033. * SPS internal tool, don't use it manually.
  80034. */
  80035. export class ModelShape {
  80036. /**
  80037. * The shape id
  80038. * @hidden
  80039. */
  80040. shapeID: number;
  80041. /**
  80042. * flat array of model positions (internal use)
  80043. * @hidden
  80044. */
  80045. _shape: Vector3[];
  80046. /**
  80047. * flat array of model UVs (internal use)
  80048. * @hidden
  80049. */
  80050. _shapeUV: number[];
  80051. /**
  80052. * length of the shape in the model indices array (internal use)
  80053. * @hidden
  80054. */
  80055. _indicesLength: number;
  80056. /**
  80057. * Custom position function (internal use)
  80058. * @hidden
  80059. */
  80060. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80061. /**
  80062. * Custom vertex function (internal use)
  80063. * @hidden
  80064. */
  80065. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80066. /**
  80067. * 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.
  80068. * SPS internal tool, don't use it manually.
  80069. * @hidden
  80070. */
  80071. 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>);
  80072. }
  80073. /**
  80074. * Represents a Depth Sorted Particle in the solid particle system.
  80075. */
  80076. export class DepthSortedParticle {
  80077. /**
  80078. * Index of the particle in the "indices" array
  80079. */
  80080. ind: number;
  80081. /**
  80082. * Length of the particle shape in the "indices" array
  80083. */
  80084. indicesLength: number;
  80085. /**
  80086. * Squared distance from the particle to the camera
  80087. */
  80088. sqDistance: number;
  80089. }
  80090. }
  80091. declare module BABYLON {
  80092. /**
  80093. * Class used to store all common mesh properties
  80094. */
  80095. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80096. /** No occlusion */
  80097. static OCCLUSION_TYPE_NONE: number;
  80098. /** Occlusion set to optimisitic */
  80099. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80100. /** Occlusion set to strict */
  80101. static OCCLUSION_TYPE_STRICT: number;
  80102. /** Use an accurante occlusion algorithm */
  80103. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80104. /** Use a conservative occlusion algorithm */
  80105. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80106. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80107. * Test order :
  80108. * Is the bounding sphere outside the frustum ?
  80109. * If not, are the bounding box vertices outside the frustum ?
  80110. * It not, then the cullable object is in the frustum.
  80111. */
  80112. static readonly CULLINGSTRATEGY_STANDARD: number;
  80113. /** Culling strategy : Bounding Sphere Only.
  80114. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80115. * It's also less accurate than the standard because some not visible objects can still be selected.
  80116. * Test : is the bounding sphere outside the frustum ?
  80117. * If not, then the cullable object is in the frustum.
  80118. */
  80119. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80120. /** Culling strategy : Optimistic Inclusion.
  80121. * This in an inclusion test first, then the standard exclusion test.
  80122. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80123. * 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.
  80124. * Anyway, it's as accurate as the standard strategy.
  80125. * Test :
  80126. * Is the cullable object bounding sphere center in the frustum ?
  80127. * If not, apply the default culling strategy.
  80128. */
  80129. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80130. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80131. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80132. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80133. * 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.
  80134. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80135. * Test :
  80136. * Is the cullable object bounding sphere center in the frustum ?
  80137. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80138. */
  80139. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80140. /**
  80141. * No billboard
  80142. */
  80143. static readonly BILLBOARDMODE_NONE: number;
  80144. /** Billboard on X axis */
  80145. static readonly BILLBOARDMODE_X: number;
  80146. /** Billboard on Y axis */
  80147. static readonly BILLBOARDMODE_Y: number;
  80148. /** Billboard on Z axis */
  80149. static readonly BILLBOARDMODE_Z: number;
  80150. /** Billboard on all axes */
  80151. static readonly BILLBOARDMODE_ALL: number;
  80152. private _facetData;
  80153. /**
  80154. * The culling strategy to use to check whether the mesh must be rendered or not.
  80155. * This value can be changed at any time and will be used on the next render mesh selection.
  80156. * The possible values are :
  80157. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80158. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80161. * Please read each static variable documentation to get details about the culling process.
  80162. * */
  80163. cullingStrategy: number;
  80164. /**
  80165. * Gets the number of facets in the mesh
  80166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80167. */
  80168. readonly facetNb: number;
  80169. /**
  80170. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80172. */
  80173. partitioningSubdivisions: number;
  80174. /**
  80175. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80176. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80178. */
  80179. partitioningBBoxRatio: number;
  80180. /**
  80181. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80182. * Works only for updatable meshes.
  80183. * Doesn't work with multi-materials
  80184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80185. */
  80186. mustDepthSortFacets: boolean;
  80187. /**
  80188. * The location (Vector3) where the facet depth sort must be computed from.
  80189. * By default, the active camera position.
  80190. * Used only when facet depth sort is enabled
  80191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80192. */
  80193. facetDepthSortFrom: Vector3;
  80194. /**
  80195. * gets a boolean indicating if facetData is enabled
  80196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80197. */
  80198. readonly isFacetDataEnabled: boolean;
  80199. /** @hidden */
  80200. _updateNonUniformScalingState(value: boolean): boolean;
  80201. /**
  80202. * An event triggered when this mesh collides with another one
  80203. */
  80204. onCollideObservable: Observable<AbstractMesh>;
  80205. private _onCollideObserver;
  80206. /** Set a function to call when this mesh collides with another one */
  80207. onCollide: () => void;
  80208. /**
  80209. * An event triggered when the collision's position changes
  80210. */
  80211. onCollisionPositionChangeObservable: Observable<Vector3>;
  80212. private _onCollisionPositionChangeObserver;
  80213. /** Set a function to call when the collision's position changes */
  80214. onCollisionPositionChange: () => void;
  80215. /**
  80216. * An event triggered when material is changed
  80217. */
  80218. onMaterialChangedObservable: Observable<AbstractMesh>;
  80219. /**
  80220. * Gets or sets the orientation for POV movement & rotation
  80221. */
  80222. definedFacingForward: boolean;
  80223. /** @hidden */
  80224. _occlusionQuery: Nullable<WebGLQuery>;
  80225. private _visibility;
  80226. /**
  80227. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80228. */
  80229. /**
  80230. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80231. */
  80232. visibility: number;
  80233. /** Gets or sets the alpha index used to sort transparent meshes
  80234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80235. */
  80236. alphaIndex: number;
  80237. /**
  80238. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80239. */
  80240. isVisible: boolean;
  80241. /**
  80242. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80243. */
  80244. isPickable: boolean;
  80245. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80246. showSubMeshesBoundingBox: boolean;
  80247. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80249. */
  80250. isBlocker: boolean;
  80251. /**
  80252. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80253. */
  80254. enablePointerMoveEvents: boolean;
  80255. /**
  80256. * Specifies the rendering group id for this mesh (0 by default)
  80257. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80258. */
  80259. renderingGroupId: number;
  80260. private _material;
  80261. /** Gets or sets current material */
  80262. material: Nullable<Material>;
  80263. private _receiveShadows;
  80264. /**
  80265. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80266. * @see http://doc.babylonjs.com/babylon101/shadows
  80267. */
  80268. receiveShadows: boolean;
  80269. /** Defines color to use when rendering outline */
  80270. outlineColor: Color3;
  80271. /** Define width to use when rendering outline */
  80272. outlineWidth: number;
  80273. /** Defines color to use when rendering overlay */
  80274. overlayColor: Color3;
  80275. /** Defines alpha to use when rendering overlay */
  80276. overlayAlpha: number;
  80277. private _hasVertexAlpha;
  80278. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80279. hasVertexAlpha: boolean;
  80280. private _useVertexColors;
  80281. /** 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) */
  80282. useVertexColors: boolean;
  80283. private _computeBonesUsingShaders;
  80284. /**
  80285. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80286. */
  80287. computeBonesUsingShaders: boolean;
  80288. private _numBoneInfluencers;
  80289. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80290. numBoneInfluencers: number;
  80291. private _applyFog;
  80292. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80293. applyFog: boolean;
  80294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80295. useOctreeForRenderingSelection: boolean;
  80296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80297. useOctreeForPicking: boolean;
  80298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80299. useOctreeForCollisions: boolean;
  80300. private _layerMask;
  80301. /**
  80302. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80303. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80304. */
  80305. layerMask: number;
  80306. /**
  80307. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80308. */
  80309. alwaysSelectAsActiveMesh: boolean;
  80310. /**
  80311. * Gets or sets the current action manager
  80312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80313. */
  80314. actionManager: Nullable<AbstractActionManager>;
  80315. private _checkCollisions;
  80316. private _collisionMask;
  80317. private _collisionGroup;
  80318. /**
  80319. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80321. */
  80322. ellipsoid: Vector3;
  80323. /**
  80324. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80326. */
  80327. ellipsoidOffset: Vector3;
  80328. private _collider;
  80329. private _oldPositionForCollisions;
  80330. private _diffPositionForCollisions;
  80331. /**
  80332. * Gets or sets a collision mask used to mask collisions (default is -1).
  80333. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80334. */
  80335. collisionMask: number;
  80336. /**
  80337. * Gets or sets the current collision group mask (-1 by default).
  80338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80339. */
  80340. collisionGroup: number;
  80341. /**
  80342. * Defines edge width used when edgesRenderer is enabled
  80343. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80344. */
  80345. edgesWidth: number;
  80346. /**
  80347. * Defines edge color used when edgesRenderer is enabled
  80348. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80349. */
  80350. edgesColor: Color4;
  80351. /** @hidden */
  80352. _edgesRenderer: Nullable<IEdgesRenderer>;
  80353. /** @hidden */
  80354. _masterMesh: Nullable<AbstractMesh>;
  80355. /** @hidden */
  80356. _boundingInfo: Nullable<BoundingInfo>;
  80357. /** @hidden */
  80358. _renderId: number;
  80359. /**
  80360. * Gets or sets the list of subMeshes
  80361. * @see http://doc.babylonjs.com/how_to/multi_materials
  80362. */
  80363. subMeshes: SubMesh[];
  80364. /** @hidden */
  80365. _intersectionsInProgress: AbstractMesh[];
  80366. /** @hidden */
  80367. _unIndexed: boolean;
  80368. /** @hidden */
  80369. _lightSources: Light[];
  80370. /** @hidden */
  80371. readonly _positions: Nullable<Vector3[]>;
  80372. /** @hidden */
  80373. _waitingActions: any;
  80374. /** @hidden */
  80375. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80376. private _skeleton;
  80377. /** @hidden */
  80378. _bonesTransformMatrices: Nullable<Float32Array>;
  80379. /**
  80380. * Gets or sets a skeleton to apply skining transformations
  80381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80382. */
  80383. skeleton: Nullable<Skeleton>;
  80384. /**
  80385. * An event triggered when the mesh is rebuilt.
  80386. */
  80387. onRebuildObservable: Observable<AbstractMesh>;
  80388. /**
  80389. * Creates a new AbstractMesh
  80390. * @param name defines the name of the mesh
  80391. * @param scene defines the hosting scene
  80392. */
  80393. constructor(name: string, scene?: Nullable<Scene>);
  80394. /**
  80395. * Returns the string "AbstractMesh"
  80396. * @returns "AbstractMesh"
  80397. */
  80398. getClassName(): string;
  80399. /**
  80400. * Gets a string representation of the current mesh
  80401. * @param fullDetails defines a boolean indicating if full details must be included
  80402. * @returns a string representation of the current mesh
  80403. */
  80404. toString(fullDetails?: boolean): string;
  80405. /** @hidden */
  80406. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80407. /** @hidden */
  80408. _rebuild(): void;
  80409. /** @hidden */
  80410. _resyncLightSources(): void;
  80411. /** @hidden */
  80412. _resyncLighSource(light: Light): void;
  80413. /** @hidden */
  80414. _unBindEffect(): void;
  80415. /** @hidden */
  80416. _removeLightSource(light: Light): void;
  80417. private _markSubMeshesAsDirty;
  80418. /** @hidden */
  80419. _markSubMeshesAsLightDirty(): void;
  80420. /** @hidden */
  80421. _markSubMeshesAsAttributesDirty(): void;
  80422. /** @hidden */
  80423. _markSubMeshesAsMiscDirty(): void;
  80424. /**
  80425. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80426. */
  80427. scaling: Vector3;
  80428. /**
  80429. * Returns true if the mesh is blocked. Implemented by child classes
  80430. */
  80431. readonly isBlocked: boolean;
  80432. /**
  80433. * Returns the mesh itself by default. Implemented by child classes
  80434. * @param camera defines the camera to use to pick the right LOD level
  80435. * @returns the currentAbstractMesh
  80436. */
  80437. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80438. /**
  80439. * Returns 0 by default. Implemented by child classes
  80440. * @returns an integer
  80441. */
  80442. getTotalVertices(): number;
  80443. /**
  80444. * Returns a positive integer : the total number of indices in this mesh geometry.
  80445. * @returns the numner of indices or zero if the mesh has no geometry.
  80446. */
  80447. getTotalIndices(): number;
  80448. /**
  80449. * Returns null by default. Implemented by child classes
  80450. * @returns null
  80451. */
  80452. getIndices(): Nullable<IndicesArray>;
  80453. /**
  80454. * Returns the array of the requested vertex data kind. Implemented by child classes
  80455. * @param kind defines the vertex data kind to use
  80456. * @returns null
  80457. */
  80458. getVerticesData(kind: string): Nullable<FloatArray>;
  80459. /**
  80460. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80461. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80462. * Note that a new underlying VertexBuffer object is created each call.
  80463. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80464. * @param kind defines vertex data kind:
  80465. * * VertexBuffer.PositionKind
  80466. * * VertexBuffer.UVKind
  80467. * * VertexBuffer.UV2Kind
  80468. * * VertexBuffer.UV3Kind
  80469. * * VertexBuffer.UV4Kind
  80470. * * VertexBuffer.UV5Kind
  80471. * * VertexBuffer.UV6Kind
  80472. * * VertexBuffer.ColorKind
  80473. * * VertexBuffer.MatricesIndicesKind
  80474. * * VertexBuffer.MatricesIndicesExtraKind
  80475. * * VertexBuffer.MatricesWeightsKind
  80476. * * VertexBuffer.MatricesWeightsExtraKind
  80477. * @param data defines the data source
  80478. * @param updatable defines if the data must be flagged as updatable (or static)
  80479. * @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
  80480. * @returns the current mesh
  80481. */
  80482. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80483. /**
  80484. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80485. * If the mesh has no geometry, it is simply returned as it is.
  80486. * @param kind defines vertex data kind:
  80487. * * VertexBuffer.PositionKind
  80488. * * VertexBuffer.UVKind
  80489. * * VertexBuffer.UV2Kind
  80490. * * VertexBuffer.UV3Kind
  80491. * * VertexBuffer.UV4Kind
  80492. * * VertexBuffer.UV5Kind
  80493. * * VertexBuffer.UV6Kind
  80494. * * VertexBuffer.ColorKind
  80495. * * VertexBuffer.MatricesIndicesKind
  80496. * * VertexBuffer.MatricesIndicesExtraKind
  80497. * * VertexBuffer.MatricesWeightsKind
  80498. * * VertexBuffer.MatricesWeightsExtraKind
  80499. * @param data defines the data source
  80500. * @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
  80501. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80502. * @returns the current mesh
  80503. */
  80504. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  80505. /**
  80506. * Sets the mesh indices,
  80507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80508. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80509. * @param totalVertices Defines the total number of vertices
  80510. * @returns the current mesh
  80511. */
  80512. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  80513. /**
  80514. * Gets a boolean indicating if specific vertex data is present
  80515. * @param kind defines the vertex data kind to use
  80516. * @returns true is data kind is present
  80517. */
  80518. isVerticesDataPresent(kind: string): boolean;
  80519. /**
  80520. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80521. * @returns a BoundingInfo
  80522. */
  80523. getBoundingInfo(): BoundingInfo;
  80524. /**
  80525. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80526. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80527. * @returns the current mesh
  80528. */
  80529. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  80530. /**
  80531. * Overwrite the current bounding info
  80532. * @param boundingInfo defines the new bounding info
  80533. * @returns the current mesh
  80534. */
  80535. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  80536. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80537. readonly useBones: boolean;
  80538. /** @hidden */
  80539. _preActivate(): void;
  80540. /** @hidden */
  80541. _preActivateForIntermediateRendering(renderId: number): void;
  80542. /** @hidden */
  80543. _activate(renderId: number): void;
  80544. /**
  80545. * Gets the current world matrix
  80546. * @returns a Matrix
  80547. */
  80548. getWorldMatrix(): Matrix;
  80549. /** @hidden */
  80550. _getWorldMatrixDeterminant(): number;
  80551. /**
  80552. * Perform relative position change from the point of view of behind the front of the mesh.
  80553. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80554. * Supports definition of mesh facing forward or backward
  80555. * @param amountRight defines the distance on the right axis
  80556. * @param amountUp defines the distance on the up axis
  80557. * @param amountForward defines the distance on the forward axis
  80558. * @returns the current mesh
  80559. */
  80560. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  80561. /**
  80562. * Calculate relative position change from the point of view of behind the front of the mesh.
  80563. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80564. * Supports definition of mesh facing forward or backward
  80565. * @param amountRight defines the distance on the right axis
  80566. * @param amountUp defines the distance on the up axis
  80567. * @param amountForward defines the distance on the forward axis
  80568. * @returns the new displacement vector
  80569. */
  80570. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  80571. /**
  80572. * Perform relative rotation change from the point of view of behind the front of the mesh.
  80573. * Supports definition of mesh facing forward or backward
  80574. * @param flipBack defines the flip
  80575. * @param twirlClockwise defines the twirl
  80576. * @param tiltRight defines the tilt
  80577. * @returns the current mesh
  80578. */
  80579. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  80580. /**
  80581. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  80582. * Supports definition of mesh facing forward or backward.
  80583. * @param flipBack defines the flip
  80584. * @param twirlClockwise defines the twirl
  80585. * @param tiltRight defines the tilt
  80586. * @returns the new rotation vector
  80587. */
  80588. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  80589. /**
  80590. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  80591. * @param includeDescendants Include bounding info from descendants as well (true by default)
  80592. * @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
  80593. * @returns the new bounding vectors
  80594. */
  80595. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  80596. min: Vector3;
  80597. max: Vector3;
  80598. };
  80599. /**
  80600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80601. * This means the mesh underlying bounding box and sphere are recomputed.
  80602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80603. * @returns the current mesh
  80604. */
  80605. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  80606. /** @hidden */
  80607. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  80608. /** @hidden */
  80609. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  80610. /** @hidden */
  80611. _updateBoundingInfo(): AbstractMesh;
  80612. /** @hidden */
  80613. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  80614. /** @hidden */
  80615. protected _afterComputeWorldMatrix(): void;
  80616. /**
  80617. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80618. * A mesh is in the frustum if its bounding box intersects the frustum
  80619. * @param frustumPlanes defines the frustum to test
  80620. * @returns true if the mesh is in the frustum planes
  80621. */
  80622. isInFrustum(frustumPlanes: Plane[]): boolean;
  80623. /**
  80624. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  80625. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  80626. * @param frustumPlanes defines the frustum to test
  80627. * @returns true if the mesh is completely in the frustum planes
  80628. */
  80629. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80630. /**
  80631. * True if the mesh intersects another mesh or a SolidParticle object
  80632. * @param mesh defines a target mesh or SolidParticle to test
  80633. * @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)
  80634. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  80635. * @returns true if there is an intersection
  80636. */
  80637. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  80638. /**
  80639. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  80640. * @param point defines the point to test
  80641. * @returns true if there is an intersection
  80642. */
  80643. intersectsPoint(point: Vector3): boolean;
  80644. /**
  80645. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80646. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80647. */
  80648. checkCollisions: boolean;
  80649. /**
  80650. * Gets Collider object used to compute collisions (not physics)
  80651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80652. */
  80653. readonly collider: Collider;
  80654. /**
  80655. * Move the mesh using collision engine
  80656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80657. * @param displacement defines the requested displacement vector
  80658. * @returns the current mesh
  80659. */
  80660. moveWithCollisions(displacement: Vector3): AbstractMesh;
  80661. private _onCollisionPositionChange;
  80662. /** @hidden */
  80663. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  80664. /** @hidden */
  80665. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  80666. /** @hidden */
  80667. _checkCollision(collider: Collider): AbstractMesh;
  80668. /** @hidden */
  80669. _generatePointsArray(): boolean;
  80670. /**
  80671. * Checks if the passed Ray intersects with the mesh
  80672. * @param ray defines the ray to use
  80673. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80674. * @returns the picking info
  80675. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80676. */
  80677. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  80678. /**
  80679. * Clones the current mesh
  80680. * @param name defines the mesh name
  80681. * @param newParent defines the new mesh parent
  80682. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80683. * @returns the new mesh
  80684. */
  80685. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  80686. /**
  80687. * Disposes all the submeshes of the current meshnp
  80688. * @returns the current mesh
  80689. */
  80690. releaseSubMeshes(): AbstractMesh;
  80691. /**
  80692. * Releases resources associated with this abstract mesh.
  80693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80695. */
  80696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80697. /**
  80698. * Adds the passed mesh as a child to the current mesh
  80699. * @param mesh defines the child mesh
  80700. * @returns the current mesh
  80701. */
  80702. addChild(mesh: AbstractMesh): AbstractMesh;
  80703. /**
  80704. * Removes the passed mesh from the current mesh children list
  80705. * @param mesh defines the child mesh
  80706. * @returns the current mesh
  80707. */
  80708. removeChild(mesh: AbstractMesh): AbstractMesh;
  80709. /** @hidden */
  80710. private _initFacetData;
  80711. /**
  80712. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80713. * This method can be called within the render loop.
  80714. * 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
  80715. * @returns the current mesh
  80716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80717. */
  80718. updateFacetData(): AbstractMesh;
  80719. /**
  80720. * Returns the facetLocalNormals array.
  80721. * The normals are expressed in the mesh local spac
  80722. * @returns an array of Vector3
  80723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80724. */
  80725. getFacetLocalNormals(): Vector3[];
  80726. /**
  80727. * Returns the facetLocalPositions array.
  80728. * The facet positions are expressed in the mesh local space
  80729. * @returns an array of Vector3
  80730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80731. */
  80732. getFacetLocalPositions(): Vector3[];
  80733. /**
  80734. * Returns the facetLocalPartioning array
  80735. * @returns an array of array of numbers
  80736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80737. */
  80738. getFacetLocalPartitioning(): number[][];
  80739. /**
  80740. * Returns the i-th facet position in the world system.
  80741. * This method allocates a new Vector3 per call
  80742. * @param i defines the facet index
  80743. * @returns a new Vector3
  80744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80745. */
  80746. getFacetPosition(i: number): Vector3;
  80747. /**
  80748. * Sets the reference Vector3 with the i-th facet position in the world system
  80749. * @param i defines the facet index
  80750. * @param ref defines the target vector
  80751. * @returns the current mesh
  80752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80753. */
  80754. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  80755. /**
  80756. * Returns the i-th facet normal in the world system.
  80757. * This method allocates a new Vector3 per call
  80758. * @param i defines the facet index
  80759. * @returns a new Vector3
  80760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80761. */
  80762. getFacetNormal(i: number): Vector3;
  80763. /**
  80764. * Sets the reference Vector3 with the i-th facet normal in the world system
  80765. * @param i defines the facet index
  80766. * @param ref defines the target vector
  80767. * @returns the current mesh
  80768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80769. */
  80770. getFacetNormalToRef(i: number, ref: Vector3): this;
  80771. /**
  80772. * 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)
  80773. * @param x defines x coordinate
  80774. * @param y defines y coordinate
  80775. * @param z defines z coordinate
  80776. * @returns the array of facet indexes
  80777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80778. */
  80779. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  80780. /**
  80781. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80782. * @param projected sets as the (x,y,z) world projection on the facet
  80783. * @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
  80784. * @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
  80785. * @param x defines x coordinate
  80786. * @param y defines y coordinate
  80787. * @param z defines z coordinate
  80788. * @returns the face index if found (or null instead)
  80789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80790. */
  80791. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80792. /**
  80793. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80794. * @param projected sets as the (x,y,z) local projection on the facet
  80795. * @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
  80796. * @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
  80797. * @param x defines x coordinate
  80798. * @param y defines y coordinate
  80799. * @param z defines z coordinate
  80800. * @returns the face index if found (or null instead)
  80801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80802. */
  80803. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80804. /**
  80805. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80806. * @returns the parameters
  80807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80808. */
  80809. getFacetDataParameters(): any;
  80810. /**
  80811. * Disables the feature FacetData and frees the related memory
  80812. * @returns the current mesh
  80813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80814. */
  80815. disableFacetData(): AbstractMesh;
  80816. /**
  80817. * Updates the AbstractMesh indices array
  80818. * @param indices defines the data source
  80819. * @returns the current mesh
  80820. */
  80821. updateIndices(indices: IndicesArray): AbstractMesh;
  80822. /**
  80823. * Creates new normals data for the mesh
  80824. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80825. * @returns the current mesh
  80826. */
  80827. createNormals(updatable: boolean): AbstractMesh;
  80828. /**
  80829. * Align the mesh with a normal
  80830. * @param normal defines the normal to use
  80831. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80832. * @returns the current mesh
  80833. */
  80834. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  80835. /** @hidden */
  80836. _checkOcclusionQuery(): boolean;
  80837. }
  80838. }
  80839. declare module BABYLON {
  80840. /**
  80841. * Interface used to define ActionEvent
  80842. */
  80843. export interface IActionEvent {
  80844. /** The mesh or sprite that triggered the action */
  80845. source: any;
  80846. /** The X mouse cursor position at the time of the event */
  80847. pointerX: number;
  80848. /** The Y mouse cursor position at the time of the event */
  80849. pointerY: number;
  80850. /** The mesh that is currently pointed at (can be null) */
  80851. meshUnderPointer: Nullable<AbstractMesh>;
  80852. /** the original (browser) event that triggered the ActionEvent */
  80853. sourceEvent?: any;
  80854. /** additional data for the event */
  80855. additionalData?: any;
  80856. }
  80857. /**
  80858. * ActionEvent is the event being sent when an action is triggered.
  80859. */
  80860. export class ActionEvent implements IActionEvent {
  80861. /** The mesh or sprite that triggered the action */
  80862. source: any;
  80863. /** The X mouse cursor position at the time of the event */
  80864. pointerX: number;
  80865. /** The Y mouse cursor position at the time of the event */
  80866. pointerY: number;
  80867. /** The mesh that is currently pointed at (can be null) */
  80868. meshUnderPointer: Nullable<AbstractMesh>;
  80869. /** the original (browser) event that triggered the ActionEvent */
  80870. sourceEvent?: any;
  80871. /** additional data for the event */
  80872. additionalData?: any;
  80873. /**
  80874. * Creates a new ActionEvent
  80875. * @param source The mesh or sprite that triggered the action
  80876. * @param pointerX The X mouse cursor position at the time of the event
  80877. * @param pointerY The Y mouse cursor position at the time of the event
  80878. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  80879. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  80880. * @param additionalData additional data for the event
  80881. */
  80882. constructor(
  80883. /** The mesh or sprite that triggered the action */
  80884. source: any,
  80885. /** The X mouse cursor position at the time of the event */
  80886. pointerX: number,
  80887. /** The Y mouse cursor position at the time of the event */
  80888. pointerY: number,
  80889. /** The mesh that is currently pointed at (can be null) */
  80890. meshUnderPointer: Nullable<AbstractMesh>,
  80891. /** the original (browser) event that triggered the ActionEvent */
  80892. sourceEvent?: any,
  80893. /** additional data for the event */
  80894. additionalData?: any);
  80895. /**
  80896. * Helper function to auto-create an ActionEvent from a source mesh.
  80897. * @param source The source mesh that triggered the event
  80898. * @param evt The original (browser) event
  80899. * @param additionalData additional data for the event
  80900. * @returns the new ActionEvent
  80901. */
  80902. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  80903. /**
  80904. * Helper function to auto-create an ActionEvent from a source sprite
  80905. * @param source The source sprite that triggered the event
  80906. * @param scene Scene associated with the sprite
  80907. * @param evt The original (browser) event
  80908. * @param additionalData additional data for the event
  80909. * @returns the new ActionEvent
  80910. */
  80911. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  80912. /**
  80913. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  80914. * @param scene the scene where the event occurred
  80915. * @param evt The original (browser) event
  80916. * @returns the new ActionEvent
  80917. */
  80918. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  80919. /**
  80920. * Helper function to auto-create an ActionEvent from a primitive
  80921. * @param prim defines the target primitive
  80922. * @param pointerPos defines the pointer position
  80923. * @param evt The original (browser) event
  80924. * @param additionalData additional data for the event
  80925. * @returns the new ActionEvent
  80926. */
  80927. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  80928. }
  80929. }
  80930. declare module BABYLON {
  80931. /**
  80932. * Abstract class used to decouple action Manager from scene and meshes.
  80933. * Do not instantiate.
  80934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80935. */
  80936. export abstract class AbstractActionManager implements IDisposable {
  80937. /** Gets the list of active triggers */
  80938. static Triggers: {
  80939. [key: string]: number;
  80940. };
  80941. /** Gets the cursor to use when hovering items */
  80942. hoverCursor: string;
  80943. /** Gets the list of actions */
  80944. actions: IAction[];
  80945. /**
  80946. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  80947. */
  80948. isRecursive: boolean;
  80949. /**
  80950. * Releases all associated resources
  80951. */
  80952. abstract dispose(): void;
  80953. /**
  80954. * Does this action manager has pointer triggers
  80955. */
  80956. abstract readonly hasPointerTriggers: boolean;
  80957. /**
  80958. * Does this action manager has pick triggers
  80959. */
  80960. abstract readonly hasPickTriggers: boolean;
  80961. /**
  80962. * Process a specific trigger
  80963. * @param trigger defines the trigger to process
  80964. * @param evt defines the event details to be processed
  80965. */
  80966. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  80967. /**
  80968. * Does this action manager handles actions of any of the given triggers
  80969. * @param triggers defines the triggers to be tested
  80970. * @return a boolean indicating whether one (or more) of the triggers is handled
  80971. */
  80972. abstract hasSpecificTriggers(triggers: number[]): boolean;
  80973. /**
  80974. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80975. * speed.
  80976. * @param triggerA defines the trigger to be tested
  80977. * @param triggerB defines the trigger to be tested
  80978. * @return a boolean indicating whether one (or more) of the triggers is handled
  80979. */
  80980. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80981. /**
  80982. * Does this action manager handles actions of a given trigger
  80983. * @param trigger defines the trigger to be tested
  80984. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80985. * @return whether the trigger is handled
  80986. */
  80987. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80988. /**
  80989. * Serialize this manager to a JSON object
  80990. * @param name defines the property name to store this manager
  80991. * @returns a JSON representation of this manager
  80992. */
  80993. abstract serialize(name: string): any;
  80994. /**
  80995. * Does exist one action manager with at least one trigger
  80996. **/
  80997. static readonly HasTriggers: boolean;
  80998. /**
  80999. * Does exist one action manager with at least one pick trigger
  81000. **/
  81001. static readonly HasPickTriggers: boolean;
  81002. /**
  81003. * Does exist one action manager that handles actions of a given trigger
  81004. * @param trigger defines the trigger to be tested
  81005. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81006. **/
  81007. static HasSpecificTrigger(trigger: number): boolean;
  81008. }
  81009. }
  81010. declare module BABYLON {
  81011. /**
  81012. * Defines how a node can be built from a string name.
  81013. */
  81014. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81015. /**
  81016. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81017. */
  81018. export class Node implements IBehaviorAware<Node> {
  81019. /** @hidden */
  81020. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81021. private static _NodeConstructors;
  81022. /**
  81023. * Add a new node constructor
  81024. * @param type defines the type name of the node to construct
  81025. * @param constructorFunc defines the constructor function
  81026. */
  81027. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81028. /**
  81029. * Returns a node constructor based on type name
  81030. * @param type defines the type name
  81031. * @param name defines the new node name
  81032. * @param scene defines the hosting scene
  81033. * @param options defines optional options to transmit to constructors
  81034. * @returns the new constructor or null
  81035. */
  81036. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81037. /**
  81038. * Gets or sets the name of the node
  81039. */
  81040. name: string;
  81041. /**
  81042. * Gets or sets the id of the node
  81043. */
  81044. id: string;
  81045. /**
  81046. * Gets or sets the unique id of the node
  81047. */
  81048. uniqueId: number;
  81049. /**
  81050. * Gets or sets a string used to store user defined state for the node
  81051. */
  81052. state: string;
  81053. /**
  81054. * Gets or sets an object used to store user defined information for the node
  81055. */
  81056. metadata: any;
  81057. /**
  81058. * For internal use only. Please do not use.
  81059. */
  81060. reservedDataStore: any;
  81061. /**
  81062. * Gets or sets a boolean used to define if the node must be serialized
  81063. */
  81064. doNotSerialize: boolean;
  81065. /** @hidden */
  81066. _isDisposed: boolean;
  81067. /**
  81068. * Gets a list of Animations associated with the node
  81069. */
  81070. animations: Animation[];
  81071. protected _ranges: {
  81072. [name: string]: Nullable<AnimationRange>;
  81073. };
  81074. /**
  81075. * Callback raised when the node is ready to be used
  81076. */
  81077. onReady: (node: Node) => void;
  81078. private _isEnabled;
  81079. private _isParentEnabled;
  81080. private _isReady;
  81081. /** @hidden */
  81082. _currentRenderId: number;
  81083. private _parentRenderId;
  81084. protected _childRenderId: number;
  81085. /** @hidden */
  81086. _waitingParentId: Nullable<string>;
  81087. /** @hidden */
  81088. _scene: Scene;
  81089. /** @hidden */
  81090. _cache: any;
  81091. private _parentNode;
  81092. private _children;
  81093. /** @hidden */
  81094. _worldMatrix: Matrix;
  81095. /** @hidden */
  81096. _worldMatrixDeterminant: number;
  81097. /** @hidden */
  81098. private _sceneRootNodesIndex;
  81099. /**
  81100. * Gets a boolean indicating if the node has been disposed
  81101. * @returns true if the node was disposed
  81102. */
  81103. isDisposed(): boolean;
  81104. /**
  81105. * Gets or sets the parent of the node
  81106. */
  81107. parent: Nullable<Node>;
  81108. private addToSceneRootNodes;
  81109. private removeFromSceneRootNodes;
  81110. private _animationPropertiesOverride;
  81111. /**
  81112. * Gets or sets the animation properties override
  81113. */
  81114. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81115. /**
  81116. * Gets a string idenfifying the name of the class
  81117. * @returns "Node" string
  81118. */
  81119. getClassName(): string;
  81120. /** @hidden */
  81121. readonly _isNode: boolean;
  81122. /**
  81123. * An event triggered when the mesh is disposed
  81124. */
  81125. onDisposeObservable: Observable<Node>;
  81126. private _onDisposeObserver;
  81127. /**
  81128. * Sets a callback that will be raised when the node will be disposed
  81129. */
  81130. onDispose: () => void;
  81131. /**
  81132. * Creates a new Node
  81133. * @param name the name and id to be given to this node
  81134. * @param scene the scene this node will be added to
  81135. * @param addToRootNodes the node will be added to scene.rootNodes
  81136. */
  81137. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81138. /**
  81139. * Gets the scene of the node
  81140. * @returns a scene
  81141. */
  81142. getScene(): Scene;
  81143. /**
  81144. * Gets the engine of the node
  81145. * @returns a Engine
  81146. */
  81147. getEngine(): Engine;
  81148. private _behaviors;
  81149. /**
  81150. * Attach a behavior to the node
  81151. * @see http://doc.babylonjs.com/features/behaviour
  81152. * @param behavior defines the behavior to attach
  81153. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81154. * @returns the current Node
  81155. */
  81156. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81157. /**
  81158. * Remove an attached behavior
  81159. * @see http://doc.babylonjs.com/features/behaviour
  81160. * @param behavior defines the behavior to attach
  81161. * @returns the current Node
  81162. */
  81163. removeBehavior(behavior: Behavior<Node>): Node;
  81164. /**
  81165. * Gets the list of attached behaviors
  81166. * @see http://doc.babylonjs.com/features/behaviour
  81167. */
  81168. readonly behaviors: Behavior<Node>[];
  81169. /**
  81170. * Gets an attached behavior by name
  81171. * @param name defines the name of the behavior to look for
  81172. * @see http://doc.babylonjs.com/features/behaviour
  81173. * @returns null if behavior was not found else the requested behavior
  81174. */
  81175. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81176. /**
  81177. * Returns the latest update of the World matrix
  81178. * @returns a Matrix
  81179. */
  81180. getWorldMatrix(): Matrix;
  81181. /** @hidden */
  81182. _getWorldMatrixDeterminant(): number;
  81183. /**
  81184. * Returns directly the latest state of the mesh World matrix.
  81185. * A Matrix is returned.
  81186. */
  81187. readonly worldMatrixFromCache: Matrix;
  81188. /** @hidden */
  81189. _initCache(): void;
  81190. /** @hidden */
  81191. updateCache(force?: boolean): void;
  81192. /** @hidden */
  81193. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81194. /** @hidden */
  81195. _updateCache(ignoreParentClass?: boolean): void;
  81196. /** @hidden */
  81197. _isSynchronized(): boolean;
  81198. /** @hidden */
  81199. _markSyncedWithParent(): void;
  81200. /** @hidden */
  81201. isSynchronizedWithParent(): boolean;
  81202. /** @hidden */
  81203. isSynchronized(): boolean;
  81204. /**
  81205. * Is this node ready to be used/rendered
  81206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81207. * @return true if the node is ready
  81208. */
  81209. isReady(completeCheck?: boolean): boolean;
  81210. /**
  81211. * Is this node enabled?
  81212. * 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
  81213. * @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
  81214. * @return whether this node (and its parent) is enabled
  81215. */
  81216. isEnabled(checkAncestors?: boolean): boolean;
  81217. /** @hidden */
  81218. protected _syncParentEnabledState(): void;
  81219. /**
  81220. * Set the enabled state of this node
  81221. * @param value defines the new enabled state
  81222. */
  81223. setEnabled(value: boolean): void;
  81224. /**
  81225. * Is this node a descendant of the given node?
  81226. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81227. * @param ancestor defines the parent node to inspect
  81228. * @returns a boolean indicating if this node is a descendant of the given node
  81229. */
  81230. isDescendantOf(ancestor: Node): boolean;
  81231. /** @hidden */
  81232. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81233. /**
  81234. * Will return all nodes that have this node as ascendant
  81235. * @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
  81236. * @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
  81237. * @return all children nodes of all types
  81238. */
  81239. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81240. /**
  81241. * Get all child-meshes of this node
  81242. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  81243. * @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
  81244. * @returns an array of AbstractMesh
  81245. */
  81246. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81247. /**
  81248. * Get all direct children of this node
  81249. * @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
  81250. * @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)
  81251. * @returns an array of Node
  81252. */
  81253. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81254. /** @hidden */
  81255. _setReady(state: boolean): void;
  81256. /**
  81257. * Get an animation by name
  81258. * @param name defines the name of the animation to look for
  81259. * @returns null if not found else the requested animation
  81260. */
  81261. getAnimationByName(name: string): Nullable<Animation>;
  81262. /**
  81263. * Creates an animation range for this node
  81264. * @param name defines the name of the range
  81265. * @param from defines the starting key
  81266. * @param to defines the end key
  81267. */
  81268. createAnimationRange(name: string, from: number, to: number): void;
  81269. /**
  81270. * Delete a specific animation range
  81271. * @param name defines the name of the range to delete
  81272. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81273. */
  81274. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81275. /**
  81276. * Get an animation range by name
  81277. * @param name defines the name of the animation range to look for
  81278. * @returns null if not found else the requested animation range
  81279. */
  81280. getAnimationRange(name: string): Nullable<AnimationRange>;
  81281. /**
  81282. * Will start the animation sequence
  81283. * @param name defines the range frames for animation sequence
  81284. * @param loop defines if the animation should loop (false by default)
  81285. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81286. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81287. * @returns the object created for this animation. If range does not exist, it will return null
  81288. */
  81289. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81290. /**
  81291. * Serialize animation ranges into a JSON compatible object
  81292. * @returns serialization object
  81293. */
  81294. serializeAnimationRanges(): any;
  81295. /**
  81296. * Computes the world matrix of the node
  81297. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81298. * @returns the world matrix
  81299. */
  81300. computeWorldMatrix(force?: boolean): Matrix;
  81301. /**
  81302. * Releases resources associated with this node.
  81303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81305. */
  81306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81307. /**
  81308. * Parse animation range data from a serialization object and store them into a given node
  81309. * @param node defines where to store the animation ranges
  81310. * @param parsedNode defines the serialization object to read data from
  81311. * @param scene defines the hosting scene
  81312. */
  81313. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81314. }
  81315. }
  81316. declare module BABYLON {
  81317. /**
  81318. * Class used to store any kind of animation
  81319. */
  81320. export class Animation {
  81321. /**Name of the animation */
  81322. name: string;
  81323. /**Property to animate */
  81324. targetProperty: string;
  81325. /**The frames per second of the animation */
  81326. framePerSecond: number;
  81327. /**The data type of the animation */
  81328. dataType: number;
  81329. /**The loop mode of the animation */
  81330. loopMode?: number | undefined;
  81331. /**Specifies if blending should be enabled */
  81332. enableBlending?: boolean | undefined;
  81333. /**
  81334. * Use matrix interpolation instead of using direct key value when animating matrices
  81335. */
  81336. static AllowMatricesInterpolation: boolean;
  81337. /**
  81338. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81339. */
  81340. static AllowMatrixDecomposeForInterpolation: boolean;
  81341. /**
  81342. * Stores the key frames of the animation
  81343. */
  81344. private _keys;
  81345. /**
  81346. * Stores the easing function of the animation
  81347. */
  81348. private _easingFunction;
  81349. /**
  81350. * @hidden Internal use only
  81351. */
  81352. _runtimeAnimations: RuntimeAnimation[];
  81353. /**
  81354. * The set of event that will be linked to this animation
  81355. */
  81356. private _events;
  81357. /**
  81358. * Stores an array of target property paths
  81359. */
  81360. targetPropertyPath: string[];
  81361. /**
  81362. * Stores the blending speed of the animation
  81363. */
  81364. blendingSpeed: number;
  81365. /**
  81366. * Stores the animation ranges for the animation
  81367. */
  81368. private _ranges;
  81369. /**
  81370. * @hidden Internal use
  81371. */
  81372. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81373. /**
  81374. * Sets up an animation
  81375. * @param property The property to animate
  81376. * @param animationType The animation type to apply
  81377. * @param framePerSecond The frames per second of the animation
  81378. * @param easingFunction The easing function used in the animation
  81379. * @returns The created animation
  81380. */
  81381. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81382. /**
  81383. * Create and start an animation on a node
  81384. * @param name defines the name of the global animation that will be run on all nodes
  81385. * @param node defines the root node where the animation will take place
  81386. * @param targetProperty defines property to animate
  81387. * @param framePerSecond defines the number of frame per second yo use
  81388. * @param totalFrame defines the number of frames in total
  81389. * @param from defines the initial value
  81390. * @param to defines the final value
  81391. * @param loopMode defines which loop mode you want to use (off by default)
  81392. * @param easingFunction defines the easing function to use (linear by default)
  81393. * @param onAnimationEnd defines the callback to call when animation end
  81394. * @returns the animatable created for this animation
  81395. */
  81396. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81397. /**
  81398. * Create and start an animation on a node and its descendants
  81399. * @param name defines the name of the global animation that will be run on all nodes
  81400. * @param node defines the root node where the animation will take place
  81401. * @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
  81402. * @param targetProperty defines property to animate
  81403. * @param framePerSecond defines the number of frame per second to use
  81404. * @param totalFrame defines the number of frames in total
  81405. * @param from defines the initial value
  81406. * @param to defines the final value
  81407. * @param loopMode defines which loop mode you want to use (off by default)
  81408. * @param easingFunction defines the easing function to use (linear by default)
  81409. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81410. * @returns the list of animatables created for all nodes
  81411. * @example https://www.babylonjs-playground.com/#MH0VLI
  81412. */
  81413. 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[]>;
  81414. /**
  81415. * Creates a new animation, merges it with the existing animations and starts it
  81416. * @param name Name of the animation
  81417. * @param node Node which contains the scene that begins the animations
  81418. * @param targetProperty Specifies which property to animate
  81419. * @param framePerSecond The frames per second of the animation
  81420. * @param totalFrame The total number of frames
  81421. * @param from The frame at the beginning of the animation
  81422. * @param to The frame at the end of the animation
  81423. * @param loopMode Specifies the loop mode of the animation
  81424. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81425. * @param onAnimationEnd Callback to run once the animation is complete
  81426. * @returns Nullable animation
  81427. */
  81428. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81429. /**
  81430. * Transition property of an host to the target Value
  81431. * @param property The property to transition
  81432. * @param targetValue The target Value of the property
  81433. * @param host The object where the property to animate belongs
  81434. * @param scene Scene used to run the animation
  81435. * @param frameRate Framerate (in frame/s) to use
  81436. * @param transition The transition type we want to use
  81437. * @param duration The duration of the animation, in milliseconds
  81438. * @param onAnimationEnd Callback trigger at the end of the animation
  81439. * @returns Nullable animation
  81440. */
  81441. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81442. /**
  81443. * Return the array of runtime animations currently using this animation
  81444. */
  81445. readonly runtimeAnimations: RuntimeAnimation[];
  81446. /**
  81447. * Specifies if any of the runtime animations are currently running
  81448. */
  81449. readonly hasRunningRuntimeAnimations: boolean;
  81450. /**
  81451. * Initializes the animation
  81452. * @param name Name of the animation
  81453. * @param targetProperty Property to animate
  81454. * @param framePerSecond The frames per second of the animation
  81455. * @param dataType The data type of the animation
  81456. * @param loopMode The loop mode of the animation
  81457. * @param enableBlending Specifies if blending should be enabled
  81458. */
  81459. constructor(
  81460. /**Name of the animation */
  81461. name: string,
  81462. /**Property to animate */
  81463. targetProperty: string,
  81464. /**The frames per second of the animation */
  81465. framePerSecond: number,
  81466. /**The data type of the animation */
  81467. dataType: number,
  81468. /**The loop mode of the animation */
  81469. loopMode?: number | undefined,
  81470. /**Specifies if blending should be enabled */
  81471. enableBlending?: boolean | undefined);
  81472. /**
  81473. * Converts the animation to a string
  81474. * @param fullDetails support for multiple levels of logging within scene loading
  81475. * @returns String form of the animation
  81476. */
  81477. toString(fullDetails?: boolean): string;
  81478. /**
  81479. * Add an event to this animation
  81480. * @param event Event to add
  81481. */
  81482. addEvent(event: AnimationEvent): void;
  81483. /**
  81484. * Remove all events found at the given frame
  81485. * @param frame The frame to remove events from
  81486. */
  81487. removeEvents(frame: number): void;
  81488. /**
  81489. * Retrieves all the events from the animation
  81490. * @returns Events from the animation
  81491. */
  81492. getEvents(): AnimationEvent[];
  81493. /**
  81494. * Creates an animation range
  81495. * @param name Name of the animation range
  81496. * @param from Starting frame of the animation range
  81497. * @param to Ending frame of the animation
  81498. */
  81499. createRange(name: string, from: number, to: number): void;
  81500. /**
  81501. * Deletes an animation range by name
  81502. * @param name Name of the animation range to delete
  81503. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81504. */
  81505. deleteRange(name: string, deleteFrames?: boolean): void;
  81506. /**
  81507. * Gets the animation range by name, or null if not defined
  81508. * @param name Name of the animation range
  81509. * @returns Nullable animation range
  81510. */
  81511. getRange(name: string): Nullable<AnimationRange>;
  81512. /**
  81513. * Gets the key frames from the animation
  81514. * @returns The key frames of the animation
  81515. */
  81516. getKeys(): Array<IAnimationKey>;
  81517. /**
  81518. * Gets the highest frame rate of the animation
  81519. * @returns Highest frame rate of the animation
  81520. */
  81521. getHighestFrame(): number;
  81522. /**
  81523. * Gets the easing function of the animation
  81524. * @returns Easing function of the animation
  81525. */
  81526. getEasingFunction(): IEasingFunction;
  81527. /**
  81528. * Sets the easing function of the animation
  81529. * @param easingFunction A custom mathematical formula for animation
  81530. */
  81531. setEasingFunction(easingFunction: EasingFunction): void;
  81532. /**
  81533. * Interpolates a scalar linearly
  81534. * @param startValue Start value of the animation curve
  81535. * @param endValue End value of the animation curve
  81536. * @param gradient Scalar amount to interpolate
  81537. * @returns Interpolated scalar value
  81538. */
  81539. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81540. /**
  81541. * Interpolates a scalar cubically
  81542. * @param startValue Start value of the animation curve
  81543. * @param outTangent End tangent of the animation
  81544. * @param endValue End value of the animation curve
  81545. * @param inTangent Start tangent of the animation curve
  81546. * @param gradient Scalar amount to interpolate
  81547. * @returns Interpolated scalar value
  81548. */
  81549. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81550. /**
  81551. * Interpolates a quaternion using a spherical linear interpolation
  81552. * @param startValue Start value of the animation curve
  81553. * @param endValue End value of the animation curve
  81554. * @param gradient Scalar amount to interpolate
  81555. * @returns Interpolated quaternion value
  81556. */
  81557. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81558. /**
  81559. * Interpolates a quaternion cubically
  81560. * @param startValue Start value of the animation curve
  81561. * @param outTangent End tangent of the animation curve
  81562. * @param endValue End value of the animation curve
  81563. * @param inTangent Start tangent of the animation curve
  81564. * @param gradient Scalar amount to interpolate
  81565. * @returns Interpolated quaternion value
  81566. */
  81567. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81568. /**
  81569. * Interpolates a Vector3 linearl
  81570. * @param startValue Start value of the animation curve
  81571. * @param endValue End value of the animation curve
  81572. * @param gradient Scalar amount to interpolate
  81573. * @returns Interpolated scalar value
  81574. */
  81575. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81576. /**
  81577. * Interpolates a Vector3 cubically
  81578. * @param startValue Start value of the animation curve
  81579. * @param outTangent End tangent of the animation
  81580. * @param endValue End value of the animation curve
  81581. * @param inTangent Start tangent of the animation curve
  81582. * @param gradient Scalar amount to interpolate
  81583. * @returns InterpolatedVector3 value
  81584. */
  81585. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81586. /**
  81587. * Interpolates a Vector2 linearly
  81588. * @param startValue Start value of the animation curve
  81589. * @param endValue End value of the animation curve
  81590. * @param gradient Scalar amount to interpolate
  81591. * @returns Interpolated Vector2 value
  81592. */
  81593. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81594. /**
  81595. * Interpolates a Vector2 cubically
  81596. * @param startValue Start value of the animation curve
  81597. * @param outTangent End tangent of the animation
  81598. * @param endValue End value of the animation curve
  81599. * @param inTangent Start tangent of the animation curve
  81600. * @param gradient Scalar amount to interpolate
  81601. * @returns Interpolated Vector2 value
  81602. */
  81603. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81604. /**
  81605. * Interpolates a size linearly
  81606. * @param startValue Start value of the animation curve
  81607. * @param endValue End value of the animation curve
  81608. * @param gradient Scalar amount to interpolate
  81609. * @returns Interpolated Size value
  81610. */
  81611. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81612. /**
  81613. * Interpolates a Color3 linearly
  81614. * @param startValue Start value of the animation curve
  81615. * @param endValue End value of the animation curve
  81616. * @param gradient Scalar amount to interpolate
  81617. * @returns Interpolated Color3 value
  81618. */
  81619. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81620. /**
  81621. * @hidden Internal use only
  81622. */
  81623. _getKeyValue(value: any): any;
  81624. /**
  81625. * @hidden Internal use only
  81626. */
  81627. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81628. /**
  81629. * Defines the function to use to interpolate matrices
  81630. * @param startValue defines the start matrix
  81631. * @param endValue defines the end matrix
  81632. * @param gradient defines the gradient between both matrices
  81633. * @param result defines an optional target matrix where to store the interpolation
  81634. * @returns the interpolated matrix
  81635. */
  81636. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81637. /**
  81638. * Makes a copy of the animation
  81639. * @returns Cloned animation
  81640. */
  81641. clone(): Animation;
  81642. /**
  81643. * Sets the key frames of the animation
  81644. * @param values The animation key frames to set
  81645. */
  81646. setKeys(values: Array<IAnimationKey>): void;
  81647. /**
  81648. * Serializes the animation to an object
  81649. * @returns Serialized object
  81650. */
  81651. serialize(): any;
  81652. /**
  81653. * Float animation type
  81654. */
  81655. private static _ANIMATIONTYPE_FLOAT;
  81656. /**
  81657. * Vector3 animation type
  81658. */
  81659. private static _ANIMATIONTYPE_VECTOR3;
  81660. /**
  81661. * Quaternion animation type
  81662. */
  81663. private static _ANIMATIONTYPE_QUATERNION;
  81664. /**
  81665. * Matrix animation type
  81666. */
  81667. private static _ANIMATIONTYPE_MATRIX;
  81668. /**
  81669. * Color3 animation type
  81670. */
  81671. private static _ANIMATIONTYPE_COLOR3;
  81672. /**
  81673. * Vector2 animation type
  81674. */
  81675. private static _ANIMATIONTYPE_VECTOR2;
  81676. /**
  81677. * Size animation type
  81678. */
  81679. private static _ANIMATIONTYPE_SIZE;
  81680. /**
  81681. * Relative Loop Mode
  81682. */
  81683. private static _ANIMATIONLOOPMODE_RELATIVE;
  81684. /**
  81685. * Cycle Loop Mode
  81686. */
  81687. private static _ANIMATIONLOOPMODE_CYCLE;
  81688. /**
  81689. * Constant Loop Mode
  81690. */
  81691. private static _ANIMATIONLOOPMODE_CONSTANT;
  81692. /**
  81693. * Get the float animation type
  81694. */
  81695. static readonly ANIMATIONTYPE_FLOAT: number;
  81696. /**
  81697. * Get the Vector3 animation type
  81698. */
  81699. static readonly ANIMATIONTYPE_VECTOR3: number;
  81700. /**
  81701. * Get the Vector2 animation type
  81702. */
  81703. static readonly ANIMATIONTYPE_VECTOR2: number;
  81704. /**
  81705. * Get the Size animation type
  81706. */
  81707. static readonly ANIMATIONTYPE_SIZE: number;
  81708. /**
  81709. * Get the Quaternion animation type
  81710. */
  81711. static readonly ANIMATIONTYPE_QUATERNION: number;
  81712. /**
  81713. * Get the Matrix animation type
  81714. */
  81715. static readonly ANIMATIONTYPE_MATRIX: number;
  81716. /**
  81717. * Get the Color3 animation type
  81718. */
  81719. static readonly ANIMATIONTYPE_COLOR3: number;
  81720. /**
  81721. * Get the Relative Loop Mode
  81722. */
  81723. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81724. /**
  81725. * Get the Cycle Loop Mode
  81726. */
  81727. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81728. /**
  81729. * Get the Constant Loop Mode
  81730. */
  81731. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81732. /** @hidden */
  81733. static _UniversalLerp(left: any, right: any, amount: number): any;
  81734. /**
  81735. * Parses an animation object and creates an animation
  81736. * @param parsedAnimation Parsed animation object
  81737. * @returns Animation object
  81738. */
  81739. static Parse(parsedAnimation: any): Animation;
  81740. /**
  81741. * Appends the serialized animations from the source animations
  81742. * @param source Source containing the animations
  81743. * @param destination Target to store the animations
  81744. */
  81745. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81746. }
  81747. }
  81748. declare module BABYLON {
  81749. /**
  81750. * Base class of all the textures in babylon.
  81751. * It groups all the common properties the materials, post process, lights... might need
  81752. * in order to make a correct use of the texture.
  81753. */
  81754. export class BaseTexture implements IAnimatable {
  81755. /**
  81756. * Default anisotropic filtering level for the application.
  81757. * It is set to 4 as a good tradeoff between perf and quality.
  81758. */
  81759. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81760. /**
  81761. * Gets or sets the unique id of the texture
  81762. */
  81763. uniqueId: number;
  81764. /**
  81765. * Define the name of the texture.
  81766. */
  81767. name: string;
  81768. /**
  81769. * Gets or sets an object used to store user defined information.
  81770. */
  81771. metadata: any;
  81772. /**
  81773. * For internal use only. Please do not use.
  81774. */
  81775. reservedDataStore: any;
  81776. private _hasAlpha;
  81777. /**
  81778. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81779. */
  81780. hasAlpha: boolean;
  81781. /**
  81782. * Defines if the alpha value should be determined via the rgb values.
  81783. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81784. */
  81785. getAlphaFromRGB: boolean;
  81786. /**
  81787. * Intensity or strength of the texture.
  81788. * It is commonly used by materials to fine tune the intensity of the texture
  81789. */
  81790. level: number;
  81791. /**
  81792. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81793. * This is part of the texture as textures usually maps to one uv set.
  81794. */
  81795. coordinatesIndex: number;
  81796. private _coordinatesMode;
  81797. /**
  81798. * How a texture is mapped.
  81799. *
  81800. * | Value | Type | Description |
  81801. * | ----- | ----------------------------------- | ----------- |
  81802. * | 0 | EXPLICIT_MODE | |
  81803. * | 1 | SPHERICAL_MODE | |
  81804. * | 2 | PLANAR_MODE | |
  81805. * | 3 | CUBIC_MODE | |
  81806. * | 4 | PROJECTION_MODE | |
  81807. * | 5 | SKYBOX_MODE | |
  81808. * | 6 | INVCUBIC_MODE | |
  81809. * | 7 | EQUIRECTANGULAR_MODE | |
  81810. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81811. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81812. */
  81813. coordinatesMode: number;
  81814. /**
  81815. * | Value | Type | Description |
  81816. * | ----- | ------------------ | ----------- |
  81817. * | 0 | CLAMP_ADDRESSMODE | |
  81818. * | 1 | WRAP_ADDRESSMODE | |
  81819. * | 2 | MIRROR_ADDRESSMODE | |
  81820. */
  81821. wrapU: number;
  81822. /**
  81823. * | Value | Type | Description |
  81824. * | ----- | ------------------ | ----------- |
  81825. * | 0 | CLAMP_ADDRESSMODE | |
  81826. * | 1 | WRAP_ADDRESSMODE | |
  81827. * | 2 | MIRROR_ADDRESSMODE | |
  81828. */
  81829. wrapV: number;
  81830. /**
  81831. * | Value | Type | Description |
  81832. * | ----- | ------------------ | ----------- |
  81833. * | 0 | CLAMP_ADDRESSMODE | |
  81834. * | 1 | WRAP_ADDRESSMODE | |
  81835. * | 2 | MIRROR_ADDRESSMODE | |
  81836. */
  81837. wrapR: number;
  81838. /**
  81839. * With compliant hardware and browser (supporting anisotropic filtering)
  81840. * this defines the level of anisotropic filtering in the texture.
  81841. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81842. */
  81843. anisotropicFilteringLevel: number;
  81844. /**
  81845. * Define if the texture is a cube texture or if false a 2d texture.
  81846. */
  81847. isCube: boolean;
  81848. /**
  81849. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81850. */
  81851. is3D: boolean;
  81852. /**
  81853. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81854. * HDR texture are usually stored in linear space.
  81855. * This only impacts the PBR and Background materials
  81856. */
  81857. gammaSpace: boolean;
  81858. /**
  81859. * Gets whether or not the texture contains RGBD data.
  81860. */
  81861. readonly isRGBD: boolean;
  81862. /**
  81863. * Is Z inverted in the texture (useful in a cube texture).
  81864. */
  81865. invertZ: boolean;
  81866. /**
  81867. * Are mip maps generated for this texture or not.
  81868. */
  81869. readonly noMipmap: boolean;
  81870. /**
  81871. * @hidden
  81872. */
  81873. lodLevelInAlpha: boolean;
  81874. /**
  81875. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81876. */
  81877. lodGenerationOffset: number;
  81878. /**
  81879. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81880. */
  81881. lodGenerationScale: number;
  81882. /**
  81883. * Define if the texture is a render target.
  81884. */
  81885. isRenderTarget: boolean;
  81886. /**
  81887. * Define the unique id of the texture in the scene.
  81888. */
  81889. readonly uid: string;
  81890. /**
  81891. * Return a string representation of the texture.
  81892. * @returns the texture as a string
  81893. */
  81894. toString(): string;
  81895. /**
  81896. * Get the class name of the texture.
  81897. * @returns "BaseTexture"
  81898. */
  81899. getClassName(): string;
  81900. /**
  81901. * Define the list of animation attached to the texture.
  81902. */
  81903. animations: Animation[];
  81904. /**
  81905. * An event triggered when the texture is disposed.
  81906. */
  81907. onDisposeObservable: Observable<BaseTexture>;
  81908. private _onDisposeObserver;
  81909. /**
  81910. * Callback triggered when the texture has been disposed.
  81911. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81912. */
  81913. onDispose: () => void;
  81914. /**
  81915. * Define the current state of the loading sequence when in delayed load mode.
  81916. */
  81917. delayLoadState: number;
  81918. private _scene;
  81919. /** @hidden */
  81920. _texture: Nullable<InternalTexture>;
  81921. private _uid;
  81922. /**
  81923. * Define if the texture is preventinga material to render or not.
  81924. * If not and the texture is not ready, the engine will use a default black texture instead.
  81925. */
  81926. readonly isBlocking: boolean;
  81927. /**
  81928. * Instantiates a new BaseTexture.
  81929. * Base class of all the textures in babylon.
  81930. * It groups all the common properties the materials, post process, lights... might need
  81931. * in order to make a correct use of the texture.
  81932. * @param scene Define the scene the texture blongs to
  81933. */
  81934. constructor(scene: Nullable<Scene>);
  81935. /**
  81936. * Get the scene the texture belongs to.
  81937. * @returns the scene or null if undefined
  81938. */
  81939. getScene(): Nullable<Scene>;
  81940. /**
  81941. * Get the texture transform matrix used to offset tile the texture for istance.
  81942. * @returns the transformation matrix
  81943. */
  81944. getTextureMatrix(): Matrix;
  81945. /**
  81946. * Get the texture reflection matrix used to rotate/transform the reflection.
  81947. * @returns the reflection matrix
  81948. */
  81949. getReflectionTextureMatrix(): Matrix;
  81950. /**
  81951. * Get the underlying lower level texture from Babylon.
  81952. * @returns the insternal texture
  81953. */
  81954. getInternalTexture(): Nullable<InternalTexture>;
  81955. /**
  81956. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81957. * @returns true if ready or not blocking
  81958. */
  81959. isReadyOrNotBlocking(): boolean;
  81960. /**
  81961. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81962. * @returns true if fully ready
  81963. */
  81964. isReady(): boolean;
  81965. private _cachedSize;
  81966. /**
  81967. * Get the size of the texture.
  81968. * @returns the texture size.
  81969. */
  81970. getSize(): ISize;
  81971. /**
  81972. * Get the base size of the texture.
  81973. * It can be different from the size if the texture has been resized for POT for instance
  81974. * @returns the base size
  81975. */
  81976. getBaseSize(): ISize;
  81977. /**
  81978. * Update the sampling mode of the texture.
  81979. * Default is Trilinear mode.
  81980. *
  81981. * | Value | Type | Description |
  81982. * | ----- | ------------------ | ----------- |
  81983. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81984. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81985. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81986. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81987. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81988. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81989. * | 7 | NEAREST_LINEAR | |
  81990. * | 8 | NEAREST_NEAREST | |
  81991. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81992. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81993. * | 11 | LINEAR_LINEAR | |
  81994. * | 12 | LINEAR_NEAREST | |
  81995. *
  81996. * > _mag_: magnification filter (close to the viewer)
  81997. * > _min_: minification filter (far from the viewer)
  81998. * > _mip_: filter used between mip map levels
  81999. *@param samplingMode Define the new sampling mode of the texture
  82000. */
  82001. updateSamplingMode(samplingMode: number): void;
  82002. /**
  82003. * Scales the texture if is `canRescale()`
  82004. * @param ratio the resize factor we want to use to rescale
  82005. */
  82006. scale(ratio: number): void;
  82007. /**
  82008. * Get if the texture can rescale.
  82009. */
  82010. readonly canRescale: boolean;
  82011. /** @hidden */
  82012. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  82013. /** @hidden */
  82014. _rebuild(): void;
  82015. /**
  82016. * Triggers the load sequence in delayed load mode.
  82017. */
  82018. delayLoad(): void;
  82019. /**
  82020. * Clones the texture.
  82021. * @returns the cloned texture
  82022. */
  82023. clone(): Nullable<BaseTexture>;
  82024. /**
  82025. * Get the texture underlying type (INT, FLOAT...)
  82026. */
  82027. readonly textureType: number;
  82028. /**
  82029. * Get the texture underlying format (RGB, RGBA...)
  82030. */
  82031. readonly textureFormat: number;
  82032. /**
  82033. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82034. * This will returns an RGBA array buffer containing either in values (0-255) or
  82035. * float values (0-1) depending of the underlying buffer type.
  82036. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82037. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82038. * @param buffer defines a user defined buffer to fill with data (can be null)
  82039. * @returns The Array buffer containing the pixels data.
  82040. */
  82041. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82042. /**
  82043. * Release and destroy the underlying lower level texture aka internalTexture.
  82044. */
  82045. releaseInternalTexture(): void;
  82046. /**
  82047. * Get the polynomial representation of the texture data.
  82048. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82049. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82050. */
  82051. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82052. /** @hidden */
  82053. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82054. /** @hidden */
  82055. readonly _lodTextureMid: Nullable<BaseTexture>;
  82056. /** @hidden */
  82057. readonly _lodTextureLow: Nullable<BaseTexture>;
  82058. /**
  82059. * Dispose the texture and release its associated resources.
  82060. */
  82061. dispose(): void;
  82062. /**
  82063. * Serialize the texture into a JSON representation that can be parsed later on.
  82064. * @returns the JSON representation of the texture
  82065. */
  82066. serialize(): any;
  82067. /**
  82068. * Helper function to be called back once a list of texture contains only ready textures.
  82069. * @param textures Define the list of textures to wait for
  82070. * @param callback Define the callback triggered once the entire list will be ready
  82071. */
  82072. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82073. }
  82074. }
  82075. declare module BABYLON {
  82076. /**
  82077. * Uniform buffer objects.
  82078. *
  82079. * Handles blocks of uniform on the GPU.
  82080. *
  82081. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82082. *
  82083. * For more information, please refer to :
  82084. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82085. */
  82086. export class UniformBuffer {
  82087. private _engine;
  82088. private _buffer;
  82089. private _data;
  82090. private _bufferData;
  82091. private _dynamic?;
  82092. private _uniformLocations;
  82093. private _uniformSizes;
  82094. private _uniformLocationPointer;
  82095. private _needSync;
  82096. private _noUBO;
  82097. private _currentEffect;
  82098. private static _MAX_UNIFORM_SIZE;
  82099. private static _tempBuffer;
  82100. /**
  82101. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82102. * This is dynamic to allow compat with webgl 1 and 2.
  82103. * You will need to pass the name of the uniform as well as the value.
  82104. */
  82105. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82106. /**
  82107. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82108. * This is dynamic to allow compat with webgl 1 and 2.
  82109. * You will need to pass the name of the uniform as well as the value.
  82110. */
  82111. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82112. /**
  82113. * Lambda to Update a single float in a uniform buffer.
  82114. * This is dynamic to allow compat with webgl 1 and 2.
  82115. * You will need to pass the name of the uniform as well as the value.
  82116. */
  82117. updateFloat: (name: string, x: number) => void;
  82118. /**
  82119. * Lambda to Update a vec2 of float in a uniform buffer.
  82120. * This is dynamic to allow compat with webgl 1 and 2.
  82121. * You will need to pass the name of the uniform as well as the value.
  82122. */
  82123. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82124. /**
  82125. * Lambda to Update a vec3 of float in a uniform buffer.
  82126. * This is dynamic to allow compat with webgl 1 and 2.
  82127. * You will need to pass the name of the uniform as well as the value.
  82128. */
  82129. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82130. /**
  82131. * Lambda to Update a vec4 of float in a uniform buffer.
  82132. * This is dynamic to allow compat with webgl 1 and 2.
  82133. * You will need to pass the name of the uniform as well as the value.
  82134. */
  82135. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82136. /**
  82137. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82138. * This is dynamic to allow compat with webgl 1 and 2.
  82139. * You will need to pass the name of the uniform as well as the value.
  82140. */
  82141. updateMatrix: (name: string, mat: Matrix) => void;
  82142. /**
  82143. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82144. * This is dynamic to allow compat with webgl 1 and 2.
  82145. * You will need to pass the name of the uniform as well as the value.
  82146. */
  82147. updateVector3: (name: string, vector: Vector3) => void;
  82148. /**
  82149. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82150. * This is dynamic to allow compat with webgl 1 and 2.
  82151. * You will need to pass the name of the uniform as well as the value.
  82152. */
  82153. updateVector4: (name: string, vector: Vector4) => void;
  82154. /**
  82155. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82156. * This is dynamic to allow compat with webgl 1 and 2.
  82157. * You will need to pass the name of the uniform as well as the value.
  82158. */
  82159. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82160. /**
  82161. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82162. * This is dynamic to allow compat with webgl 1 and 2.
  82163. * You will need to pass the name of the uniform as well as the value.
  82164. */
  82165. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82166. /**
  82167. * Instantiates a new Uniform buffer objects.
  82168. *
  82169. * Handles blocks of uniform on the GPU.
  82170. *
  82171. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82172. *
  82173. * For more information, please refer to :
  82174. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82175. * @param engine Define the engine the buffer is associated with
  82176. * @param data Define the data contained in the buffer
  82177. * @param dynamic Define if the buffer is updatable
  82178. */
  82179. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82180. /**
  82181. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82182. * or just falling back on setUniformXXX calls.
  82183. */
  82184. readonly useUbo: boolean;
  82185. /**
  82186. * Indicates if the WebGL underlying uniform buffer is in sync
  82187. * with the javascript cache data.
  82188. */
  82189. readonly isSync: boolean;
  82190. /**
  82191. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82192. * Also, a dynamic UniformBuffer will disable cache verification and always
  82193. * update the underlying WebGL uniform buffer to the GPU.
  82194. * @returns if Dynamic, otherwise false
  82195. */
  82196. isDynamic(): boolean;
  82197. /**
  82198. * The data cache on JS side.
  82199. * @returns the underlying data as a float array
  82200. */
  82201. getData(): Float32Array;
  82202. /**
  82203. * The underlying WebGL Uniform buffer.
  82204. * @returns the webgl buffer
  82205. */
  82206. getBuffer(): Nullable<WebGLBuffer>;
  82207. /**
  82208. * std140 layout specifies how to align data within an UBO structure.
  82209. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82210. * for specs.
  82211. */
  82212. private _fillAlignment;
  82213. /**
  82214. * Adds an uniform in the buffer.
  82215. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82216. * for the layout to be correct !
  82217. * @param name Name of the uniform, as used in the uniform block in the shader.
  82218. * @param size Data size, or data directly.
  82219. */
  82220. addUniform(name: string, size: number | number[]): void;
  82221. /**
  82222. * Adds a Matrix 4x4 to the uniform buffer.
  82223. * @param name Name of the uniform, as used in the uniform block in the shader.
  82224. * @param mat A 4x4 matrix.
  82225. */
  82226. addMatrix(name: string, mat: Matrix): void;
  82227. /**
  82228. * Adds a vec2 to the uniform buffer.
  82229. * @param name Name of the uniform, as used in the uniform block in the shader.
  82230. * @param x Define the x component value of the vec2
  82231. * @param y Define the y component value of the vec2
  82232. */
  82233. addFloat2(name: string, x: number, y: number): void;
  82234. /**
  82235. * Adds a vec3 to the uniform buffer.
  82236. * @param name Name of the uniform, as used in the uniform block in the shader.
  82237. * @param x Define the x component value of the vec3
  82238. * @param y Define the y component value of the vec3
  82239. * @param z Define the z component value of the vec3
  82240. */
  82241. addFloat3(name: string, x: number, y: number, z: number): void;
  82242. /**
  82243. * Adds a vec3 to the uniform buffer.
  82244. * @param name Name of the uniform, as used in the uniform block in the shader.
  82245. * @param color Define the vec3 from a Color
  82246. */
  82247. addColor3(name: string, color: Color3): void;
  82248. /**
  82249. * Adds a vec4 to the uniform buffer.
  82250. * @param name Name of the uniform, as used in the uniform block in the shader.
  82251. * @param color Define the rgb components from a Color
  82252. * @param alpha Define the a component of the vec4
  82253. */
  82254. addColor4(name: string, color: Color3, alpha: number): void;
  82255. /**
  82256. * Adds a vec3 to the uniform buffer.
  82257. * @param name Name of the uniform, as used in the uniform block in the shader.
  82258. * @param vector Define the vec3 components from a Vector
  82259. */
  82260. addVector3(name: string, vector: Vector3): void;
  82261. /**
  82262. * Adds a Matrix 3x3 to the uniform buffer.
  82263. * @param name Name of the uniform, as used in the uniform block in the shader.
  82264. */
  82265. addMatrix3x3(name: string): void;
  82266. /**
  82267. * Adds a Matrix 2x2 to the uniform buffer.
  82268. * @param name Name of the uniform, as used in the uniform block in the shader.
  82269. */
  82270. addMatrix2x2(name: string): void;
  82271. /**
  82272. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82273. */
  82274. create(): void;
  82275. /** @hidden */
  82276. _rebuild(): void;
  82277. /**
  82278. * Updates the WebGL Uniform Buffer on the GPU.
  82279. * If the `dynamic` flag is set to true, no cache comparison is done.
  82280. * Otherwise, the buffer will be updated only if the cache differs.
  82281. */
  82282. update(): void;
  82283. /**
  82284. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82285. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82286. * @param data Define the flattened data
  82287. * @param size Define the size of the data.
  82288. */
  82289. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82290. private _updateMatrix3x3ForUniform;
  82291. private _updateMatrix3x3ForEffect;
  82292. private _updateMatrix2x2ForEffect;
  82293. private _updateMatrix2x2ForUniform;
  82294. private _updateFloatForEffect;
  82295. private _updateFloatForUniform;
  82296. private _updateFloat2ForEffect;
  82297. private _updateFloat2ForUniform;
  82298. private _updateFloat3ForEffect;
  82299. private _updateFloat3ForUniform;
  82300. private _updateFloat4ForEffect;
  82301. private _updateFloat4ForUniform;
  82302. private _updateMatrixForEffect;
  82303. private _updateMatrixForUniform;
  82304. private _updateVector3ForEffect;
  82305. private _updateVector3ForUniform;
  82306. private _updateVector4ForEffect;
  82307. private _updateVector4ForUniform;
  82308. private _updateColor3ForEffect;
  82309. private _updateColor3ForUniform;
  82310. private _updateColor4ForEffect;
  82311. private _updateColor4ForUniform;
  82312. /**
  82313. * Sets a sampler uniform on the effect.
  82314. * @param name Define the name of the sampler.
  82315. * @param texture Define the texture to set in the sampler
  82316. */
  82317. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82318. /**
  82319. * Directly updates the value of the uniform in the cache AND on the GPU.
  82320. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82321. * @param data Define the flattened data
  82322. */
  82323. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82324. /**
  82325. * Binds this uniform buffer to an effect.
  82326. * @param effect Define the effect to bind the buffer to
  82327. * @param name Name of the uniform block in the shader.
  82328. */
  82329. bindToEffect(effect: Effect, name: string): void;
  82330. /**
  82331. * Disposes the uniform buffer.
  82332. */
  82333. dispose(): void;
  82334. }
  82335. }
  82336. declare module BABYLON {
  82337. /**
  82338. * This represents the required contract to create a new type of texture loader.
  82339. */
  82340. export interface IInternalTextureLoader {
  82341. /**
  82342. * Defines wether the loader supports cascade loading the different faces.
  82343. */
  82344. supportCascades: boolean;
  82345. /**
  82346. * This returns if the loader support the current file information.
  82347. * @param extension defines the file extension of the file being loaded
  82348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82349. * @param fallback defines the fallback internal texture if any
  82350. * @param isBase64 defines whether the texture is encoded as a base64
  82351. * @param isBuffer defines whether the texture data are stored as a buffer
  82352. * @returns true if the loader can load the specified file
  82353. */
  82354. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82355. /**
  82356. * Transform the url before loading if required.
  82357. * @param rootUrl the url of the texture
  82358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82359. * @returns the transformed texture
  82360. */
  82361. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82362. /**
  82363. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82364. * @param rootUrl the url of the texture
  82365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82366. * @returns the fallback texture
  82367. */
  82368. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82369. /**
  82370. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82371. * @param data contains the texture data
  82372. * @param texture defines the BabylonJS internal texture
  82373. * @param createPolynomials will be true if polynomials have been requested
  82374. * @param onLoad defines the callback to trigger once the texture is ready
  82375. * @param onError defines the callback to trigger in case of error
  82376. */
  82377. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82378. /**
  82379. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82380. * @param data contains the texture data
  82381. * @param texture defines the BabylonJS internal texture
  82382. * @param callback defines the method to call once ready to upload
  82383. */
  82384. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82385. }
  82386. }
  82387. declare module BABYLON {
  82388. /**
  82389. * Creation options of the multi render target texture.
  82390. */
  82391. export interface IMultiRenderTargetOptions {
  82392. /**
  82393. * Define if the texture needs to create mip maps after render.
  82394. */
  82395. generateMipMaps?: boolean;
  82396. /**
  82397. * Define the types of all the draw buffers we want to create
  82398. */
  82399. types?: number[];
  82400. /**
  82401. * Define the sampling modes of all the draw buffers we want to create
  82402. */
  82403. samplingModes?: number[];
  82404. /**
  82405. * Define if a depth buffer is required
  82406. */
  82407. generateDepthBuffer?: boolean;
  82408. /**
  82409. * Define if a stencil buffer is required
  82410. */
  82411. generateStencilBuffer?: boolean;
  82412. /**
  82413. * Define if a depth texture is required instead of a depth buffer
  82414. */
  82415. generateDepthTexture?: boolean;
  82416. /**
  82417. * Define the number of desired draw buffers
  82418. */
  82419. textureCount?: number;
  82420. /**
  82421. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82422. */
  82423. doNotChangeAspectRatio?: boolean;
  82424. /**
  82425. * Define the default type of the buffers we are creating
  82426. */
  82427. defaultType?: number;
  82428. }
  82429. /**
  82430. * A multi render target, like a render target provides the ability to render to a texture.
  82431. * Unlike the render target, it can render to several draw buffers in one draw.
  82432. * This is specially interesting in deferred rendering or for any effects requiring more than
  82433. * just one color from a single pass.
  82434. */
  82435. export class MultiRenderTarget extends RenderTargetTexture {
  82436. private _internalTextures;
  82437. private _textures;
  82438. private _multiRenderTargetOptions;
  82439. /**
  82440. * Get if draw buffers are currently supported by the used hardware and browser.
  82441. */
  82442. readonly isSupported: boolean;
  82443. /**
  82444. * Get the list of textures generated by the multi render target.
  82445. */
  82446. readonly textures: Texture[];
  82447. /**
  82448. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82449. */
  82450. readonly depthTexture: Texture;
  82451. /**
  82452. * Set the wrapping mode on U of all the textures we are rendering to.
  82453. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82454. */
  82455. wrapU: number;
  82456. /**
  82457. * Set the wrapping mode on V of all the textures we are rendering to.
  82458. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82459. */
  82460. wrapV: number;
  82461. /**
  82462. * Instantiate a new multi render target texture.
  82463. * A multi render target, like a render target provides the ability to render to a texture.
  82464. * Unlike the render target, it can render to several draw buffers in one draw.
  82465. * This is specially interesting in deferred rendering or for any effects requiring more than
  82466. * just one color from a single pass.
  82467. * @param name Define the name of the texture
  82468. * @param size Define the size of the buffers to render to
  82469. * @param count Define the number of target we are rendering into
  82470. * @param scene Define the scene the texture belongs to
  82471. * @param options Define the options used to create the multi render target
  82472. */
  82473. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82474. /** @hidden */
  82475. _rebuild(): void;
  82476. private _createInternalTextures;
  82477. private _createTextures;
  82478. /**
  82479. * Define the number of samples used if MSAA is enabled.
  82480. */
  82481. samples: number;
  82482. /**
  82483. * Resize all the textures in the multi render target.
  82484. * Be carrefull as it will recreate all the data in the new texture.
  82485. * @param size Define the new size
  82486. */
  82487. resize(size: any): void;
  82488. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82489. /**
  82490. * Dispose the render targets and their associated resources
  82491. */
  82492. dispose(): void;
  82493. /**
  82494. * Release all the underlying texture used as draw buffers.
  82495. */
  82496. releaseInternalTextures(): void;
  82497. }
  82498. }
  82499. declare module BABYLON {
  82500. /**
  82501. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82503. */
  82504. export class Analyser {
  82505. /**
  82506. * Gets or sets the smoothing
  82507. * @ignorenaming
  82508. */
  82509. SMOOTHING: number;
  82510. /**
  82511. * Gets or sets the FFT table size
  82512. * @ignorenaming
  82513. */
  82514. FFT_SIZE: number;
  82515. /**
  82516. * Gets or sets the bar graph amplitude
  82517. * @ignorenaming
  82518. */
  82519. BARGRAPHAMPLITUDE: number;
  82520. /**
  82521. * Gets or sets the position of the debug canvas
  82522. * @ignorenaming
  82523. */
  82524. DEBUGCANVASPOS: {
  82525. x: number;
  82526. y: number;
  82527. };
  82528. /**
  82529. * Gets or sets the debug canvas size
  82530. * @ignorenaming
  82531. */
  82532. DEBUGCANVASSIZE: {
  82533. width: number;
  82534. height: number;
  82535. };
  82536. private _byteFreqs;
  82537. private _byteTime;
  82538. private _floatFreqs;
  82539. private _webAudioAnalyser;
  82540. private _debugCanvas;
  82541. private _debugCanvasContext;
  82542. private _scene;
  82543. private _registerFunc;
  82544. private _audioEngine;
  82545. /**
  82546. * Creates a new analyser
  82547. * @param scene defines hosting scene
  82548. */
  82549. constructor(scene: Scene);
  82550. /**
  82551. * Get the number of data values you will have to play with for the visualization
  82552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82553. * @returns a number
  82554. */
  82555. getFrequencyBinCount(): number;
  82556. /**
  82557. * Gets the current frequency data as a byte array
  82558. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82559. * @returns a Uint8Array
  82560. */
  82561. getByteFrequencyData(): Uint8Array;
  82562. /**
  82563. * Gets the current waveform as a byte array
  82564. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82565. * @returns a Uint8Array
  82566. */
  82567. getByteTimeDomainData(): Uint8Array;
  82568. /**
  82569. * Gets the current frequency data as a float array
  82570. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82571. * @returns a Float32Array
  82572. */
  82573. getFloatFrequencyData(): Float32Array;
  82574. /**
  82575. * Renders the debug canvas
  82576. */
  82577. drawDebugCanvas(): void;
  82578. /**
  82579. * Stops rendering the debug canvas and removes it
  82580. */
  82581. stopDebugCanvas(): void;
  82582. /**
  82583. * Connects two audio nodes
  82584. * @param inputAudioNode defines first node to connect
  82585. * @param outputAudioNode defines second node to connect
  82586. */
  82587. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82588. /**
  82589. * Releases all associated resources
  82590. */
  82591. dispose(): void;
  82592. }
  82593. }
  82594. declare module BABYLON {
  82595. /**
  82596. * This represents an audio engine and it is responsible
  82597. * to play, synchronize and analyse sounds throughout the application.
  82598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82599. */
  82600. export interface IAudioEngine extends IDisposable {
  82601. /**
  82602. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82603. */
  82604. readonly canUseWebAudio: boolean;
  82605. /**
  82606. * Gets the current AudioContext if available.
  82607. */
  82608. readonly audioContext: Nullable<AudioContext>;
  82609. /**
  82610. * The master gain node defines the global audio volume of your audio engine.
  82611. */
  82612. readonly masterGain: GainNode;
  82613. /**
  82614. * Gets whether or not mp3 are supported by your browser.
  82615. */
  82616. readonly isMP3supported: boolean;
  82617. /**
  82618. * Gets whether or not ogg are supported by your browser.
  82619. */
  82620. readonly isOGGsupported: boolean;
  82621. /**
  82622. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82623. * @ignoreNaming
  82624. */
  82625. WarnedWebAudioUnsupported: boolean;
  82626. /**
  82627. * Defines if the audio engine relies on a custom unlocked button.
  82628. * In this case, the embedded button will not be displayed.
  82629. */
  82630. useCustomUnlockedButton: boolean;
  82631. /**
  82632. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82633. */
  82634. readonly unlocked: boolean;
  82635. /**
  82636. * Event raised when audio has been unlocked on the browser.
  82637. */
  82638. onAudioUnlockedObservable: Observable<AudioEngine>;
  82639. /**
  82640. * Event raised when audio has been locked on the browser.
  82641. */
  82642. onAudioLockedObservable: Observable<AudioEngine>;
  82643. /**
  82644. * Flags the audio engine in Locked state.
  82645. * This happens due to new browser policies preventing audio to autoplay.
  82646. */
  82647. lock(): void;
  82648. /**
  82649. * Unlocks the audio engine once a user action has been done on the dom.
  82650. * This is helpful to resume play once browser policies have been satisfied.
  82651. */
  82652. unlock(): void;
  82653. }
  82654. /**
  82655. * This represents the default audio engine used in babylon.
  82656. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82658. */
  82659. export class AudioEngine implements IAudioEngine {
  82660. private _audioContext;
  82661. private _audioContextInitialized;
  82662. private _muteButton;
  82663. private _hostElement;
  82664. /**
  82665. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82666. */
  82667. canUseWebAudio: boolean;
  82668. /**
  82669. * The master gain node defines the global audio volume of your audio engine.
  82670. */
  82671. masterGain: GainNode;
  82672. /**
  82673. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82674. * @ignoreNaming
  82675. */
  82676. WarnedWebAudioUnsupported: boolean;
  82677. /**
  82678. * Gets whether or not mp3 are supported by your browser.
  82679. */
  82680. isMP3supported: boolean;
  82681. /**
  82682. * Gets whether or not ogg are supported by your browser.
  82683. */
  82684. isOGGsupported: boolean;
  82685. /**
  82686. * Gets whether audio has been unlocked on the device.
  82687. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82688. * a user interaction has happened.
  82689. */
  82690. unlocked: boolean;
  82691. /**
  82692. * Defines if the audio engine relies on a custom unlocked button.
  82693. * In this case, the embedded button will not be displayed.
  82694. */
  82695. useCustomUnlockedButton: boolean;
  82696. /**
  82697. * Event raised when audio has been unlocked on the browser.
  82698. */
  82699. onAudioUnlockedObservable: Observable<AudioEngine>;
  82700. /**
  82701. * Event raised when audio has been locked on the browser.
  82702. */
  82703. onAudioLockedObservable: Observable<AudioEngine>;
  82704. /**
  82705. * Gets the current AudioContext if available.
  82706. */
  82707. readonly audioContext: Nullable<AudioContext>;
  82708. private _connectedAnalyser;
  82709. /**
  82710. * Instantiates a new audio engine.
  82711. *
  82712. * There should be only one per page as some browsers restrict the number
  82713. * of audio contexts you can create.
  82714. * @param hostElement defines the host element where to display the mute icon if necessary
  82715. */
  82716. constructor(hostElement?: Nullable<HTMLElement>);
  82717. /**
  82718. * Flags the audio engine in Locked state.
  82719. * This happens due to new browser policies preventing audio to autoplay.
  82720. */
  82721. lock(): void;
  82722. /**
  82723. * Unlocks the audio engine once a user action has been done on the dom.
  82724. * This is helpful to resume play once browser policies have been satisfied.
  82725. */
  82726. unlock(): void;
  82727. private _resumeAudioContext;
  82728. private _initializeAudioContext;
  82729. private _tryToRun;
  82730. private _triggerRunningState;
  82731. private _triggerSuspendedState;
  82732. private _displayMuteButton;
  82733. private _moveButtonToTopLeft;
  82734. private _onResize;
  82735. private _hideMuteButton;
  82736. /**
  82737. * Destroy and release the resources associated with the audio ccontext.
  82738. */
  82739. dispose(): void;
  82740. /**
  82741. * Gets the global volume sets on the master gain.
  82742. * @returns the global volume if set or -1 otherwise
  82743. */
  82744. getGlobalVolume(): number;
  82745. /**
  82746. * Sets the global volume of your experience (sets on the master gain).
  82747. * @param newVolume Defines the new global volume of the application
  82748. */
  82749. setGlobalVolume(newVolume: number): void;
  82750. /**
  82751. * Connect the audio engine to an audio analyser allowing some amazing
  82752. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82754. * @param analyser The analyser to connect to the engine
  82755. */
  82756. connectToAnalyser(analyser: Analyser): void;
  82757. }
  82758. }
  82759. declare module BABYLON {
  82760. /**
  82761. * Interface used to present a loading screen while loading a scene
  82762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82763. */
  82764. export interface ILoadingScreen {
  82765. /**
  82766. * Function called to display the loading screen
  82767. */
  82768. displayLoadingUI: () => void;
  82769. /**
  82770. * Function called to hide the loading screen
  82771. */
  82772. hideLoadingUI: () => void;
  82773. /**
  82774. * Gets or sets the color to use for the background
  82775. */
  82776. loadingUIBackgroundColor: string;
  82777. /**
  82778. * Gets or sets the text to display while loading
  82779. */
  82780. loadingUIText: string;
  82781. }
  82782. /**
  82783. * Class used for the default loading screen
  82784. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82785. */
  82786. export class DefaultLoadingScreen implements ILoadingScreen {
  82787. private _renderingCanvas;
  82788. private _loadingText;
  82789. private _loadingDivBackgroundColor;
  82790. private _loadingDiv;
  82791. private _loadingTextDiv;
  82792. /**
  82793. * Creates a new default loading screen
  82794. * @param _renderingCanvas defines the canvas used to render the scene
  82795. * @param _loadingText defines the default text to display
  82796. * @param _loadingDivBackgroundColor defines the default background color
  82797. */
  82798. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82799. /**
  82800. * Function called to display the loading screen
  82801. */
  82802. displayLoadingUI(): void;
  82803. /**
  82804. * Function called to hide the loading screen
  82805. */
  82806. hideLoadingUI(): void;
  82807. /**
  82808. * Gets or sets the text to display while loading
  82809. */
  82810. loadingUIText: string;
  82811. /**
  82812. * Gets or sets the color to use for the background
  82813. */
  82814. loadingUIBackgroundColor: string;
  82815. private _resizeLoadingUI;
  82816. }
  82817. }
  82818. declare module BABYLON {
  82819. /**
  82820. * Settings for finer control over video usage
  82821. */
  82822. export interface VideoTextureSettings {
  82823. /**
  82824. * Applies `autoplay` to video, if specified
  82825. */
  82826. autoPlay?: boolean;
  82827. /**
  82828. * Applies `loop` to video, if specified
  82829. */
  82830. loop?: boolean;
  82831. /**
  82832. * Automatically updates internal texture from video at every frame in the render loop
  82833. */
  82834. autoUpdateTexture: boolean;
  82835. /**
  82836. * Image src displayed during the video loading or until the user interacts with the video.
  82837. */
  82838. poster?: string;
  82839. }
  82840. /**
  82841. * If you want to display a video in your scene, this is the special texture for that.
  82842. * This special texture works similar to other textures, with the exception of a few parameters.
  82843. * @see https://doc.babylonjs.com/how_to/video_texture
  82844. */
  82845. export class VideoTexture extends Texture {
  82846. /**
  82847. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82848. */
  82849. readonly autoUpdateTexture: boolean;
  82850. /**
  82851. * The video instance used by the texture internally
  82852. */
  82853. readonly video: HTMLVideoElement;
  82854. private _onUserActionRequestedObservable;
  82855. /**
  82856. * Event triggerd when a dom action is required by the user to play the video.
  82857. * This happens due to recent changes in browser policies preventing video to auto start.
  82858. */
  82859. readonly onUserActionRequestedObservable: Observable<Texture>;
  82860. private _generateMipMaps;
  82861. private _engine;
  82862. private _stillImageCaptured;
  82863. private _displayingPosterTexture;
  82864. private _settings;
  82865. private _createInternalTextureOnEvent;
  82866. /**
  82867. * Creates a video texture.
  82868. * If you want to display a video in your scene, this is the special texture for that.
  82869. * This special texture works similar to other textures, with the exception of a few parameters.
  82870. * @see https://doc.babylonjs.com/how_to/video_texture
  82871. * @param name optional name, will detect from video source, if not defined
  82872. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82873. * @param scene is obviously the current scene.
  82874. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82875. * @param invertY is false by default but can be used to invert video on Y axis
  82876. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82877. * @param settings allows finer control over video usage
  82878. */
  82879. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82880. private _getName;
  82881. private _getVideo;
  82882. private _createInternalTexture;
  82883. private reset;
  82884. /**
  82885. * @hidden Internal method to initiate `update`.
  82886. */
  82887. _rebuild(): void;
  82888. /**
  82889. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82890. */
  82891. update(): void;
  82892. /**
  82893. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82894. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82895. */
  82896. updateTexture(isVisible: boolean): void;
  82897. protected _updateInternalTexture: () => void;
  82898. /**
  82899. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82900. * @param url New url.
  82901. */
  82902. updateURL(url: string): void;
  82903. /**
  82904. * Dispose the texture and release its associated resources.
  82905. */
  82906. dispose(): void;
  82907. /**
  82908. * Creates a video texture straight from your WebCam video feed.
  82909. * @param scene Define the scene the texture should be created in
  82910. * @param onReady Define a callback to triggered once the texture will be ready
  82911. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82912. */
  82913. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82914. minWidth: number;
  82915. maxWidth: number;
  82916. minHeight: number;
  82917. maxHeight: number;
  82918. deviceId: string;
  82919. }): void;
  82920. }
  82921. }
  82922. declare module BABYLON {
  82923. /**
  82924. * Interface for attribute information associated with buffer instanciation
  82925. */
  82926. export class InstancingAttributeInfo {
  82927. /**
  82928. * Index/offset of the attribute in the vertex shader
  82929. */
  82930. index: number;
  82931. /**
  82932. * size of the attribute, 1, 2, 3 or 4
  82933. */
  82934. attributeSize: number;
  82935. /**
  82936. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82937. * default is FLOAT
  82938. */
  82939. attribyteType: number;
  82940. /**
  82941. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82942. */
  82943. normalized: boolean;
  82944. /**
  82945. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82946. */
  82947. offset: number;
  82948. /**
  82949. * Name of the GLSL attribute, for debugging purpose only
  82950. */
  82951. attributeName: string;
  82952. }
  82953. /**
  82954. * Define options used to create a depth texture
  82955. */
  82956. export class DepthTextureCreationOptions {
  82957. /** Specifies whether or not a stencil should be allocated in the texture */
  82958. generateStencil?: boolean;
  82959. /** Specifies whether or not bilinear filtering is enable on the texture */
  82960. bilinearFiltering?: boolean;
  82961. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82962. comparisonFunction?: number;
  82963. /** Specifies if the created texture is a cube texture */
  82964. isCube?: boolean;
  82965. }
  82966. /**
  82967. * Class used to describe the capabilities of the engine relatively to the current browser
  82968. */
  82969. export class EngineCapabilities {
  82970. /** Maximum textures units per fragment shader */
  82971. maxTexturesImageUnits: number;
  82972. /** Maximum texture units per vertex shader */
  82973. maxVertexTextureImageUnits: number;
  82974. /** Maximum textures units in the entire pipeline */
  82975. maxCombinedTexturesImageUnits: number;
  82976. /** Maximum texture size */
  82977. maxTextureSize: number;
  82978. /** Maximum cube texture size */
  82979. maxCubemapTextureSize: number;
  82980. /** Maximum render texture size */
  82981. maxRenderTextureSize: number;
  82982. /** Maximum number of vertex attributes */
  82983. maxVertexAttribs: number;
  82984. /** Maximum number of varyings */
  82985. maxVaryingVectors: number;
  82986. /** Maximum number of uniforms per vertex shader */
  82987. maxVertexUniformVectors: number;
  82988. /** Maximum number of uniforms per fragment shader */
  82989. maxFragmentUniformVectors: number;
  82990. /** Defines if standard derivates (dx/dy) are supported */
  82991. standardDerivatives: boolean;
  82992. /** Defines if s3tc texture compression is supported */
  82993. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82994. /** Defines if pvrtc texture compression is supported */
  82995. pvrtc: any;
  82996. /** Defines if etc1 texture compression is supported */
  82997. etc1: any;
  82998. /** Defines if etc2 texture compression is supported */
  82999. etc2: any;
  83000. /** Defines if astc texture compression is supported */
  83001. astc: any;
  83002. /** Defines if float textures are supported */
  83003. textureFloat: boolean;
  83004. /** Defines if vertex array objects are supported */
  83005. vertexArrayObject: boolean;
  83006. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83007. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83008. /** Gets the maximum level of anisotropy supported */
  83009. maxAnisotropy: number;
  83010. /** Defines if instancing is supported */
  83011. instancedArrays: boolean;
  83012. /** Defines if 32 bits indices are supported */
  83013. uintIndices: boolean;
  83014. /** Defines if high precision shaders are supported */
  83015. highPrecisionShaderSupported: boolean;
  83016. /** Defines if depth reading in the fragment shader is supported */
  83017. fragmentDepthSupported: boolean;
  83018. /** Defines if float texture linear filtering is supported*/
  83019. textureFloatLinearFiltering: boolean;
  83020. /** Defines if rendering to float textures is supported */
  83021. textureFloatRender: boolean;
  83022. /** Defines if half float textures are supported*/
  83023. textureHalfFloat: boolean;
  83024. /** Defines if half float texture linear filtering is supported*/
  83025. textureHalfFloatLinearFiltering: boolean;
  83026. /** Defines if rendering to half float textures is supported */
  83027. textureHalfFloatRender: boolean;
  83028. /** Defines if textureLOD shader command is supported */
  83029. textureLOD: boolean;
  83030. /** Defines if draw buffers extension is supported */
  83031. drawBuffersExtension: boolean;
  83032. /** Defines if depth textures are supported */
  83033. depthTextureExtension: boolean;
  83034. /** Defines if float color buffer are supported */
  83035. colorBufferFloat: boolean;
  83036. /** Gets disjoint timer query extension (null if not supported) */
  83037. timerQuery: EXT_disjoint_timer_query;
  83038. /** Defines if timestamp can be used with timer query */
  83039. canUseTimestampForTimerQuery: boolean;
  83040. /** Function used to let the system compiles shaders in background */
  83041. parallelShaderCompile: {
  83042. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83043. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83044. COMPLETION_STATUS_KHR: number;
  83045. };
  83046. }
  83047. /** Interface defining initialization parameters for Engine class */
  83048. export interface EngineOptions extends WebGLContextAttributes {
  83049. /**
  83050. * Defines if the engine should no exceed a specified device ratio
  83051. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83052. */
  83053. limitDeviceRatio?: number;
  83054. /**
  83055. * Defines if webvr should be enabled automatically
  83056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83057. */
  83058. autoEnableWebVR?: boolean;
  83059. /**
  83060. * Defines if webgl2 should be turned off even if supported
  83061. * @see http://doc.babylonjs.com/features/webgl2
  83062. */
  83063. disableWebGL2Support?: boolean;
  83064. /**
  83065. * Defines if webaudio should be initialized as well
  83066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83067. */
  83068. audioEngine?: boolean;
  83069. /**
  83070. * Defines if animations should run using a deterministic lock step
  83071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83072. */
  83073. deterministicLockstep?: boolean;
  83074. /** Defines the maximum steps to use with deterministic lock step mode */
  83075. lockstepMaxSteps?: number;
  83076. /**
  83077. * Defines that engine should ignore context lost events
  83078. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83079. */
  83080. doNotHandleContextLost?: boolean;
  83081. /**
  83082. * Defines that engine should ignore modifying touch action attribute and style
  83083. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83084. */
  83085. doNotHandleTouchAction?: boolean;
  83086. }
  83087. /**
  83088. * Defines the interface used by display changed events
  83089. */
  83090. export interface IDisplayChangedEventArgs {
  83091. /** Gets the vrDisplay object (if any) */
  83092. vrDisplay: Nullable<any>;
  83093. /** Gets a boolean indicating if webVR is supported */
  83094. vrSupported: boolean;
  83095. }
  83096. /**
  83097. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83098. */
  83099. export class Engine {
  83100. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83101. static ExceptionList: ({
  83102. key: string;
  83103. capture: string;
  83104. captureConstraint: number;
  83105. targets: string[];
  83106. } | {
  83107. key: string;
  83108. capture: null;
  83109. captureConstraint: null;
  83110. targets: string[];
  83111. })[];
  83112. /** Gets the list of created engines */
  83113. static readonly Instances: Engine[];
  83114. /**
  83115. * Gets the latest created engine
  83116. */
  83117. static readonly LastCreatedEngine: Nullable<Engine>;
  83118. /**
  83119. * Gets the latest created scene
  83120. */
  83121. static readonly LastCreatedScene: Nullable<Scene>;
  83122. /**
  83123. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83124. * @param flag defines which part of the materials must be marked as dirty
  83125. * @param predicate defines a predicate used to filter which materials should be affected
  83126. */
  83127. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83128. /**
  83129. * Hidden
  83130. */
  83131. static _TextureLoaders: IInternalTextureLoader[];
  83132. /** Defines that alpha blending is disabled */
  83133. static readonly ALPHA_DISABLE: number;
  83134. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83135. static readonly ALPHA_ADD: number;
  83136. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83137. static readonly ALPHA_COMBINE: number;
  83138. /** Defines that alpha blending to DEST - SRC * DEST */
  83139. static readonly ALPHA_SUBTRACT: number;
  83140. /** Defines that alpha blending to SRC * DEST */
  83141. static readonly ALPHA_MULTIPLY: number;
  83142. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83143. static readonly ALPHA_MAXIMIZED: number;
  83144. /** Defines that alpha blending to SRC + DEST */
  83145. static readonly ALPHA_ONEONE: number;
  83146. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83147. static readonly ALPHA_PREMULTIPLIED: number;
  83148. /**
  83149. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83150. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83151. */
  83152. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83153. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83154. static readonly ALPHA_INTERPOLATE: number;
  83155. /**
  83156. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83157. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83158. */
  83159. static readonly ALPHA_SCREENMODE: number;
  83160. /** Defines that the ressource is not delayed*/
  83161. static readonly DELAYLOADSTATE_NONE: number;
  83162. /** Defines that the ressource was successfully delay loaded */
  83163. static readonly DELAYLOADSTATE_LOADED: number;
  83164. /** Defines that the ressource is currently delay loading */
  83165. static readonly DELAYLOADSTATE_LOADING: number;
  83166. /** Defines that the ressource is delayed and has not started loading */
  83167. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83169. static readonly NEVER: number;
  83170. /** 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 */
  83171. static readonly ALWAYS: number;
  83172. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83173. static readonly LESS: number;
  83174. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83175. static readonly EQUAL: number;
  83176. /** 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 */
  83177. static readonly LEQUAL: number;
  83178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83179. static readonly GREATER: number;
  83180. /** 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 */
  83181. static readonly GEQUAL: number;
  83182. /** 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 */
  83183. static readonly NOTEQUAL: number;
  83184. /** Passed to stencilOperation to specify that stencil value must be kept */
  83185. static readonly KEEP: number;
  83186. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83187. static readonly REPLACE: number;
  83188. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83189. static readonly INCR: number;
  83190. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83191. static readonly DECR: number;
  83192. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83193. static readonly INVERT: number;
  83194. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83195. static readonly INCR_WRAP: number;
  83196. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83197. static readonly DECR_WRAP: number;
  83198. /** Texture is not repeating outside of 0..1 UVs */
  83199. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83200. /** Texture is repeating outside of 0..1 UVs */
  83201. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83202. /** Texture is repeating and mirrored */
  83203. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83204. /** ALPHA */
  83205. static readonly TEXTUREFORMAT_ALPHA: number;
  83206. /** LUMINANCE */
  83207. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83208. /** LUMINANCE_ALPHA */
  83209. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83210. /** RGB */
  83211. static readonly TEXTUREFORMAT_RGB: number;
  83212. /** RGBA */
  83213. static readonly TEXTUREFORMAT_RGBA: number;
  83214. /** RED */
  83215. static readonly TEXTUREFORMAT_RED: number;
  83216. /** RED (2nd reference) */
  83217. static readonly TEXTUREFORMAT_R: number;
  83218. /** RG */
  83219. static readonly TEXTUREFORMAT_RG: number;
  83220. /** RED_INTEGER */
  83221. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83222. /** RED_INTEGER (2nd reference) */
  83223. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83224. /** RG_INTEGER */
  83225. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83226. /** RGB_INTEGER */
  83227. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83228. /** RGBA_INTEGER */
  83229. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83230. /** UNSIGNED_BYTE */
  83231. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83232. /** UNSIGNED_BYTE (2nd reference) */
  83233. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83234. /** FLOAT */
  83235. static readonly TEXTURETYPE_FLOAT: number;
  83236. /** HALF_FLOAT */
  83237. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83238. /** BYTE */
  83239. static readonly TEXTURETYPE_BYTE: number;
  83240. /** SHORT */
  83241. static readonly TEXTURETYPE_SHORT: number;
  83242. /** UNSIGNED_SHORT */
  83243. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83244. /** INT */
  83245. static readonly TEXTURETYPE_INT: number;
  83246. /** UNSIGNED_INT */
  83247. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83248. /** UNSIGNED_SHORT_4_4_4_4 */
  83249. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83250. /** UNSIGNED_SHORT_5_5_5_1 */
  83251. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83252. /** UNSIGNED_SHORT_5_6_5 */
  83253. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83254. /** UNSIGNED_INT_2_10_10_10_REV */
  83255. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83256. /** UNSIGNED_INT_24_8 */
  83257. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83258. /** UNSIGNED_INT_10F_11F_11F_REV */
  83259. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83260. /** UNSIGNED_INT_5_9_9_9_REV */
  83261. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83262. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83263. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83264. /** nearest is mag = nearest and min = nearest and mip = linear */
  83265. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83266. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83267. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83268. /** Trilinear is mag = linear and min = linear and mip = linear */
  83269. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83270. /** nearest is mag = nearest and min = nearest and mip = linear */
  83271. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83272. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83273. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83274. /** Trilinear is mag = linear and min = linear and mip = linear */
  83275. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83276. /** mag = nearest and min = nearest and mip = nearest */
  83277. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83278. /** mag = nearest and min = linear and mip = nearest */
  83279. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83280. /** mag = nearest and min = linear and mip = linear */
  83281. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83282. /** mag = nearest and min = linear and mip = none */
  83283. static readonly TEXTURE_NEAREST_LINEAR: number;
  83284. /** mag = nearest and min = nearest and mip = none */
  83285. static readonly TEXTURE_NEAREST_NEAREST: number;
  83286. /** mag = linear and min = nearest and mip = nearest */
  83287. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83288. /** mag = linear and min = nearest and mip = linear */
  83289. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83290. /** mag = linear and min = linear and mip = none */
  83291. static readonly TEXTURE_LINEAR_LINEAR: number;
  83292. /** mag = linear and min = nearest and mip = none */
  83293. static readonly TEXTURE_LINEAR_NEAREST: number;
  83294. /** Explicit coordinates mode */
  83295. static readonly TEXTURE_EXPLICIT_MODE: number;
  83296. /** Spherical coordinates mode */
  83297. static readonly TEXTURE_SPHERICAL_MODE: number;
  83298. /** Planar coordinates mode */
  83299. static readonly TEXTURE_PLANAR_MODE: number;
  83300. /** Cubic coordinates mode */
  83301. static readonly TEXTURE_CUBIC_MODE: number;
  83302. /** Projection coordinates mode */
  83303. static readonly TEXTURE_PROJECTION_MODE: number;
  83304. /** Skybox coordinates mode */
  83305. static readonly TEXTURE_SKYBOX_MODE: number;
  83306. /** Inverse Cubic coordinates mode */
  83307. static readonly TEXTURE_INVCUBIC_MODE: number;
  83308. /** Equirectangular coordinates mode */
  83309. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83310. /** Equirectangular Fixed coordinates mode */
  83311. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83312. /** Equirectangular Fixed Mirrored coordinates mode */
  83313. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83314. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83315. static readonly SCALEMODE_FLOOR: number;
  83316. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83317. static readonly SCALEMODE_NEAREST: number;
  83318. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83319. static readonly SCALEMODE_CEILING: number;
  83320. /**
  83321. * Returns the current version of the framework
  83322. */
  83323. static readonly Version: string;
  83324. /**
  83325. * Returns a string describing the current engine
  83326. */
  83327. readonly description: string;
  83328. /**
  83329. * Gets or sets the epsilon value used by collision engine
  83330. */
  83331. static CollisionsEpsilon: number;
  83332. /**
  83333. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83334. */
  83335. static ShadersRepository: string;
  83336. /**
  83337. * Method called to create the default loading screen.
  83338. * This can be overriden in your own app.
  83339. * @param canvas The rendering canvas element
  83340. * @returns The loading screen
  83341. */
  83342. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83343. /**
  83344. * Method called to create the default rescale post process on each engine.
  83345. */
  83346. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83347. /**
  83348. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83349. */
  83350. forcePOTTextures: boolean;
  83351. /**
  83352. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83353. */
  83354. isFullscreen: boolean;
  83355. /**
  83356. * Gets a boolean indicating if the pointer is currently locked
  83357. */
  83358. isPointerLock: boolean;
  83359. /**
  83360. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83361. */
  83362. cullBackFaces: boolean;
  83363. /**
  83364. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83365. */
  83366. renderEvenInBackground: boolean;
  83367. /**
  83368. * Gets or sets a boolean indicating that cache can be kept between frames
  83369. */
  83370. preventCacheWipeBetweenFrames: boolean;
  83371. /**
  83372. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83373. **/
  83374. enableOfflineSupport: boolean;
  83375. /**
  83376. * 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)
  83377. **/
  83378. disableManifestCheck: boolean;
  83379. /**
  83380. * Gets the list of created scenes
  83381. */
  83382. scenes: Scene[];
  83383. /**
  83384. * Event raised when a new scene is created
  83385. */
  83386. onNewSceneAddedObservable: Observable<Scene>;
  83387. /**
  83388. * Gets the list of created postprocesses
  83389. */
  83390. postProcesses: PostProcess[];
  83391. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83392. validateShaderPrograms: boolean;
  83393. /**
  83394. * Observable event triggered each time the rendering canvas is resized
  83395. */
  83396. onResizeObservable: Observable<Engine>;
  83397. /**
  83398. * Observable event triggered each time the canvas loses focus
  83399. */
  83400. onCanvasBlurObservable: Observable<Engine>;
  83401. /**
  83402. * Observable event triggered each time the canvas gains focus
  83403. */
  83404. onCanvasFocusObservable: Observable<Engine>;
  83405. /**
  83406. * Observable event triggered each time the canvas receives pointerout event
  83407. */
  83408. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83409. /**
  83410. * Observable event triggered before each texture is initialized
  83411. */
  83412. onBeforeTextureInitObservable: Observable<Texture>;
  83413. private _vrDisplay;
  83414. private _vrSupported;
  83415. private _oldSize;
  83416. private _oldHardwareScaleFactor;
  83417. private _vrExclusivePointerMode;
  83418. private _webVRInitPromise;
  83419. /**
  83420. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83421. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83422. */
  83423. readonly isInVRExclusivePointerMode: boolean;
  83424. /**
  83425. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83426. */
  83427. disableUniformBuffers: boolean;
  83428. /** @hidden */
  83429. _uniformBuffers: UniformBuffer[];
  83430. /**
  83431. * Gets a boolean indicating that the engine supports uniform buffers
  83432. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83433. */
  83434. readonly supportsUniformBuffers: boolean;
  83435. /**
  83436. * Observable raised when the engine begins a new frame
  83437. */
  83438. onBeginFrameObservable: Observable<Engine>;
  83439. /**
  83440. * If set, will be used to request the next animation frame for the render loop
  83441. */
  83442. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83443. /**
  83444. * Observable raised when the engine ends the current frame
  83445. */
  83446. onEndFrameObservable: Observable<Engine>;
  83447. /**
  83448. * Observable raised when the engine is about to compile a shader
  83449. */
  83450. onBeforeShaderCompilationObservable: Observable<Engine>;
  83451. /**
  83452. * Observable raised when the engine has jsut compiled a shader
  83453. */
  83454. onAfterShaderCompilationObservable: Observable<Engine>;
  83455. /** @hidden */
  83456. _gl: WebGLRenderingContext;
  83457. private _renderingCanvas;
  83458. private _windowIsBackground;
  83459. private _webGLVersion;
  83460. /**
  83461. * Gets a boolean indicating that only power of 2 textures are supported
  83462. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83463. */
  83464. readonly needPOTTextures: boolean;
  83465. /** @hidden */
  83466. _badOS: boolean;
  83467. /** @hidden */
  83468. _badDesktopOS: boolean;
  83469. /**
  83470. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83471. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83472. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83473. */
  83474. disableTextureBindingOptimization: boolean;
  83475. /**
  83476. * Gets the audio engine
  83477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83478. * @ignorenaming
  83479. */
  83480. static audioEngine: IAudioEngine;
  83481. /**
  83482. * Default AudioEngine factory responsible of creating the Audio Engine.
  83483. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83484. */
  83485. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83486. /**
  83487. * Default offline support factory responsible of creating a tool used to store data locally.
  83488. * By default, this will create a Database object if the workload has been embedded.
  83489. */
  83490. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83491. private _onFocus;
  83492. private _onBlur;
  83493. private _onCanvasPointerOut;
  83494. private _onCanvasBlur;
  83495. private _onCanvasFocus;
  83496. private _onFullscreenChange;
  83497. private _onPointerLockChange;
  83498. private _onVRDisplayPointerRestricted;
  83499. private _onVRDisplayPointerUnrestricted;
  83500. private _onVrDisplayConnect;
  83501. private _onVrDisplayDisconnect;
  83502. private _onVrDisplayPresentChange;
  83503. /**
  83504. * Observable signaled when VR display mode changes
  83505. */
  83506. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83507. /**
  83508. * Observable signaled when VR request present is complete
  83509. */
  83510. onVRRequestPresentComplete: Observable<boolean>;
  83511. /**
  83512. * Observable signaled when VR request present starts
  83513. */
  83514. onVRRequestPresentStart: Observable<Engine>;
  83515. private _hardwareScalingLevel;
  83516. /** @hidden */
  83517. protected _caps: EngineCapabilities;
  83518. private _pointerLockRequested;
  83519. private _isStencilEnable;
  83520. private _colorWrite;
  83521. private _loadingScreen;
  83522. /** @hidden */
  83523. _drawCalls: PerfCounter;
  83524. /** @hidden */
  83525. _textureCollisions: PerfCounter;
  83526. private _glVersion;
  83527. private _glRenderer;
  83528. private _glVendor;
  83529. private _videoTextureSupported;
  83530. private _renderingQueueLaunched;
  83531. private _activeRenderLoops;
  83532. private _deterministicLockstep;
  83533. private _lockstepMaxSteps;
  83534. /**
  83535. * Observable signaled when a context lost event is raised
  83536. */
  83537. onContextLostObservable: Observable<Engine>;
  83538. /**
  83539. * Observable signaled when a context restored event is raised
  83540. */
  83541. onContextRestoredObservable: Observable<Engine>;
  83542. private _onContextLost;
  83543. private _onContextRestored;
  83544. private _contextWasLost;
  83545. private _doNotHandleContextLost;
  83546. /**
  83547. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83549. */
  83550. doNotHandleContextLost: boolean;
  83551. private _performanceMonitor;
  83552. private _fps;
  83553. private _deltaTime;
  83554. /**
  83555. * Turn this value on if you want to pause FPS computation when in background
  83556. */
  83557. disablePerformanceMonitorInBackground: boolean;
  83558. /**
  83559. * Gets the performance monitor attached to this engine
  83560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83561. */
  83562. readonly performanceMonitor: PerformanceMonitor;
  83563. /** @hidden */
  83564. protected _depthCullingState: _DepthCullingState;
  83565. /** @hidden */
  83566. protected _stencilState: _StencilState;
  83567. /** @hidden */
  83568. protected _alphaState: _AlphaState;
  83569. /** @hidden */
  83570. protected _alphaMode: number;
  83571. protected _internalTexturesCache: InternalTexture[];
  83572. /** @hidden */
  83573. protected _activeChannel: number;
  83574. private _currentTextureChannel;
  83575. /** @hidden */
  83576. protected _boundTexturesCache: {
  83577. [key: string]: Nullable<InternalTexture>;
  83578. };
  83579. /** @hidden */
  83580. protected _currentEffect: Nullable<Effect>;
  83581. /** @hidden */
  83582. protected _currentProgram: Nullable<WebGLProgram>;
  83583. private _compiledEffects;
  83584. private _vertexAttribArraysEnabled;
  83585. /** @hidden */
  83586. protected _cachedViewport: Nullable<Viewport>;
  83587. private _cachedVertexArrayObject;
  83588. /** @hidden */
  83589. protected _cachedVertexBuffers: any;
  83590. /** @hidden */
  83591. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83592. /** @hidden */
  83593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83594. /** @hidden */
  83595. protected _currentRenderTarget: Nullable<InternalTexture>;
  83596. private _uintIndicesCurrentlySet;
  83597. private _currentBoundBuffer;
  83598. /** @hidden */
  83599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83600. private _currentBufferPointers;
  83601. private _currentInstanceLocations;
  83602. private _currentInstanceBuffers;
  83603. private _textureUnits;
  83604. private _firstBoundInternalTextureTracker;
  83605. private _lastBoundInternalTextureTracker;
  83606. private _workingCanvas;
  83607. private _workingContext;
  83608. private _rescalePostProcess;
  83609. private _dummyFramebuffer;
  83610. private _externalData;
  83611. private _bindedRenderFunction;
  83612. private _vaoRecordInProgress;
  83613. private _mustWipeVertexAttributes;
  83614. private _emptyTexture;
  83615. private _emptyCubeTexture;
  83616. private _emptyTexture3D;
  83617. /** @hidden */
  83618. _frameHandler: number;
  83619. private _nextFreeTextureSlots;
  83620. private _maxSimultaneousTextures;
  83621. private _activeRequests;
  83622. private _texturesSupported;
  83623. private _textureFormatInUse;
  83624. /**
  83625. * Gets the list of texture formats supported
  83626. */
  83627. readonly texturesSupported: Array<string>;
  83628. /**
  83629. * Gets the list of texture formats in use
  83630. */
  83631. readonly textureFormatInUse: Nullable<string>;
  83632. /**
  83633. * Gets the current viewport
  83634. */
  83635. readonly currentViewport: Nullable<Viewport>;
  83636. /**
  83637. * Gets the default empty texture
  83638. */
  83639. readonly emptyTexture: InternalTexture;
  83640. /**
  83641. * Gets the default empty 3D texture
  83642. */
  83643. readonly emptyTexture3D: InternalTexture;
  83644. /**
  83645. * Gets the default empty cube texture
  83646. */
  83647. readonly emptyCubeTexture: InternalTexture;
  83648. /**
  83649. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83650. */
  83651. readonly premultipliedAlpha: boolean;
  83652. /**
  83653. * Creates a new engine
  83654. * @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
  83655. * @param antialias defines enable antialiasing (default: false)
  83656. * @param options defines further options to be sent to the getContext() function
  83657. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83658. */
  83659. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83660. private _disableTouchAction;
  83661. private _rebuildInternalTextures;
  83662. private _rebuildEffects;
  83663. /**
  83664. * Gets a boolean indicating if all created effects are ready
  83665. * @returns true if all effects are ready
  83666. */
  83667. areAllEffectsReady(): boolean;
  83668. private _rebuildBuffers;
  83669. private _initGLContext;
  83670. /**
  83671. * Gets version of the current webGL context
  83672. */
  83673. readonly webGLVersion: number;
  83674. /**
  83675. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83676. */
  83677. readonly isStencilEnable: boolean;
  83678. private _prepareWorkingCanvas;
  83679. /**
  83680. * Reset the texture cache to empty state
  83681. */
  83682. resetTextureCache(): void;
  83683. /**
  83684. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83686. * @returns true if engine is in deterministic lock step mode
  83687. */
  83688. isDeterministicLockStep(): boolean;
  83689. /**
  83690. * Gets the max steps when engine is running in deterministic lock step
  83691. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83692. * @returns the max steps
  83693. */
  83694. getLockstepMaxSteps(): number;
  83695. /**
  83696. * Gets an object containing information about the current webGL context
  83697. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83698. */
  83699. getGlInfo(): {
  83700. vendor: string;
  83701. renderer: string;
  83702. version: string;
  83703. };
  83704. /**
  83705. * Gets current aspect ratio
  83706. * @param camera defines the camera to use to get the aspect ratio
  83707. * @param useScreen defines if screen size must be used (or the current render target if any)
  83708. * @returns a number defining the aspect ratio
  83709. */
  83710. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83711. /**
  83712. * Gets current screen aspect ratio
  83713. * @returns a number defining the aspect ratio
  83714. */
  83715. getScreenAspectRatio(): number;
  83716. /**
  83717. * Gets the current render width
  83718. * @param useScreen defines if screen size must be used (or the current render target if any)
  83719. * @returns a number defining the current render width
  83720. */
  83721. getRenderWidth(useScreen?: boolean): number;
  83722. /**
  83723. * Gets the current render height
  83724. * @param useScreen defines if screen size must be used (or the current render target if any)
  83725. * @returns a number defining the current render height
  83726. */
  83727. getRenderHeight(useScreen?: boolean): number;
  83728. /**
  83729. * Gets the HTML canvas attached with the current webGL context
  83730. * @returns a HTML canvas
  83731. */
  83732. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83733. /**
  83734. * Gets the client rect of the HTML canvas attached with the current webGL context
  83735. * @returns a client rectanglee
  83736. */
  83737. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83738. /**
  83739. * Defines the hardware scaling level.
  83740. * By default the hardware scaling level is computed from the window device ratio.
  83741. * 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.
  83742. * @param level defines the level to use
  83743. */
  83744. setHardwareScalingLevel(level: number): void;
  83745. /**
  83746. * Gets the current hardware scaling level.
  83747. * By default the hardware scaling level is computed from the window device ratio.
  83748. * 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.
  83749. * @returns a number indicating the current hardware scaling level
  83750. */
  83751. getHardwareScalingLevel(): number;
  83752. /**
  83753. * Gets the list of loaded textures
  83754. * @returns an array containing all loaded textures
  83755. */
  83756. getLoadedTexturesCache(): InternalTexture[];
  83757. /**
  83758. * Gets the object containing all engine capabilities
  83759. * @returns the EngineCapabilities object
  83760. */
  83761. getCaps(): EngineCapabilities;
  83762. /**
  83763. * Gets the current depth function
  83764. * @returns a number defining the depth function
  83765. */
  83766. getDepthFunction(): Nullable<number>;
  83767. /**
  83768. * Sets the current depth function
  83769. * @param depthFunc defines the function to use
  83770. */
  83771. setDepthFunction(depthFunc: number): void;
  83772. /**
  83773. * Sets the current depth function to GREATER
  83774. */
  83775. setDepthFunctionToGreater(): void;
  83776. /**
  83777. * Sets the current depth function to GEQUAL
  83778. */
  83779. setDepthFunctionToGreaterOrEqual(): void;
  83780. /**
  83781. * Sets the current depth function to LESS
  83782. */
  83783. setDepthFunctionToLess(): void;
  83784. /**
  83785. * Sets the current depth function to LEQUAL
  83786. */
  83787. setDepthFunctionToLessOrEqual(): void;
  83788. /**
  83789. * Gets a boolean indicating if stencil buffer is enabled
  83790. * @returns the current stencil buffer state
  83791. */
  83792. getStencilBuffer(): boolean;
  83793. /**
  83794. * Enable or disable the stencil buffer
  83795. * @param enable defines if the stencil buffer must be enabled or disabled
  83796. */
  83797. setStencilBuffer(enable: boolean): void;
  83798. /**
  83799. * Gets the current stencil mask
  83800. * @returns a number defining the new stencil mask to use
  83801. */
  83802. getStencilMask(): number;
  83803. /**
  83804. * Sets the current stencil mask
  83805. * @param mask defines the new stencil mask to use
  83806. */
  83807. setStencilMask(mask: number): void;
  83808. /**
  83809. * Gets the current stencil function
  83810. * @returns a number defining the stencil function to use
  83811. */
  83812. getStencilFunction(): number;
  83813. /**
  83814. * Gets the current stencil reference value
  83815. * @returns a number defining the stencil reference value to use
  83816. */
  83817. getStencilFunctionReference(): number;
  83818. /**
  83819. * Gets the current stencil mask
  83820. * @returns a number defining the stencil mask to use
  83821. */
  83822. getStencilFunctionMask(): number;
  83823. /**
  83824. * Sets the current stencil function
  83825. * @param stencilFunc defines the new stencil function to use
  83826. */
  83827. setStencilFunction(stencilFunc: number): void;
  83828. /**
  83829. * Sets the current stencil reference
  83830. * @param reference defines the new stencil reference to use
  83831. */
  83832. setStencilFunctionReference(reference: number): void;
  83833. /**
  83834. * Sets the current stencil mask
  83835. * @param mask defines the new stencil mask to use
  83836. */
  83837. setStencilFunctionMask(mask: number): void;
  83838. /**
  83839. * Gets the current stencil operation when stencil fails
  83840. * @returns a number defining stencil operation to use when stencil fails
  83841. */
  83842. getStencilOperationFail(): number;
  83843. /**
  83844. * Gets the current stencil operation when depth fails
  83845. * @returns a number defining stencil operation to use when depth fails
  83846. */
  83847. getStencilOperationDepthFail(): number;
  83848. /**
  83849. * Gets the current stencil operation when stencil passes
  83850. * @returns a number defining stencil operation to use when stencil passes
  83851. */
  83852. getStencilOperationPass(): number;
  83853. /**
  83854. * Sets the stencil operation to use when stencil fails
  83855. * @param operation defines the stencil operation to use when stencil fails
  83856. */
  83857. setStencilOperationFail(operation: number): void;
  83858. /**
  83859. * Sets the stencil operation to use when depth fails
  83860. * @param operation defines the stencil operation to use when depth fails
  83861. */
  83862. setStencilOperationDepthFail(operation: number): void;
  83863. /**
  83864. * Sets the stencil operation to use when stencil passes
  83865. * @param operation defines the stencil operation to use when stencil passes
  83866. */
  83867. setStencilOperationPass(operation: number): void;
  83868. /**
  83869. * Sets a boolean indicating if the dithering state is enabled or disabled
  83870. * @param value defines the dithering state
  83871. */
  83872. setDitheringState(value: boolean): void;
  83873. /**
  83874. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83875. * @param value defines the rasterizer state
  83876. */
  83877. setRasterizerState(value: boolean): void;
  83878. /**
  83879. * stop executing a render loop function and remove it from the execution array
  83880. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83881. */
  83882. stopRenderLoop(renderFunction?: () => void): void;
  83883. /** @hidden */
  83884. _renderLoop(): void;
  83885. /**
  83886. * Register and execute a render loop. The engine can have more than one render function
  83887. * @param renderFunction defines the function to continuously execute
  83888. */
  83889. runRenderLoop(renderFunction: () => void): void;
  83890. /**
  83891. * Toggle full screen mode
  83892. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83893. */
  83894. switchFullscreen(requestPointerLock: boolean): void;
  83895. /**
  83896. * Enters full screen mode
  83897. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83898. */
  83899. enterFullscreen(requestPointerLock: boolean): void;
  83900. /**
  83901. * Exits full screen mode
  83902. */
  83903. exitFullscreen(): void;
  83904. /**
  83905. * Clear the current render buffer or the current render target (if any is set up)
  83906. * @param color defines the color to use
  83907. * @param backBuffer defines if the back buffer must be cleared
  83908. * @param depth defines if the depth buffer must be cleared
  83909. * @param stencil defines if the stencil buffer must be cleared
  83910. */
  83911. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83912. /**
  83913. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83914. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83915. * @param y defines the y-coordinate of the corner of the clear rectangle
  83916. * @param width defines the width of the clear rectangle
  83917. * @param height defines the height of the clear rectangle
  83918. * @param clearColor defines the clear color
  83919. */
  83920. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83921. /**
  83922. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83923. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83924. * @param y defines the y-coordinate of the corner of the clear rectangle
  83925. * @param width defines the width of the clear rectangle
  83926. * @param height defines the height of the clear rectangle
  83927. */
  83928. enableScissor(x: number, y: number, width: number, height: number): void;
  83929. /**
  83930. * Disable previously set scissor test rectangle
  83931. */
  83932. disableScissor(): void;
  83933. private _viewportCached;
  83934. /** @hidden */
  83935. _viewport(x: number, y: number, width: number, height: number): void;
  83936. /**
  83937. * Set the WebGL's viewport
  83938. * @param viewport defines the viewport element to be used
  83939. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83940. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83941. */
  83942. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83943. /**
  83944. * Directly set the WebGL Viewport
  83945. * @param x defines the x coordinate of the viewport (in screen space)
  83946. * @param y defines the y coordinate of the viewport (in screen space)
  83947. * @param width defines the width of the viewport (in screen space)
  83948. * @param height defines the height of the viewport (in screen space)
  83949. * @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
  83950. */
  83951. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83952. /**
  83953. * Begin a new frame
  83954. */
  83955. beginFrame(): void;
  83956. /**
  83957. * Enf the current frame
  83958. */
  83959. endFrame(): void;
  83960. /**
  83961. * Resize the view according to the canvas' size
  83962. */
  83963. resize(): void;
  83964. /**
  83965. * Force a specific size of the canvas
  83966. * @param width defines the new canvas' width
  83967. * @param height defines the new canvas' height
  83968. */
  83969. setSize(width: number, height: number): void;
  83970. /**
  83971. * Gets a boolean indicating if a webVR device was detected
  83972. * @returns true if a webVR device was detected
  83973. */
  83974. isVRDevicePresent(): boolean;
  83975. /**
  83976. * Gets the current webVR device
  83977. * @returns the current webVR device (or null)
  83978. */
  83979. getVRDevice(): any;
  83980. /**
  83981. * Initializes a webVR display and starts listening to display change events
  83982. * The onVRDisplayChangedObservable will be notified upon these changes
  83983. * @returns The onVRDisplayChangedObservable
  83984. */
  83985. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83986. /**
  83987. * Initializes a webVR display and starts listening to display change events
  83988. * The onVRDisplayChangedObservable will be notified upon these changes
  83989. * @returns A promise containing a VRDisplay and if vr is supported
  83990. */
  83991. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83992. /**
  83993. * Call this function to switch to webVR mode
  83994. * Will do nothing if webVR is not supported or if there is no webVR device
  83995. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83996. */
  83997. enableVR(): void;
  83998. /**
  83999. * Call this function to leave webVR mode
  84000. * Will do nothing if webVR is not supported or if there is no webVR device
  84001. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84002. */
  84003. disableVR(): void;
  84004. private _onVRFullScreenTriggered;
  84005. private _getVRDisplaysAsync;
  84006. /**
  84007. * Binds the frame buffer to the specified texture.
  84008. * @param texture The texture to render to or null for the default canvas
  84009. * @param faceIndex The face of the texture to render to in case of cube texture
  84010. * @param requiredWidth The width of the target to render to
  84011. * @param requiredHeight The height of the target to render to
  84012. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84013. * @param depthStencilTexture The depth stencil texture to use to render
  84014. * @param lodLevel defines le lod level to bind to the frame buffer
  84015. */
  84016. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84017. private bindUnboundFramebuffer;
  84018. /**
  84019. * Unbind the current render target texture from the webGL context
  84020. * @param texture defines the render target texture to unbind
  84021. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84022. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84023. */
  84024. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84025. /**
  84026. * Unbind a list of render target textures from the webGL context
  84027. * This is used only when drawBuffer extension or webGL2 are active
  84028. * @param textures defines the render target textures to unbind
  84029. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84030. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84031. */
  84032. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84033. /**
  84034. * Force the mipmap generation for the given render target texture
  84035. * @param texture defines the render target texture to use
  84036. */
  84037. generateMipMapsForCubemap(texture: InternalTexture): void;
  84038. /**
  84039. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84040. */
  84041. flushFramebuffer(): void;
  84042. /**
  84043. * Unbind the current render target and bind the default framebuffer
  84044. */
  84045. restoreDefaultFramebuffer(): void;
  84046. /**
  84047. * Create an uniform buffer
  84048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84049. * @param elements defines the content of the uniform buffer
  84050. * @returns the webGL uniform buffer
  84051. */
  84052. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84053. /**
  84054. * Create a dynamic uniform buffer
  84055. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84056. * @param elements defines the content of the uniform buffer
  84057. * @returns the webGL uniform buffer
  84058. */
  84059. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84060. /**
  84061. * Update an existing uniform buffer
  84062. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84063. * @param uniformBuffer defines the target uniform buffer
  84064. * @param elements defines the content to update
  84065. * @param offset defines the offset in the uniform buffer where update should start
  84066. * @param count defines the size of the data to update
  84067. */
  84068. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84069. private _resetVertexBufferBinding;
  84070. /**
  84071. * Creates a vertex buffer
  84072. * @param data the data for the vertex buffer
  84073. * @returns the new WebGL static buffer
  84074. */
  84075. createVertexBuffer(data: DataArray): WebGLBuffer;
  84076. /**
  84077. * Creates a dynamic vertex buffer
  84078. * @param data the data for the dynamic vertex buffer
  84079. * @returns the new WebGL dynamic buffer
  84080. */
  84081. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84082. /**
  84083. * Update a dynamic index buffer
  84084. * @param indexBuffer defines the target index buffer
  84085. * @param indices defines the data to update
  84086. * @param offset defines the offset in the target index buffer where update should start
  84087. */
  84088. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84089. /**
  84090. * Updates a dynamic vertex buffer.
  84091. * @param vertexBuffer the vertex buffer to update
  84092. * @param data the data used to update the vertex buffer
  84093. * @param byteOffset the byte offset of the data
  84094. * @param byteLength the byte length of the data
  84095. */
  84096. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84097. private _resetIndexBufferBinding;
  84098. /**
  84099. * Creates a new index buffer
  84100. * @param indices defines the content of the index buffer
  84101. * @param updatable defines if the index buffer must be updatable
  84102. * @returns a new webGL buffer
  84103. */
  84104. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84105. /**
  84106. * Bind a webGL buffer to the webGL context
  84107. * @param buffer defines the buffer to bind
  84108. */
  84109. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84110. /**
  84111. * Bind an uniform buffer to the current webGL context
  84112. * @param buffer defines the buffer to bind
  84113. */
  84114. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84115. /**
  84116. * Bind a buffer to the current webGL context at a given location
  84117. * @param buffer defines the buffer to bind
  84118. * @param location defines the index where to bind the buffer
  84119. */
  84120. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84121. /**
  84122. * Bind a specific block at a given index in a specific shader program
  84123. * @param shaderProgram defines the shader program
  84124. * @param blockName defines the block name
  84125. * @param index defines the index where to bind the block
  84126. */
  84127. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84128. private bindIndexBuffer;
  84129. private bindBuffer;
  84130. /**
  84131. * update the bound buffer with the given data
  84132. * @param data defines the data to update
  84133. */
  84134. updateArrayBuffer(data: Float32Array): void;
  84135. private _vertexAttribPointer;
  84136. private _bindIndexBufferWithCache;
  84137. private _bindVertexBuffersAttributes;
  84138. /**
  84139. * Records a vertex array object
  84140. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84141. * @param vertexBuffers defines the list of vertex buffers to store
  84142. * @param indexBuffer defines the index buffer to store
  84143. * @param effect defines the effect to store
  84144. * @returns the new vertex array object
  84145. */
  84146. recordVertexArrayObject(vertexBuffers: {
  84147. [key: string]: VertexBuffer;
  84148. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84149. /**
  84150. * Bind a specific vertex array object
  84151. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84152. * @param vertexArrayObject defines the vertex array object to bind
  84153. * @param indexBuffer defines the index buffer to bind
  84154. */
  84155. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84156. /**
  84157. * Bind webGl buffers directly to the webGL context
  84158. * @param vertexBuffer defines the vertex buffer to bind
  84159. * @param indexBuffer defines the index buffer to bind
  84160. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84161. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84162. * @param effect defines the effect associated with the vertex buffer
  84163. */
  84164. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84165. private _unbindVertexArrayObject;
  84166. /**
  84167. * Bind a list of vertex buffers to the webGL context
  84168. * @param vertexBuffers defines the list of vertex buffers to bind
  84169. * @param indexBuffer defines the index buffer to bind
  84170. * @param effect defines the effect associated with the vertex buffers
  84171. */
  84172. bindBuffers(vertexBuffers: {
  84173. [key: string]: Nullable<VertexBuffer>;
  84174. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84175. /**
  84176. * Unbind all instance attributes
  84177. */
  84178. unbindInstanceAttributes(): void;
  84179. /**
  84180. * Release and free the memory of a vertex array object
  84181. * @param vao defines the vertex array object to delete
  84182. */
  84183. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84184. /** @hidden */
  84185. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84186. /**
  84187. * Creates a webGL buffer to use with instanciation
  84188. * @param capacity defines the size of the buffer
  84189. * @returns the webGL buffer
  84190. */
  84191. createInstancesBuffer(capacity: number): WebGLBuffer;
  84192. /**
  84193. * Delete a webGL buffer used with instanciation
  84194. * @param buffer defines the webGL buffer to delete
  84195. */
  84196. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84197. /**
  84198. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84199. * @param instancesBuffer defines the webGL buffer to update and bind
  84200. * @param data defines the data to store in the buffer
  84201. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84202. */
  84203. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84204. /**
  84205. * Apply all cached states (depth, culling, stencil and alpha)
  84206. */
  84207. applyStates(): void;
  84208. /**
  84209. * Send a draw order
  84210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84211. * @param indexStart defines the starting index
  84212. * @param indexCount defines the number of index to draw
  84213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84214. */
  84215. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84216. /**
  84217. * Draw a list of points
  84218. * @param verticesStart defines the index of first vertex to draw
  84219. * @param verticesCount defines the count of vertices to draw
  84220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84221. */
  84222. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84223. /**
  84224. * Draw a list of unindexed primitives
  84225. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84226. * @param verticesStart defines the index of first vertex to draw
  84227. * @param verticesCount defines the count of vertices to draw
  84228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84229. */
  84230. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84231. /**
  84232. * Draw a list of indexed primitives
  84233. * @param fillMode defines the primitive to use
  84234. * @param indexStart defines the starting index
  84235. * @param indexCount defines the number of index to draw
  84236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84237. */
  84238. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84239. /**
  84240. * Draw a list of unindexed primitives
  84241. * @param fillMode defines the primitive to use
  84242. * @param verticesStart defines the index of first vertex to draw
  84243. * @param verticesCount defines the count of vertices to draw
  84244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84245. */
  84246. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84247. private _drawMode;
  84248. /** @hidden */
  84249. _releaseEffect(effect: Effect): void;
  84250. /** @hidden */
  84251. _deleteProgram(program: WebGLProgram): void;
  84252. /**
  84253. * Create a new effect (used to store vertex/fragment shaders)
  84254. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84255. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84256. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84257. * @param samplers defines an array of string used to represent textures
  84258. * @param defines defines the string containing the defines to use to compile the shaders
  84259. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84260. * @param onCompiled defines a function to call when the effect creation is successful
  84261. * @param onError defines a function to call when the effect creation has failed
  84262. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84263. * @returns the new Effect
  84264. */
  84265. 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;
  84266. private _compileShader;
  84267. private _compileRawShader;
  84268. /**
  84269. * Directly creates a webGL program
  84270. * @param vertexCode defines the vertex shader code to use
  84271. * @param fragmentCode defines the fragment shader code to use
  84272. * @param context defines the webGL context to use (if not set, the current one will be used)
  84273. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84274. * @returns the new webGL program
  84275. */
  84276. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84277. /**
  84278. * Creates a webGL program
  84279. * @param vertexCode defines the vertex shader code to use
  84280. * @param fragmentCode defines the fragment shader code to use
  84281. * @param defines defines the string containing the defines to use to compile the shaders
  84282. * @param context defines the webGL context to use (if not set, the current one will be used)
  84283. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84284. * @returns the new webGL program
  84285. */
  84286. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84287. private _createShaderProgram;
  84288. private _finalizeProgram;
  84289. /** @hidden */
  84290. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84291. /** @hidden */
  84292. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84293. /**
  84294. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84295. * @param shaderProgram defines the webGL program to use
  84296. * @param uniformsNames defines the list of uniform names
  84297. * @returns an array of webGL uniform locations
  84298. */
  84299. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84300. /**
  84301. * Gets the lsit of active attributes for a given webGL program
  84302. * @param shaderProgram defines the webGL program to use
  84303. * @param attributesNames defines the list of attribute names to get
  84304. * @returns an array of indices indicating the offset of each attribute
  84305. */
  84306. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84307. /**
  84308. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84309. * @param effect defines the effect to activate
  84310. */
  84311. enableEffect(effect: Nullable<Effect>): void;
  84312. /**
  84313. * Set the value of an uniform to an array of int32
  84314. * @param uniform defines the webGL uniform location where to store the value
  84315. * @param array defines the array of int32 to store
  84316. */
  84317. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84318. /**
  84319. * Set the value of an uniform to an array of int32 (stored as vec2)
  84320. * @param uniform defines the webGL uniform location where to store the value
  84321. * @param array defines the array of int32 to store
  84322. */
  84323. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84324. /**
  84325. * Set the value of an uniform to an array of int32 (stored as vec3)
  84326. * @param uniform defines the webGL uniform location where to store the value
  84327. * @param array defines the array of int32 to store
  84328. */
  84329. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84330. /**
  84331. * Set the value of an uniform to an array of int32 (stored as vec4)
  84332. * @param uniform defines the webGL uniform location where to store the value
  84333. * @param array defines the array of int32 to store
  84334. */
  84335. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84336. /**
  84337. * Set the value of an uniform to an array of float32
  84338. * @param uniform defines the webGL uniform location where to store the value
  84339. * @param array defines the array of float32 to store
  84340. */
  84341. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84342. /**
  84343. * Set the value of an uniform to an array of float32 (stored as vec2)
  84344. * @param uniform defines the webGL uniform location where to store the value
  84345. * @param array defines the array of float32 to store
  84346. */
  84347. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84348. /**
  84349. * Set the value of an uniform to an array of float32 (stored as vec3)
  84350. * @param uniform defines the webGL uniform location where to store the value
  84351. * @param array defines the array of float32 to store
  84352. */
  84353. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84354. /**
  84355. * Set the value of an uniform to an array of float32 (stored as vec4)
  84356. * @param uniform defines the webGL uniform location where to store the value
  84357. * @param array defines the array of float32 to store
  84358. */
  84359. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84360. /**
  84361. * Set the value of an uniform to an array of number
  84362. * @param uniform defines the webGL uniform location where to store the value
  84363. * @param array defines the array of number to store
  84364. */
  84365. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84366. /**
  84367. * Set the value of an uniform to an array of number (stored as vec2)
  84368. * @param uniform defines the webGL uniform location where to store the value
  84369. * @param array defines the array of number to store
  84370. */
  84371. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84372. /**
  84373. * Set the value of an uniform to an array of number (stored as vec3)
  84374. * @param uniform defines the webGL uniform location where to store the value
  84375. * @param array defines the array of number to store
  84376. */
  84377. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84378. /**
  84379. * Set the value of an uniform to an array of number (stored as vec4)
  84380. * @param uniform defines the webGL uniform location where to store the value
  84381. * @param array defines the array of number to store
  84382. */
  84383. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84384. /**
  84385. * Set the value of an uniform to an array of float32 (stored as matrices)
  84386. * @param uniform defines the webGL uniform location where to store the value
  84387. * @param matrices defines the array of float32 to store
  84388. */
  84389. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84390. /**
  84391. * Set the value of an uniform to a matrix
  84392. * @param uniform defines the webGL uniform location where to store the value
  84393. * @param matrix defines the matrix to store
  84394. */
  84395. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84396. /**
  84397. * Set the value of an uniform to a matrix (3x3)
  84398. * @param uniform defines the webGL uniform location where to store the value
  84399. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84400. */
  84401. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84402. /**
  84403. * Set the value of an uniform to a matrix (2x2)
  84404. * @param uniform defines the webGL uniform location where to store the value
  84405. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84406. */
  84407. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84408. /**
  84409. * Set the value of an uniform to a number (int)
  84410. * @param uniform defines the webGL uniform location where to store the value
  84411. * @param value defines the int number to store
  84412. */
  84413. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84414. /**
  84415. * Set the value of an uniform to a number (float)
  84416. * @param uniform defines the webGL uniform location where to store the value
  84417. * @param value defines the float number to store
  84418. */
  84419. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84420. /**
  84421. * Set the value of an uniform to a vec2
  84422. * @param uniform defines the webGL uniform location where to store the value
  84423. * @param x defines the 1st component of the value
  84424. * @param y defines the 2nd component of the value
  84425. */
  84426. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84427. /**
  84428. * Set the value of an uniform to a vec3
  84429. * @param uniform defines the webGL uniform location where to store the value
  84430. * @param x defines the 1st component of the value
  84431. * @param y defines the 2nd component of the value
  84432. * @param z defines the 3rd component of the value
  84433. */
  84434. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84435. /**
  84436. * Set the value of an uniform to a boolean
  84437. * @param uniform defines the webGL uniform location where to store the value
  84438. * @param bool defines the boolean to store
  84439. */
  84440. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84441. /**
  84442. * Set the value of an uniform to a vec4
  84443. * @param uniform defines the webGL uniform location where to store the value
  84444. * @param x defines the 1st component of the value
  84445. * @param y defines the 2nd component of the value
  84446. * @param z defines the 3rd component of the value
  84447. * @param w defines the 4th component of the value
  84448. */
  84449. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84450. /**
  84451. * Set the value of an uniform to a Color3
  84452. * @param uniform defines the webGL uniform location where to store the value
  84453. * @param color3 defines the color to store
  84454. */
  84455. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84456. /**
  84457. * Set the value of an uniform to a Color3 and an alpha value
  84458. * @param uniform defines the webGL uniform location where to store the value
  84459. * @param color3 defines the color to store
  84460. * @param alpha defines the alpha component to store
  84461. */
  84462. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84463. /**
  84464. * Sets a Color4 on a uniform variable
  84465. * @param uniform defines the uniform location
  84466. * @param color4 defines the value to be set
  84467. */
  84468. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84469. /**
  84470. * Set various states to the webGL context
  84471. * @param culling defines backface culling state
  84472. * @param zOffset defines the value to apply to zOffset (0 by default)
  84473. * @param force defines if states must be applied even if cache is up to date
  84474. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84475. */
  84476. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84477. /**
  84478. * Set the z offset to apply to current rendering
  84479. * @param value defines the offset to apply
  84480. */
  84481. setZOffset(value: number): void;
  84482. /**
  84483. * Gets the current value of the zOffset
  84484. * @returns the current zOffset state
  84485. */
  84486. getZOffset(): number;
  84487. /**
  84488. * Enable or disable depth buffering
  84489. * @param enable defines the state to set
  84490. */
  84491. setDepthBuffer(enable: boolean): void;
  84492. /**
  84493. * Gets a boolean indicating if depth writing is enabled
  84494. * @returns the current depth writing state
  84495. */
  84496. getDepthWrite(): boolean;
  84497. /**
  84498. * Enable or disable depth writing
  84499. * @param enable defines the state to set
  84500. */
  84501. setDepthWrite(enable: boolean): void;
  84502. /**
  84503. * Enable or disable color writing
  84504. * @param enable defines the state to set
  84505. */
  84506. setColorWrite(enable: boolean): void;
  84507. /**
  84508. * Gets a boolean indicating if color writing is enabled
  84509. * @returns the current color writing state
  84510. */
  84511. getColorWrite(): boolean;
  84512. /**
  84513. * Sets alpha constants used by some alpha blending modes
  84514. * @param r defines the red component
  84515. * @param g defines the green component
  84516. * @param b defines the blue component
  84517. * @param a defines the alpha component
  84518. */
  84519. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84520. /**
  84521. * Sets the current alpha mode
  84522. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84523. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84525. */
  84526. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84527. /**
  84528. * Gets the current alpha mode
  84529. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84530. * @returns the current alpha mode
  84531. */
  84532. getAlphaMode(): number;
  84533. /**
  84534. * Clears the list of texture accessible through engine.
  84535. * This can help preventing texture load conflict due to name collision.
  84536. */
  84537. clearInternalTexturesCache(): void;
  84538. /**
  84539. * Force the entire cache to be cleared
  84540. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84541. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84542. */
  84543. wipeCaches(bruteForce?: boolean): void;
  84544. /**
  84545. * Set the compressed texture format to use, based on the formats you have, and the formats
  84546. * supported by the hardware / browser.
  84547. *
  84548. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84549. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84550. * to API arguments needed to compressed textures. This puts the burden on the container
  84551. * generator to house the arcane code for determining these for current & future formats.
  84552. *
  84553. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84554. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84555. *
  84556. * Note: The result of this call is not taken into account when a texture is base64.
  84557. *
  84558. * @param formatsAvailable defines the list of those format families you have created
  84559. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84560. *
  84561. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84562. * @returns The extension selected.
  84563. */
  84564. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84565. private _getSamplingParameters;
  84566. private _partialLoadImg;
  84567. private _cascadeLoadImgs;
  84568. /** @hidden */
  84569. _createTexture(): WebGLTexture;
  84570. /**
  84571. * Usually called from Texture.ts.
  84572. * Passed information to create a WebGLTexture
  84573. * @param urlArg defines a value which contains one of the following:
  84574. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84575. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84576. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84577. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84578. * @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)
  84579. * @param scene needed for loading to the correct scene
  84580. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84581. * @param onLoad optional callback to be called upon successful completion
  84582. * @param onError optional callback to be called upon failure
  84583. * @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
  84584. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84585. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84586. * @param forcedExtension defines the extension to use to pick the right loader
  84587. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84589. */
  84590. 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;
  84591. private _rescaleTexture;
  84592. /**
  84593. * Update a raw texture
  84594. * @param texture defines the texture to update
  84595. * @param data defines the data to store in the texture
  84596. * @param format defines the format of the data
  84597. * @param invertY defines if data must be stored with Y axis inverted
  84598. * @param compression defines the compression used (null by default)
  84599. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84600. */
  84601. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84602. /**
  84603. * Creates a raw texture
  84604. * @param data defines the data to store in the texture
  84605. * @param width defines the width of the texture
  84606. * @param height defines the height of the texture
  84607. * @param format defines the format of the data
  84608. * @param generateMipMaps defines if the engine should generate the mip levels
  84609. * @param invertY defines if data must be stored with Y axis inverted
  84610. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84611. * @param compression defines the compression used (null by default)
  84612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84613. * @returns the raw texture inside an InternalTexture
  84614. */
  84615. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84616. private _unpackFlipYCached;
  84617. /**
  84618. * In case you are sharing the context with other applications, it might
  84619. * be interested to not cache the unpack flip y state to ensure a consistent
  84620. * value would be set.
  84621. */
  84622. enableUnpackFlipYCached: boolean;
  84623. /** @hidden */
  84624. _unpackFlipY(value: boolean): void;
  84625. /** @hidden */
  84626. _getUnpackAlignement(): number;
  84627. /**
  84628. * Creates a dynamic texture
  84629. * @param width defines the width of the texture
  84630. * @param height defines the height of the texture
  84631. * @param generateMipMaps defines if the engine should generate the mip levels
  84632. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84633. * @returns the dynamic texture inside an InternalTexture
  84634. */
  84635. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84636. /**
  84637. * Update the sampling mode of a given texture
  84638. * @param samplingMode defines the required sampling mode
  84639. * @param texture defines the texture to update
  84640. */
  84641. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84642. /**
  84643. * Update the content of a dynamic texture
  84644. * @param texture defines the texture to update
  84645. * @param canvas defines the canvas containing the source
  84646. * @param invertY defines if data must be stored with Y axis inverted
  84647. * @param premulAlpha defines if alpha is stored as premultiplied
  84648. * @param format defines the format of the data
  84649. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84650. */
  84651. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84652. /**
  84653. * Update a video texture
  84654. * @param texture defines the texture to update
  84655. * @param video defines the video element to use
  84656. * @param invertY defines if data must be stored with Y axis inverted
  84657. */
  84658. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84659. /**
  84660. * Updates a depth texture Comparison Mode and Function.
  84661. * If the comparison Function is equal to 0, the mode will be set to none.
  84662. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84663. * @param texture The texture to set the comparison function for
  84664. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84665. */
  84666. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84667. private _setupDepthStencilTexture;
  84668. /**
  84669. * Creates a depth stencil texture.
  84670. * This is only available in WebGL 2 or with the depth texture extension available.
  84671. * @param size The size of face edge in the texture.
  84672. * @param options The options defining the texture.
  84673. * @returns The texture
  84674. */
  84675. createDepthStencilTexture(size: number | {
  84676. width: number;
  84677. height: number;
  84678. }, options: DepthTextureCreationOptions): InternalTexture;
  84679. /**
  84680. * Creates a depth stencil texture.
  84681. * This is only available in WebGL 2 or with the depth texture extension available.
  84682. * @param size The size of face edge in the texture.
  84683. * @param options The options defining the texture.
  84684. * @returns The texture
  84685. */
  84686. private _createDepthStencilTexture;
  84687. /**
  84688. * Creates a depth stencil cube texture.
  84689. * This is only available in WebGL 2.
  84690. * @param size The size of face edge in the cube texture.
  84691. * @param options The options defining the cube texture.
  84692. * @returns The cube texture
  84693. */
  84694. private _createDepthStencilCubeTexture;
  84695. /**
  84696. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84697. * @param renderTarget The render target to set the frame buffer for
  84698. */
  84699. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84700. /**
  84701. * Creates a new render target texture
  84702. * @param size defines the size of the texture
  84703. * @param options defines the options used to create the texture
  84704. * @returns a new render target texture stored in an InternalTexture
  84705. */
  84706. createRenderTargetTexture(size: number | {
  84707. width: number;
  84708. height: number;
  84709. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84710. /**
  84711. * Create a multi render target texture
  84712. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84713. * @param size defines the size of the texture
  84714. * @param options defines the creation options
  84715. * @returns the cube texture as an InternalTexture
  84716. */
  84717. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84718. private _setupFramebufferDepthAttachments;
  84719. /**
  84720. * Updates the sample count of a render target texture
  84721. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84722. * @param texture defines the texture to update
  84723. * @param samples defines the sample count to set
  84724. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84725. */
  84726. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84727. /**
  84728. * Update the sample count for a given multiple render target texture
  84729. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84730. * @param textures defines the textures to update
  84731. * @param samples defines the sample count to set
  84732. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84733. */
  84734. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84735. /** @hidden */
  84736. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84737. /** @hidden */
  84738. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84739. /** @hidden */
  84740. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84741. /** @hidden */
  84742. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84743. /**
  84744. * Creates a new render target cube texture
  84745. * @param size defines the size of the texture
  84746. * @param options defines the options used to create the texture
  84747. * @returns a new render target cube texture stored in an InternalTexture
  84748. */
  84749. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84750. /**
  84751. * Creates a cube texture
  84752. * @param rootUrl defines the url where the files to load is located
  84753. * @param scene defines the current scene
  84754. * @param files defines the list of files to load (1 per face)
  84755. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84756. * @param onLoad defines an optional callback raised when the texture is loaded
  84757. * @param onError defines an optional callback raised if there is an issue to load the texture
  84758. * @param format defines the format of the data
  84759. * @param forcedExtension defines the extension to use to pick the right loader
  84760. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84761. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84762. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84763. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84764. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84765. * @returns the cube texture as an InternalTexture
  84766. */
  84767. 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;
  84768. /**
  84769. * @hidden
  84770. */
  84771. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84772. /**
  84773. * Update a raw cube texture
  84774. * @param texture defines the texture to udpdate
  84775. * @param data defines the data to store
  84776. * @param format defines the data format
  84777. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84778. * @param invertY defines if data must be stored with Y axis inverted
  84779. * @param compression defines the compression used (null by default)
  84780. * @param level defines which level of the texture to update
  84781. */
  84782. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84783. /**
  84784. * Creates a new raw cube texture
  84785. * @param data defines the array of data to use to create each face
  84786. * @param size defines the size of the textures
  84787. * @param format defines the format of the data
  84788. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84789. * @param generateMipMaps defines if the engine should generate the mip levels
  84790. * @param invertY defines if data must be stored with Y axis inverted
  84791. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84792. * @param compression defines the compression used (null by default)
  84793. * @returns the cube texture as an InternalTexture
  84794. */
  84795. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84796. /**
  84797. * Creates a new raw cube texture from a specified url
  84798. * @param url defines the url where the data is located
  84799. * @param scene defines the current scene
  84800. * @param size defines the size of the textures
  84801. * @param format defines the format of the data
  84802. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84803. * @param noMipmap defines if the engine should avoid generating the mip levels
  84804. * @param callback defines a callback used to extract texture data from loaded data
  84805. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84806. * @param onLoad defines a callback called when texture is loaded
  84807. * @param onError defines a callback called if there is an error
  84808. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84809. * @param invertY defines if data must be stored with Y axis inverted
  84810. * @returns the cube texture as an InternalTexture
  84811. */
  84812. 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;
  84813. /**
  84814. * Update a raw 3D texture
  84815. * @param texture defines the texture to update
  84816. * @param data defines the data to store
  84817. * @param format defines the data format
  84818. * @param invertY defines if data must be stored with Y axis inverted
  84819. * @param compression defines the used compression (can be null)
  84820. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84821. */
  84822. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84823. /**
  84824. * Creates a new raw 3D texture
  84825. * @param data defines the data used to create the texture
  84826. * @param width defines the width of the texture
  84827. * @param height defines the height of the texture
  84828. * @param depth defines the depth of the texture
  84829. * @param format defines the format of the texture
  84830. * @param generateMipMaps defines if the engine must generate mip levels
  84831. * @param invertY defines if data must be stored with Y axis inverted
  84832. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84833. * @param compression defines the compressed used (can be null)
  84834. * @param textureType defines the compressed used (can be null)
  84835. * @returns a new raw 3D texture (stored in an InternalTexture)
  84836. */
  84837. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84838. private _prepareWebGLTextureContinuation;
  84839. private _prepareWebGLTexture;
  84840. private _convertRGBtoRGBATextureData;
  84841. /** @hidden */
  84842. _releaseFramebufferObjects(texture: InternalTexture): void;
  84843. /** @hidden */
  84844. _releaseTexture(texture: InternalTexture): void;
  84845. private setProgram;
  84846. private _boundUniforms;
  84847. /**
  84848. * Binds an effect to the webGL context
  84849. * @param effect defines the effect to bind
  84850. */
  84851. bindSamplers(effect: Effect): void;
  84852. private _moveBoundTextureOnTop;
  84853. private _getCorrectTextureChannel;
  84854. private _linkTrackers;
  84855. private _removeDesignatedSlot;
  84856. private _activateCurrentTexture;
  84857. /** @hidden */
  84858. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84859. /** @hidden */
  84860. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84861. /**
  84862. * Sets a texture to the webGL context from a postprocess
  84863. * @param channel defines the channel to use
  84864. * @param postProcess defines the source postprocess
  84865. */
  84866. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84867. /**
  84868. * Binds the output of the passed in post process to the texture channel specified
  84869. * @param channel The channel the texture should be bound to
  84870. * @param postProcess The post process which's output should be bound
  84871. */
  84872. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84873. /**
  84874. * Unbind all textures from the webGL context
  84875. */
  84876. unbindAllTextures(): void;
  84877. /**
  84878. * Sets a texture to the according uniform.
  84879. * @param channel The texture channel
  84880. * @param uniform The uniform to set
  84881. * @param texture The texture to apply
  84882. */
  84883. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84884. /**
  84885. * Sets a depth stencil texture from a render target to the according uniform.
  84886. * @param channel The texture channel
  84887. * @param uniform The uniform to set
  84888. * @param texture The render target texture containing the depth stencil texture to apply
  84889. */
  84890. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84891. private _bindSamplerUniformToChannel;
  84892. private _getTextureWrapMode;
  84893. private _setTexture;
  84894. /**
  84895. * Sets an array of texture to the webGL context
  84896. * @param channel defines the channel where the texture array must be set
  84897. * @param uniform defines the associated uniform location
  84898. * @param textures defines the array of textures to bind
  84899. */
  84900. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84901. /** @hidden */
  84902. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84903. private _setTextureParameterFloat;
  84904. private _setTextureParameterInteger;
  84905. /**
  84906. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84907. * @param x defines the x coordinate of the rectangle where pixels must be read
  84908. * @param y defines the y coordinate of the rectangle where pixels must be read
  84909. * @param width defines the width of the rectangle where pixels must be read
  84910. * @param height defines the height of the rectangle where pixels must be read
  84911. * @returns a Uint8Array containing RGBA colors
  84912. */
  84913. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84914. /**
  84915. * Add an externaly attached data from its key.
  84916. * This method call will fail and return false, if such key already exists.
  84917. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84918. * @param key the unique key that identifies the data
  84919. * @param data the data object to associate to the key for this Engine instance
  84920. * @return true if no such key were already present and the data was added successfully, false otherwise
  84921. */
  84922. addExternalData<T>(key: string, data: T): boolean;
  84923. /**
  84924. * Get an externaly attached data from its key
  84925. * @param key the unique key that identifies the data
  84926. * @return the associated data, if present (can be null), or undefined if not present
  84927. */
  84928. getExternalData<T>(key: string): T;
  84929. /**
  84930. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84931. * @param key the unique key that identifies the data
  84932. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84933. * @return the associated data, can be null if the factory returned null.
  84934. */
  84935. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84936. /**
  84937. * Remove an externaly attached data from the Engine instance
  84938. * @param key the unique key that identifies the data
  84939. * @return true if the data was successfully removed, false if it doesn't exist
  84940. */
  84941. removeExternalData(key: string): boolean;
  84942. /**
  84943. * Unbind all vertex attributes from the webGL context
  84944. */
  84945. unbindAllAttributes(): void;
  84946. /**
  84947. * 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
  84948. */
  84949. releaseEffects(): void;
  84950. /**
  84951. * Dispose and release all associated resources
  84952. */
  84953. dispose(): void;
  84954. /**
  84955. * Display the loading screen
  84956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84957. */
  84958. displayLoadingUI(): void;
  84959. /**
  84960. * Hide the loading screen
  84961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84962. */
  84963. hideLoadingUI(): void;
  84964. /**
  84965. * Gets the current loading screen object
  84966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84967. */
  84968. /**
  84969. * Sets the current loading screen object
  84970. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84971. */
  84972. loadingScreen: ILoadingScreen;
  84973. /**
  84974. * Sets the current loading screen text
  84975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84976. */
  84977. loadingUIText: string;
  84978. /**
  84979. * Sets the current loading screen background color
  84980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84981. */
  84982. loadingUIBackgroundColor: string;
  84983. /**
  84984. * Attach a new callback raised when context lost event is fired
  84985. * @param callback defines the callback to call
  84986. */
  84987. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84988. /**
  84989. * Attach a new callback raised when context restored event is fired
  84990. * @param callback defines the callback to call
  84991. */
  84992. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84993. /**
  84994. * Gets the source code of the vertex shader associated with a specific webGL program
  84995. * @param program defines the program to use
  84996. * @returns a string containing the source code of the vertex shader associated with the program
  84997. */
  84998. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84999. /**
  85000. * Gets the source code of the fragment shader associated with a specific webGL program
  85001. * @param program defines the program to use
  85002. * @returns a string containing the source code of the fragment shader associated with the program
  85003. */
  85004. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85005. /**
  85006. * Get the current error code of the webGL context
  85007. * @returns the error code
  85008. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85009. */
  85010. getError(): number;
  85011. /**
  85012. * Gets the current framerate
  85013. * @returns a number representing the framerate
  85014. */
  85015. getFps(): number;
  85016. /**
  85017. * Gets the time spent between current and previous frame
  85018. * @returns a number representing the delta time in ms
  85019. */
  85020. getDeltaTime(): number;
  85021. private _measureFps;
  85022. /** @hidden */
  85023. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85024. private _canRenderToFloatFramebuffer;
  85025. private _canRenderToHalfFloatFramebuffer;
  85026. private _canRenderToFramebuffer;
  85027. /** @hidden */
  85028. _getWebGLTextureType(type: number): number;
  85029. private _getInternalFormat;
  85030. /** @hidden */
  85031. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85032. /** @hidden */
  85033. _getRGBAMultiSampleBufferFormat(type: number): number;
  85034. /** @hidden */
  85035. _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;
  85036. /** @hidden */
  85037. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85038. private _partialLoadFile;
  85039. private _cascadeLoadFiles;
  85040. /**
  85041. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85042. * @returns true if the engine can be created
  85043. * @ignorenaming
  85044. */
  85045. static isSupported(): boolean;
  85046. }
  85047. }
  85048. declare module BABYLON {
  85049. /**
  85050. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85051. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85052. */
  85053. export class EffectFallbacks {
  85054. private _defines;
  85055. private _currentRank;
  85056. private _maxRank;
  85057. private _mesh;
  85058. /**
  85059. * Removes the fallback from the bound mesh.
  85060. */
  85061. unBindMesh(): void;
  85062. /**
  85063. * Adds a fallback on the specified property.
  85064. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85065. * @param define The name of the define in the shader
  85066. */
  85067. addFallback(rank: number, define: string): void;
  85068. /**
  85069. * Sets the mesh to use CPU skinning when needing to fallback.
  85070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85071. * @param mesh The mesh to use the fallbacks.
  85072. */
  85073. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85074. /**
  85075. * Checks to see if more fallbacks are still availible.
  85076. */
  85077. readonly isMoreFallbacks: boolean;
  85078. /**
  85079. * Removes the defines that shoould be removed when falling back.
  85080. * @param currentDefines defines the current define statements for the shader.
  85081. * @param effect defines the current effect we try to compile
  85082. * @returns The resulting defines with defines of the current rank removed.
  85083. */
  85084. reduce(currentDefines: string, effect: Effect): string;
  85085. }
  85086. /**
  85087. * Options to be used when creating an effect.
  85088. */
  85089. export class EffectCreationOptions {
  85090. /**
  85091. * Atrributes that will be used in the shader.
  85092. */
  85093. attributes: string[];
  85094. /**
  85095. * Uniform varible names that will be set in the shader.
  85096. */
  85097. uniformsNames: string[];
  85098. /**
  85099. * Uniform buffer varible names that will be set in the shader.
  85100. */
  85101. uniformBuffersNames: string[];
  85102. /**
  85103. * Sampler texture variable names that will be set in the shader.
  85104. */
  85105. samplers: string[];
  85106. /**
  85107. * Define statements that will be set in the shader.
  85108. */
  85109. defines: any;
  85110. /**
  85111. * Possible fallbacks for this effect to improve performance when needed.
  85112. */
  85113. fallbacks: Nullable<EffectFallbacks>;
  85114. /**
  85115. * Callback that will be called when the shader is compiled.
  85116. */
  85117. onCompiled: Nullable<(effect: Effect) => void>;
  85118. /**
  85119. * Callback that will be called if an error occurs during shader compilation.
  85120. */
  85121. onError: Nullable<(effect: Effect, errors: string) => void>;
  85122. /**
  85123. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85124. */
  85125. indexParameters: any;
  85126. /**
  85127. * Max number of lights that can be used in the shader.
  85128. */
  85129. maxSimultaneousLights: number;
  85130. /**
  85131. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85132. */
  85133. transformFeedbackVaryings: Nullable<string[]>;
  85134. }
  85135. /**
  85136. * Effect containing vertex and fragment shader that can be executed on an object.
  85137. */
  85138. export class Effect {
  85139. /**
  85140. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85141. */
  85142. static ShadersRepository: string;
  85143. /**
  85144. * Name of the effect.
  85145. */
  85146. name: any;
  85147. /**
  85148. * String container all the define statements that should be set on the shader.
  85149. */
  85150. defines: string;
  85151. /**
  85152. * Callback that will be called when the shader is compiled.
  85153. */
  85154. onCompiled: Nullable<(effect: Effect) => void>;
  85155. /**
  85156. * Callback that will be called if an error occurs during shader compilation.
  85157. */
  85158. onError: Nullable<(effect: Effect, errors: string) => void>;
  85159. /**
  85160. * Callback that will be called when effect is bound.
  85161. */
  85162. onBind: Nullable<(effect: Effect) => void>;
  85163. /**
  85164. * Unique ID of the effect.
  85165. */
  85166. uniqueId: number;
  85167. /**
  85168. * Observable that will be called when the shader is compiled.
  85169. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85170. */
  85171. onCompileObservable: Observable<Effect>;
  85172. /**
  85173. * Observable that will be called if an error occurs during shader compilation.
  85174. */
  85175. onErrorObservable: Observable<Effect>;
  85176. /** @hidden */
  85177. _onBindObservable: Nullable<Observable<Effect>>;
  85178. /**
  85179. * Observable that will be called when effect is bound.
  85180. */
  85181. readonly onBindObservable: Observable<Effect>;
  85182. /** @hidden */
  85183. _bonesComputationForcedToCPU: boolean;
  85184. private static _uniqueIdSeed;
  85185. private _engine;
  85186. private _uniformBuffersNames;
  85187. private _uniformsNames;
  85188. private _samplers;
  85189. private _isReady;
  85190. private _compilationError;
  85191. private _attributesNames;
  85192. private _attributes;
  85193. private _uniforms;
  85194. /**
  85195. * Key for the effect.
  85196. * @hidden
  85197. */
  85198. _key: string;
  85199. private _indexParameters;
  85200. private _fallbacks;
  85201. private _vertexSourceCode;
  85202. private _fragmentSourceCode;
  85203. private _vertexSourceCodeOverride;
  85204. private _fragmentSourceCodeOverride;
  85205. private _transformFeedbackVaryings;
  85206. /**
  85207. * Compiled shader to webGL program.
  85208. * @hidden
  85209. */
  85210. _program: WebGLProgram;
  85211. private _valueCache;
  85212. private static _baseCache;
  85213. /**
  85214. * Instantiates an effect.
  85215. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85216. * @param baseName Name of the effect.
  85217. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85218. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85219. * @param samplers List of sampler variables that will be passed to the shader.
  85220. * @param engine Engine to be used to render the effect
  85221. * @param defines Define statements to be added to the shader.
  85222. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85223. * @param onCompiled Callback that will be called when the shader is compiled.
  85224. * @param onError Callback that will be called if an error occurs during shader compilation.
  85225. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85226. */
  85227. 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);
  85228. /**
  85229. * Unique key for this effect
  85230. */
  85231. readonly key: string;
  85232. /**
  85233. * If the effect has been compiled and prepared.
  85234. * @returns if the effect is compiled and prepared.
  85235. */
  85236. isReady(): boolean;
  85237. /**
  85238. * The engine the effect was initialized with.
  85239. * @returns the engine.
  85240. */
  85241. getEngine(): Engine;
  85242. /**
  85243. * The compiled webGL program for the effect
  85244. * @returns the webGL program.
  85245. */
  85246. getProgram(): WebGLProgram;
  85247. /**
  85248. * The set of names of attribute variables for the shader.
  85249. * @returns An array of attribute names.
  85250. */
  85251. getAttributesNames(): string[];
  85252. /**
  85253. * Returns the attribute at the given index.
  85254. * @param index The index of the attribute.
  85255. * @returns The location of the attribute.
  85256. */
  85257. getAttributeLocation(index: number): number;
  85258. /**
  85259. * Returns the attribute based on the name of the variable.
  85260. * @param name of the attribute to look up.
  85261. * @returns the attribute location.
  85262. */
  85263. getAttributeLocationByName(name: string): number;
  85264. /**
  85265. * The number of attributes.
  85266. * @returns the numnber of attributes.
  85267. */
  85268. getAttributesCount(): number;
  85269. /**
  85270. * Gets the index of a uniform variable.
  85271. * @param uniformName of the uniform to look up.
  85272. * @returns the index.
  85273. */
  85274. getUniformIndex(uniformName: string): number;
  85275. /**
  85276. * Returns the attribute based on the name of the variable.
  85277. * @param uniformName of the uniform to look up.
  85278. * @returns the location of the uniform.
  85279. */
  85280. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85281. /**
  85282. * Returns an array of sampler variable names
  85283. * @returns The array of sampler variable neames.
  85284. */
  85285. getSamplers(): string[];
  85286. /**
  85287. * The error from the last compilation.
  85288. * @returns the error string.
  85289. */
  85290. getCompilationError(): string;
  85291. /**
  85292. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85293. * @param func The callback to be used.
  85294. */
  85295. executeWhenCompiled(func: (effect: Effect) => void): void;
  85296. private _checkIsReady;
  85297. /** @hidden */
  85298. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85299. /** @hidden */
  85300. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85301. /** @hidden */
  85302. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85303. private _processShaderConversion;
  85304. private _processIncludes;
  85305. private _processPrecision;
  85306. /**
  85307. * Recompiles the webGL program
  85308. * @param vertexSourceCode The source code for the vertex shader.
  85309. * @param fragmentSourceCode The source code for the fragment shader.
  85310. * @param onCompiled Callback called when completed.
  85311. * @param onError Callback called on error.
  85312. * @hidden
  85313. */
  85314. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85315. /**
  85316. * Gets the uniform locations of the the specified variable names
  85317. * @param names THe names of the variables to lookup.
  85318. * @returns Array of locations in the same order as variable names.
  85319. */
  85320. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85321. /**
  85322. * Prepares the effect
  85323. * @hidden
  85324. */
  85325. _prepareEffect(): void;
  85326. /**
  85327. * Checks if the effect is supported. (Must be called after compilation)
  85328. */
  85329. readonly isSupported: boolean;
  85330. /**
  85331. * Binds a texture to the engine to be used as output of the shader.
  85332. * @param channel Name of the output variable.
  85333. * @param texture Texture to bind.
  85334. * @hidden
  85335. */
  85336. _bindTexture(channel: string, texture: InternalTexture): void;
  85337. /**
  85338. * Sets a texture on the engine to be used in the shader.
  85339. * @param channel Name of the sampler variable.
  85340. * @param texture Texture to set.
  85341. */
  85342. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85343. /**
  85344. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85345. * @param channel Name of the sampler variable.
  85346. * @param texture Texture to set.
  85347. */
  85348. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85349. /**
  85350. * Sets an array of textures on the engine to be used in the shader.
  85351. * @param channel Name of the variable.
  85352. * @param textures Textures to set.
  85353. */
  85354. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85355. /**
  85356. * 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)
  85357. * @param channel Name of the sampler variable.
  85358. * @param postProcess Post process to get the input texture from.
  85359. */
  85360. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85361. /**
  85362. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85363. * 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)
  85364. * @param channel Name of the sampler variable.
  85365. * @param postProcess Post process to get the output texture from.
  85366. */
  85367. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85368. /** @hidden */
  85369. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85370. /** @hidden */
  85371. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85372. /** @hidden */
  85373. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85374. /** @hidden */
  85375. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85376. /**
  85377. * Binds a buffer to a uniform.
  85378. * @param buffer Buffer to bind.
  85379. * @param name Name of the uniform variable to bind to.
  85380. */
  85381. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85382. /**
  85383. * Binds block to a uniform.
  85384. * @param blockName Name of the block to bind.
  85385. * @param index Index to bind.
  85386. */
  85387. bindUniformBlock(blockName: string, index: number): void;
  85388. /**
  85389. * Sets an interger value on a uniform variable.
  85390. * @param uniformName Name of the variable.
  85391. * @param value Value to be set.
  85392. * @returns this effect.
  85393. */
  85394. setInt(uniformName: string, value: number): Effect;
  85395. /**
  85396. * Sets an int array on a uniform variable.
  85397. * @param uniformName Name of the variable.
  85398. * @param array array to be set.
  85399. * @returns this effect.
  85400. */
  85401. setIntArray(uniformName: string, array: Int32Array): Effect;
  85402. /**
  85403. * 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)
  85404. * @param uniformName Name of the variable.
  85405. * @param array array to be set.
  85406. * @returns this effect.
  85407. */
  85408. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85409. /**
  85410. * 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)
  85411. * @param uniformName Name of the variable.
  85412. * @param array array to be set.
  85413. * @returns this effect.
  85414. */
  85415. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85416. /**
  85417. * 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)
  85418. * @param uniformName Name of the variable.
  85419. * @param array array to be set.
  85420. * @returns this effect.
  85421. */
  85422. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85423. /**
  85424. * Sets an float array on a uniform variable.
  85425. * @param uniformName Name of the variable.
  85426. * @param array array to be set.
  85427. * @returns this effect.
  85428. */
  85429. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85430. /**
  85431. * 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)
  85432. * @param uniformName Name of the variable.
  85433. * @param array array to be set.
  85434. * @returns this effect.
  85435. */
  85436. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85437. /**
  85438. * 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)
  85439. * @param uniformName Name of the variable.
  85440. * @param array array to be set.
  85441. * @returns this effect.
  85442. */
  85443. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85444. /**
  85445. * 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)
  85446. * @param uniformName Name of the variable.
  85447. * @param array array to be set.
  85448. * @returns this effect.
  85449. */
  85450. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85451. /**
  85452. * Sets an array on a uniform variable.
  85453. * @param uniformName Name of the variable.
  85454. * @param array array to be set.
  85455. * @returns this effect.
  85456. */
  85457. setArray(uniformName: string, array: number[]): Effect;
  85458. /**
  85459. * 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)
  85460. * @param uniformName Name of the variable.
  85461. * @param array array to be set.
  85462. * @returns this effect.
  85463. */
  85464. setArray2(uniformName: string, array: number[]): Effect;
  85465. /**
  85466. * 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)
  85467. * @param uniformName Name of the variable.
  85468. * @param array array to be set.
  85469. * @returns this effect.
  85470. */
  85471. setArray3(uniformName: string, array: number[]): Effect;
  85472. /**
  85473. * 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)
  85474. * @param uniformName Name of the variable.
  85475. * @param array array to be set.
  85476. * @returns this effect.
  85477. */
  85478. setArray4(uniformName: string, array: number[]): Effect;
  85479. /**
  85480. * Sets matrices on a uniform variable.
  85481. * @param uniformName Name of the variable.
  85482. * @param matrices matrices to be set.
  85483. * @returns this effect.
  85484. */
  85485. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85486. /**
  85487. * Sets matrix on a uniform variable.
  85488. * @param uniformName Name of the variable.
  85489. * @param matrix matrix to be set.
  85490. * @returns this effect.
  85491. */
  85492. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85493. /**
  85494. * 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)
  85495. * @param uniformName Name of the variable.
  85496. * @param matrix matrix to be set.
  85497. * @returns this effect.
  85498. */
  85499. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85500. /**
  85501. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85502. * @param uniformName Name of the variable.
  85503. * @param matrix matrix to be set.
  85504. * @returns this effect.
  85505. */
  85506. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85507. /**
  85508. * Sets a float on a uniform variable.
  85509. * @param uniformName Name of the variable.
  85510. * @param value value to be set.
  85511. * @returns this effect.
  85512. */
  85513. setFloat(uniformName: string, value: number): Effect;
  85514. /**
  85515. * Sets a boolean on a uniform variable.
  85516. * @param uniformName Name of the variable.
  85517. * @param bool value to be set.
  85518. * @returns this effect.
  85519. */
  85520. setBool(uniformName: string, bool: boolean): Effect;
  85521. /**
  85522. * Sets a Vector2 on a uniform variable.
  85523. * @param uniformName Name of the variable.
  85524. * @param vector2 vector2 to be set.
  85525. * @returns this effect.
  85526. */
  85527. setVector2(uniformName: string, vector2: Vector2): Effect;
  85528. /**
  85529. * Sets a float2 on a uniform variable.
  85530. * @param uniformName Name of the variable.
  85531. * @param x First float in float2.
  85532. * @param y Second float in float2.
  85533. * @returns this effect.
  85534. */
  85535. setFloat2(uniformName: string, x: number, y: number): Effect;
  85536. /**
  85537. * Sets a Vector3 on a uniform variable.
  85538. * @param uniformName Name of the variable.
  85539. * @param vector3 Value to be set.
  85540. * @returns this effect.
  85541. */
  85542. setVector3(uniformName: string, vector3: Vector3): Effect;
  85543. /**
  85544. * Sets a float3 on a uniform variable.
  85545. * @param uniformName Name of the variable.
  85546. * @param x First float in float3.
  85547. * @param y Second float in float3.
  85548. * @param z Third float in float3.
  85549. * @returns this effect.
  85550. */
  85551. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85552. /**
  85553. * Sets a Vector4 on a uniform variable.
  85554. * @param uniformName Name of the variable.
  85555. * @param vector4 Value to be set.
  85556. * @returns this effect.
  85557. */
  85558. setVector4(uniformName: string, vector4: Vector4): Effect;
  85559. /**
  85560. * Sets a float4 on a uniform variable.
  85561. * @param uniformName Name of the variable.
  85562. * @param x First float in float4.
  85563. * @param y Second float in float4.
  85564. * @param z Third float in float4.
  85565. * @param w Fourth float in float4.
  85566. * @returns this effect.
  85567. */
  85568. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85569. /**
  85570. * Sets a Color3 on a uniform variable.
  85571. * @param uniformName Name of the variable.
  85572. * @param color3 Value to be set.
  85573. * @returns this effect.
  85574. */
  85575. setColor3(uniformName: string, color3: Color3): Effect;
  85576. /**
  85577. * Sets a Color4 on a uniform variable.
  85578. * @param uniformName Name of the variable.
  85579. * @param color3 Value to be set.
  85580. * @param alpha Alpha value to be set.
  85581. * @returns this effect.
  85582. */
  85583. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85584. /**
  85585. * Sets a Color4 on a uniform variable
  85586. * @param uniformName defines the name of the variable
  85587. * @param color4 defines the value to be set
  85588. * @returns this effect.
  85589. */
  85590. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85591. /**
  85592. * This function will add a new shader to the shader store
  85593. * @param name the name of the shader
  85594. * @param pixelShader optional pixel shader content
  85595. * @param vertexShader optional vertex shader content
  85596. */
  85597. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85598. /**
  85599. * Store of each shader (The can be looked up using effect.key)
  85600. */
  85601. static ShadersStore: {
  85602. [key: string]: string;
  85603. };
  85604. /**
  85605. * Store of each included file for a shader (The can be looked up using effect.key)
  85606. */
  85607. static IncludesShadersStore: {
  85608. [key: string]: string;
  85609. };
  85610. /**
  85611. * Resets the cache of effects.
  85612. */
  85613. static ResetCache(): void;
  85614. }
  85615. }
  85616. declare module BABYLON {
  85617. /**
  85618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85620. * 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;
  85621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85622. */
  85623. export class ColorCurves {
  85624. private _dirty;
  85625. private _tempColor;
  85626. private _globalCurve;
  85627. private _highlightsCurve;
  85628. private _midtonesCurve;
  85629. private _shadowsCurve;
  85630. private _positiveCurve;
  85631. private _negativeCurve;
  85632. private _globalHue;
  85633. private _globalDensity;
  85634. private _globalSaturation;
  85635. private _globalExposure;
  85636. /**
  85637. * Gets the global Hue value.
  85638. * 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).
  85639. */
  85640. /**
  85641. * Sets the global Hue value.
  85642. * 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).
  85643. */
  85644. globalHue: number;
  85645. /**
  85646. * Gets the global Density value.
  85647. * 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.
  85648. * Values less than zero provide a filter of opposite hue.
  85649. */
  85650. /**
  85651. * Sets the global Density value.
  85652. * 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.
  85653. * Values less than zero provide a filter of opposite hue.
  85654. */
  85655. globalDensity: number;
  85656. /**
  85657. * Gets the global Saturation value.
  85658. * 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.
  85659. */
  85660. /**
  85661. * Sets the global Saturation value.
  85662. * 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.
  85663. */
  85664. globalSaturation: number;
  85665. /**
  85666. * Gets the global Exposure value.
  85667. * 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.
  85668. */
  85669. /**
  85670. * Sets the global Exposure value.
  85671. * 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.
  85672. */
  85673. globalExposure: number;
  85674. private _highlightsHue;
  85675. private _highlightsDensity;
  85676. private _highlightsSaturation;
  85677. private _highlightsExposure;
  85678. /**
  85679. * Gets the highlights Hue value.
  85680. * 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).
  85681. */
  85682. /**
  85683. * Sets the highlights Hue value.
  85684. * 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).
  85685. */
  85686. highlightsHue: number;
  85687. /**
  85688. * Gets the highlights Density value.
  85689. * 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.
  85690. * Values less than zero provide a filter of opposite hue.
  85691. */
  85692. /**
  85693. * Sets the highlights Density value.
  85694. * 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.
  85695. * Values less than zero provide a filter of opposite hue.
  85696. */
  85697. highlightsDensity: number;
  85698. /**
  85699. * Gets the highlights Saturation value.
  85700. * 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.
  85701. */
  85702. /**
  85703. * Sets the highlights Saturation value.
  85704. * 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.
  85705. */
  85706. highlightsSaturation: number;
  85707. /**
  85708. * Gets the highlights Exposure value.
  85709. * 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.
  85710. */
  85711. /**
  85712. * Sets the highlights Exposure value.
  85713. * 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.
  85714. */
  85715. highlightsExposure: number;
  85716. private _midtonesHue;
  85717. private _midtonesDensity;
  85718. private _midtonesSaturation;
  85719. private _midtonesExposure;
  85720. /**
  85721. * Gets the midtones Hue value.
  85722. * 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).
  85723. */
  85724. /**
  85725. * Sets the midtones Hue value.
  85726. * 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).
  85727. */
  85728. midtonesHue: number;
  85729. /**
  85730. * Gets the midtones Density value.
  85731. * 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.
  85732. * Values less than zero provide a filter of opposite hue.
  85733. */
  85734. /**
  85735. * Sets the midtones Density value.
  85736. * 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.
  85737. * Values less than zero provide a filter of opposite hue.
  85738. */
  85739. midtonesDensity: number;
  85740. /**
  85741. * Gets the midtones Saturation value.
  85742. * 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.
  85743. */
  85744. /**
  85745. * Sets the midtones Saturation value.
  85746. * 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.
  85747. */
  85748. midtonesSaturation: number;
  85749. /**
  85750. * Gets the midtones Exposure value.
  85751. * 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.
  85752. */
  85753. /**
  85754. * Sets the midtones Exposure value.
  85755. * 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.
  85756. */
  85757. midtonesExposure: number;
  85758. private _shadowsHue;
  85759. private _shadowsDensity;
  85760. private _shadowsSaturation;
  85761. private _shadowsExposure;
  85762. /**
  85763. * Gets the shadows Hue value.
  85764. * 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).
  85765. */
  85766. /**
  85767. * Sets the shadows Hue value.
  85768. * 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).
  85769. */
  85770. shadowsHue: number;
  85771. /**
  85772. * Gets the shadows Density value.
  85773. * 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.
  85774. * Values less than zero provide a filter of opposite hue.
  85775. */
  85776. /**
  85777. * Sets the shadows Density value.
  85778. * 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.
  85779. * Values less than zero provide a filter of opposite hue.
  85780. */
  85781. shadowsDensity: number;
  85782. /**
  85783. * Gets the shadows Saturation value.
  85784. * 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.
  85785. */
  85786. /**
  85787. * Sets the shadows Saturation value.
  85788. * 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.
  85789. */
  85790. shadowsSaturation: number;
  85791. /**
  85792. * Gets the shadows Exposure value.
  85793. * 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.
  85794. */
  85795. /**
  85796. * Sets the shadows Exposure value.
  85797. * 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.
  85798. */
  85799. shadowsExposure: number;
  85800. /**
  85801. * Returns the class name
  85802. * @returns The class name
  85803. */
  85804. getClassName(): string;
  85805. /**
  85806. * Binds the color curves to the shader.
  85807. * @param colorCurves The color curve to bind
  85808. * @param effect The effect to bind to
  85809. * @param positiveUniform The positive uniform shader parameter
  85810. * @param neutralUniform The neutral uniform shader parameter
  85811. * @param negativeUniform The negative uniform shader parameter
  85812. */
  85813. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85814. /**
  85815. * Prepare the list of uniforms associated with the ColorCurves effects.
  85816. * @param uniformsList The list of uniforms used in the effect
  85817. */
  85818. static PrepareUniforms(uniformsList: string[]): void;
  85819. /**
  85820. * Returns color grading data based on a hue, density, saturation and exposure value.
  85821. * @param filterHue The hue of the color filter.
  85822. * @param filterDensity The density of the color filter.
  85823. * @param saturation The saturation.
  85824. * @param exposure The exposure.
  85825. * @param result The result data container.
  85826. */
  85827. private getColorGradingDataToRef;
  85828. /**
  85829. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85830. * @param value The input slider value in range [-100,100].
  85831. * @returns Adjusted value.
  85832. */
  85833. private static applyColorGradingSliderNonlinear;
  85834. /**
  85835. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85836. * @param hue The hue (H) input.
  85837. * @param saturation The saturation (S) input.
  85838. * @param brightness The brightness (B) input.
  85839. * @result An RGBA color represented as Vector4.
  85840. */
  85841. private static fromHSBToRef;
  85842. /**
  85843. * Returns a value clamped between min and max
  85844. * @param value The value to clamp
  85845. * @param min The minimum of value
  85846. * @param max The maximum of value
  85847. * @returns The clamped value.
  85848. */
  85849. private static clamp;
  85850. /**
  85851. * Clones the current color curve instance.
  85852. * @return The cloned curves
  85853. */
  85854. clone(): ColorCurves;
  85855. /**
  85856. * Serializes the current color curve instance to a json representation.
  85857. * @return a JSON representation
  85858. */
  85859. serialize(): any;
  85860. /**
  85861. * Parses the color curve from a json representation.
  85862. * @param source the JSON source to parse
  85863. * @return The parsed curves
  85864. */
  85865. static Parse(source: any): ColorCurves;
  85866. }
  85867. }
  85868. declare module BABYLON {
  85869. /**
  85870. * Interface to follow in your material defines to integrate easily the
  85871. * Image proccessing functions.
  85872. * @hidden
  85873. */
  85874. export interface IImageProcessingConfigurationDefines {
  85875. IMAGEPROCESSING: boolean;
  85876. VIGNETTE: boolean;
  85877. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85878. VIGNETTEBLENDMODEOPAQUE: boolean;
  85879. TONEMAPPING: boolean;
  85880. TONEMAPPING_ACES: boolean;
  85881. CONTRAST: boolean;
  85882. EXPOSURE: boolean;
  85883. COLORCURVES: boolean;
  85884. COLORGRADING: boolean;
  85885. COLORGRADING3D: boolean;
  85886. SAMPLER3DGREENDEPTH: boolean;
  85887. SAMPLER3DBGRMAP: boolean;
  85888. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85889. }
  85890. /**
  85891. * @hidden
  85892. */
  85893. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85894. IMAGEPROCESSING: boolean;
  85895. VIGNETTE: boolean;
  85896. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85897. VIGNETTEBLENDMODEOPAQUE: boolean;
  85898. TONEMAPPING: boolean;
  85899. TONEMAPPING_ACES: boolean;
  85900. CONTRAST: boolean;
  85901. COLORCURVES: boolean;
  85902. COLORGRADING: boolean;
  85903. COLORGRADING3D: boolean;
  85904. SAMPLER3DGREENDEPTH: boolean;
  85905. SAMPLER3DBGRMAP: boolean;
  85906. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85907. EXPOSURE: boolean;
  85908. constructor();
  85909. }
  85910. /**
  85911. * This groups together the common properties used for image processing either in direct forward pass
  85912. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85913. * or not.
  85914. */
  85915. export class ImageProcessingConfiguration {
  85916. /**
  85917. * Default tone mapping applied in BabylonJS.
  85918. */
  85919. static readonly TONEMAPPING_STANDARD: number;
  85920. /**
  85921. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85922. * to other engines rendering to increase portability.
  85923. */
  85924. static readonly TONEMAPPING_ACES: number;
  85925. /**
  85926. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85927. */
  85928. colorCurves: Nullable<ColorCurves>;
  85929. private _colorCurvesEnabled;
  85930. /**
  85931. * Gets wether the color curves effect is enabled.
  85932. */
  85933. /**
  85934. * Sets wether the color curves effect is enabled.
  85935. */
  85936. colorCurvesEnabled: boolean;
  85937. private _colorGradingTexture;
  85938. /**
  85939. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85940. */
  85941. /**
  85942. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85943. */
  85944. colorGradingTexture: Nullable<BaseTexture>;
  85945. private _colorGradingEnabled;
  85946. /**
  85947. * Gets wether the color grading effect is enabled.
  85948. */
  85949. /**
  85950. * Sets wether the color grading effect is enabled.
  85951. */
  85952. colorGradingEnabled: boolean;
  85953. private _colorGradingWithGreenDepth;
  85954. /**
  85955. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85956. */
  85957. /**
  85958. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85959. */
  85960. colorGradingWithGreenDepth: boolean;
  85961. private _colorGradingBGR;
  85962. /**
  85963. * Gets wether the color grading texture contains BGR values.
  85964. */
  85965. /**
  85966. * Sets wether the color grading texture contains BGR values.
  85967. */
  85968. colorGradingBGR: boolean;
  85969. /** @hidden */
  85970. _exposure: number;
  85971. /**
  85972. * Gets the Exposure used in the effect.
  85973. */
  85974. /**
  85975. * Sets the Exposure used in the effect.
  85976. */
  85977. exposure: number;
  85978. private _toneMappingEnabled;
  85979. /**
  85980. * Gets wether the tone mapping effect is enabled.
  85981. */
  85982. /**
  85983. * Sets wether the tone mapping effect is enabled.
  85984. */
  85985. toneMappingEnabled: boolean;
  85986. private _toneMappingType;
  85987. /**
  85988. * Gets the type of tone mapping effect.
  85989. */
  85990. /**
  85991. * Sets the type of tone mapping effect used in BabylonJS.
  85992. */
  85993. toneMappingType: number;
  85994. protected _contrast: number;
  85995. /**
  85996. * Gets the contrast used in the effect.
  85997. */
  85998. /**
  85999. * Sets the contrast used in the effect.
  86000. */
  86001. contrast: number;
  86002. /**
  86003. * Vignette stretch size.
  86004. */
  86005. vignetteStretch: number;
  86006. /**
  86007. * Vignette centre X Offset.
  86008. */
  86009. vignetteCentreX: number;
  86010. /**
  86011. * Vignette centre Y Offset.
  86012. */
  86013. vignetteCentreY: number;
  86014. /**
  86015. * Vignette weight or intensity of the vignette effect.
  86016. */
  86017. vignetteWeight: number;
  86018. /**
  86019. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86020. * if vignetteEnabled is set to true.
  86021. */
  86022. vignetteColor: Color4;
  86023. /**
  86024. * Camera field of view used by the Vignette effect.
  86025. */
  86026. vignetteCameraFov: number;
  86027. private _vignetteBlendMode;
  86028. /**
  86029. * Gets the vignette blend mode allowing different kind of effect.
  86030. */
  86031. /**
  86032. * Sets the vignette blend mode allowing different kind of effect.
  86033. */
  86034. vignetteBlendMode: number;
  86035. private _vignetteEnabled;
  86036. /**
  86037. * Gets wether the vignette effect is enabled.
  86038. */
  86039. /**
  86040. * Sets wether the vignette effect is enabled.
  86041. */
  86042. vignetteEnabled: boolean;
  86043. private _applyByPostProcess;
  86044. /**
  86045. * Gets wether the image processing is applied through a post process or not.
  86046. */
  86047. /**
  86048. * Sets wether the image processing is applied through a post process or not.
  86049. */
  86050. applyByPostProcess: boolean;
  86051. private _isEnabled;
  86052. /**
  86053. * Gets wether the image processing is enabled or not.
  86054. */
  86055. /**
  86056. * Sets wether the image processing is enabled or not.
  86057. */
  86058. isEnabled: boolean;
  86059. /**
  86060. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86061. */
  86062. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86063. /**
  86064. * Method called each time the image processing information changes requires to recompile the effect.
  86065. */
  86066. protected _updateParameters(): void;
  86067. /**
  86068. * Gets the current class name.
  86069. * @return "ImageProcessingConfiguration"
  86070. */
  86071. getClassName(): string;
  86072. /**
  86073. * Prepare the list of uniforms associated with the Image Processing effects.
  86074. * @param uniforms The list of uniforms used in the effect
  86075. * @param defines the list of defines currently in use
  86076. */
  86077. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86078. /**
  86079. * Prepare the list of samplers associated with the Image Processing effects.
  86080. * @param samplersList The list of uniforms used in the effect
  86081. * @param defines the list of defines currently in use
  86082. */
  86083. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86084. /**
  86085. * Prepare the list of defines associated to the shader.
  86086. * @param defines the list of defines to complete
  86087. * @param forPostProcess Define if we are currently in post process mode or not
  86088. */
  86089. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86090. /**
  86091. * Returns true if all the image processing information are ready.
  86092. * @returns True if ready, otherwise, false
  86093. */
  86094. isReady(): boolean;
  86095. /**
  86096. * Binds the image processing to the shader.
  86097. * @param effect The effect to bind to
  86098. * @param aspectRatio Define the current aspect ratio of the effect
  86099. */
  86100. bind(effect: Effect, aspectRatio?: number): void;
  86101. /**
  86102. * Clones the current image processing instance.
  86103. * @return The cloned image processing
  86104. */
  86105. clone(): ImageProcessingConfiguration;
  86106. /**
  86107. * Serializes the current image processing instance to a json representation.
  86108. * @return a JSON representation
  86109. */
  86110. serialize(): any;
  86111. /**
  86112. * Parses the image processing from a json representation.
  86113. * @param source the JSON source to parse
  86114. * @return The parsed image processing
  86115. */
  86116. static Parse(source: any): ImageProcessingConfiguration;
  86117. private static _VIGNETTEMODE_MULTIPLY;
  86118. private static _VIGNETTEMODE_OPAQUE;
  86119. /**
  86120. * Used to apply the vignette as a mix with the pixel color.
  86121. */
  86122. static readonly VIGNETTEMODE_MULTIPLY: number;
  86123. /**
  86124. * Used to apply the vignette as a replacement of the pixel color.
  86125. */
  86126. static readonly VIGNETTEMODE_OPAQUE: number;
  86127. }
  86128. }
  86129. declare module BABYLON {
  86130. /**
  86131. * This represents all the required information to add a fresnel effect on a material:
  86132. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86133. */
  86134. export class FresnelParameters {
  86135. private _isEnabled;
  86136. /**
  86137. * Define if the fresnel effect is enable or not.
  86138. */
  86139. isEnabled: boolean;
  86140. /**
  86141. * Define the color used on edges (grazing angle)
  86142. */
  86143. leftColor: Color3;
  86144. /**
  86145. * Define the color used on center
  86146. */
  86147. rightColor: Color3;
  86148. /**
  86149. * Define bias applied to computed fresnel term
  86150. */
  86151. bias: number;
  86152. /**
  86153. * Defined the power exponent applied to fresnel term
  86154. */
  86155. power: number;
  86156. /**
  86157. * Clones the current fresnel and its valuues
  86158. * @returns a clone fresnel configuration
  86159. */
  86160. clone(): FresnelParameters;
  86161. /**
  86162. * Serializes the current fresnel parameters to a JSON representation.
  86163. * @return the JSON serialization
  86164. */
  86165. serialize(): any;
  86166. /**
  86167. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86168. * @param parsedFresnelParameters Define the JSON representation
  86169. * @returns the parsed parameters
  86170. */
  86171. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86172. }
  86173. }
  86174. declare module BABYLON {
  86175. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86176. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86177. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86178. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86179. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86180. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86181. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86182. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86183. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86184. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86185. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86186. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86187. /**
  86188. * Decorator used to define property that can be serialized as reference to a camera
  86189. * @param sourceName defines the name of the property to decorate
  86190. */
  86191. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86192. /**
  86193. * Class used to help serialization objects
  86194. */
  86195. export class SerializationHelper {
  86196. /** hidden */
  86197. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86198. /** hidden */
  86199. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86200. /** hidden */
  86201. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86202. /** hidden */
  86203. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86204. /**
  86205. * Appends the serialized animations from the source animations
  86206. * @param source Source containing the animations
  86207. * @param destination Target to store the animations
  86208. */
  86209. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86210. /**
  86211. * Static function used to serialized a specific entity
  86212. * @param entity defines the entity to serialize
  86213. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86214. * @returns a JSON compatible object representing the serialization of the entity
  86215. */
  86216. static Serialize<T>(entity: T, serializationObject?: any): any;
  86217. /**
  86218. * Creates a new entity from a serialization data object
  86219. * @param creationFunction defines a function used to instanciated the new entity
  86220. * @param source defines the source serialization data
  86221. * @param scene defines the hosting scene
  86222. * @param rootUrl defines the root url for resources
  86223. * @returns a new entity
  86224. */
  86225. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86226. /**
  86227. * Clones an object
  86228. * @param creationFunction defines the function used to instanciate the new object
  86229. * @param source defines the source object
  86230. * @returns the cloned object
  86231. */
  86232. static Clone<T>(creationFunction: () => T, source: T): T;
  86233. /**
  86234. * Instanciates a new object based on a source one (some data will be shared between both object)
  86235. * @param creationFunction defines the function used to instanciate the new object
  86236. * @param source defines the source object
  86237. * @returns the new object
  86238. */
  86239. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86240. }
  86241. }
  86242. declare module BABYLON {
  86243. /**
  86244. * This is the base class of all the camera used in the application.
  86245. * @see http://doc.babylonjs.com/features/cameras
  86246. */
  86247. export class Camera extends Node {
  86248. /** @hidden */
  86249. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86250. /**
  86251. * This is the default projection mode used by the cameras.
  86252. * It helps recreating a feeling of perspective and better appreciate depth.
  86253. * This is the best way to simulate real life cameras.
  86254. */
  86255. static readonly PERSPECTIVE_CAMERA: number;
  86256. /**
  86257. * This helps creating camera with an orthographic mode.
  86258. * 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.
  86259. */
  86260. static readonly ORTHOGRAPHIC_CAMERA: number;
  86261. /**
  86262. * This is the default FOV mode for perspective cameras.
  86263. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86264. */
  86265. static readonly FOVMODE_VERTICAL_FIXED: number;
  86266. /**
  86267. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86268. */
  86269. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86270. /**
  86271. * This specifies ther is no need for a camera rig.
  86272. * Basically only one eye is rendered corresponding to the camera.
  86273. */
  86274. static readonly RIG_MODE_NONE: number;
  86275. /**
  86276. * Simulates a camera Rig with one blue eye and one red eye.
  86277. * This can be use with 3d blue and red glasses.
  86278. */
  86279. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86280. /**
  86281. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86282. */
  86283. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86284. /**
  86285. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86286. */
  86287. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86288. /**
  86289. * Defines that both eyes of the camera will be rendered over under each other.
  86290. */
  86291. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86292. /**
  86293. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86294. */
  86295. static readonly RIG_MODE_VR: number;
  86296. /**
  86297. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86298. */
  86299. static readonly RIG_MODE_WEBVR: number;
  86300. /**
  86301. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86302. */
  86303. static readonly RIG_MODE_CUSTOM: number;
  86304. /**
  86305. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86306. */
  86307. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86308. /**
  86309. * @hidden
  86310. * Might be removed once multiview will be a thing
  86311. */
  86312. static UseAlternateWebVRRendering: boolean;
  86313. /**
  86314. * Define the input manager associated with the camera.
  86315. */
  86316. inputs: CameraInputsManager<Camera>;
  86317. /** @hidden */
  86318. _position: Vector3;
  86319. /**
  86320. * Define the current local position of the camera in the scene
  86321. */
  86322. position: Vector3;
  86323. /**
  86324. * The vector the camera should consider as up.
  86325. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86326. */
  86327. upVector: Vector3;
  86328. /**
  86329. * Define the current limit on the left side for an orthographic camera
  86330. * In scene unit
  86331. */
  86332. orthoLeft: Nullable<number>;
  86333. /**
  86334. * Define the current limit on the right side for an orthographic camera
  86335. * In scene unit
  86336. */
  86337. orthoRight: Nullable<number>;
  86338. /**
  86339. * Define the current limit on the bottom side for an orthographic camera
  86340. * In scene unit
  86341. */
  86342. orthoBottom: Nullable<number>;
  86343. /**
  86344. * Define the current limit on the top side for an orthographic camera
  86345. * In scene unit
  86346. */
  86347. orthoTop: Nullable<number>;
  86348. /**
  86349. * Field Of View is set in Radians. (default is 0.8)
  86350. */
  86351. fov: number;
  86352. /**
  86353. * Define the minimum distance the camera can see from.
  86354. * This is important to note that the depth buffer are not infinite and the closer it starts
  86355. * the more your scene might encounter depth fighting issue.
  86356. */
  86357. minZ: number;
  86358. /**
  86359. * Define the maximum distance the camera can see to.
  86360. * This is important to note that the depth buffer are not infinite and the further it end
  86361. * the more your scene might encounter depth fighting issue.
  86362. */
  86363. maxZ: number;
  86364. /**
  86365. * Define the default inertia of the camera.
  86366. * This helps giving a smooth feeling to the camera movement.
  86367. */
  86368. inertia: number;
  86369. /**
  86370. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86371. */
  86372. mode: number;
  86373. /**
  86374. * Define wether the camera is intermediate.
  86375. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86376. */
  86377. isIntermediate: boolean;
  86378. /**
  86379. * Define the viewport of the camera.
  86380. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86381. */
  86382. viewport: Viewport;
  86383. /**
  86384. * Restricts the camera to viewing objects with the same layerMask.
  86385. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86386. */
  86387. layerMask: number;
  86388. /**
  86389. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86390. */
  86391. fovMode: number;
  86392. /**
  86393. * Rig mode of the camera.
  86394. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86395. * This is normally controlled byt the camera themselves as internal use.
  86396. */
  86397. cameraRigMode: number;
  86398. /**
  86399. * Defines the distance between both "eyes" in case of a RIG
  86400. */
  86401. interaxialDistance: number;
  86402. /**
  86403. * Defines if stereoscopic rendering is done side by side or over under.
  86404. */
  86405. isStereoscopicSideBySide: boolean;
  86406. /**
  86407. * 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
  86408. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86409. * else in the scene.
  86410. */
  86411. customRenderTargets: RenderTargetTexture[];
  86412. /**
  86413. * When set, the camera will render to this render target instead of the default canvas
  86414. */
  86415. outputRenderTarget: Nullable<RenderTargetTexture>;
  86416. /**
  86417. * Observable triggered when the camera view matrix has changed.
  86418. */
  86419. onViewMatrixChangedObservable: Observable<Camera>;
  86420. /**
  86421. * Observable triggered when the camera Projection matrix has changed.
  86422. */
  86423. onProjectionMatrixChangedObservable: Observable<Camera>;
  86424. /**
  86425. * Observable triggered when the inputs have been processed.
  86426. */
  86427. onAfterCheckInputsObservable: Observable<Camera>;
  86428. /**
  86429. * Observable triggered when reset has been called and applied to the camera.
  86430. */
  86431. onRestoreStateObservable: Observable<Camera>;
  86432. /** @hidden */
  86433. _cameraRigParams: any;
  86434. /** @hidden */
  86435. _rigCameras: Camera[];
  86436. /** @hidden */
  86437. _rigPostProcess: Nullable<PostProcess>;
  86438. protected _webvrViewMatrix: Matrix;
  86439. /** @hidden */
  86440. _skipRendering: boolean;
  86441. /** @hidden */
  86442. _alternateCamera: Camera;
  86443. /** @hidden */
  86444. _projectionMatrix: Matrix;
  86445. /** @hidden */
  86446. _postProcesses: Nullable<PostProcess>[];
  86447. /** @hidden */
  86448. _activeMeshes: SmartArray<AbstractMesh>;
  86449. protected _globalPosition: Vector3;
  86450. /** hidden */
  86451. _computedViewMatrix: Matrix;
  86452. private _doNotComputeProjectionMatrix;
  86453. private _transformMatrix;
  86454. private _frustumPlanes;
  86455. private _refreshFrustumPlanes;
  86456. private _storedFov;
  86457. private _stateStored;
  86458. /**
  86459. * Instantiates a new camera object.
  86460. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86461. * @see http://doc.babylonjs.com/features/cameras
  86462. * @param name Defines the name of the camera in the scene
  86463. * @param position Defines the position of the camera
  86464. * @param scene Defines the scene the camera belongs too
  86465. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86466. */
  86467. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86468. /**
  86469. * Store current camera state (fov, position, etc..)
  86470. * @returns the camera
  86471. */
  86472. storeState(): Camera;
  86473. /**
  86474. * Restores the camera state values if it has been stored. You must call storeState() first
  86475. */
  86476. protected _restoreStateValues(): boolean;
  86477. /**
  86478. * Restored camera state. You must call storeState() first.
  86479. * @returns true if restored and false otherwise
  86480. */
  86481. restoreState(): boolean;
  86482. /**
  86483. * Gets the class name of the camera.
  86484. * @returns the class name
  86485. */
  86486. getClassName(): string;
  86487. /** @hidden */
  86488. readonly _isCamera: boolean;
  86489. /**
  86490. * Gets a string representation of the camera useful for debug purpose.
  86491. * @param fullDetails Defines that a more verboe level of logging is required
  86492. * @returns the string representation
  86493. */
  86494. toString(fullDetails?: boolean): string;
  86495. /**
  86496. * Gets the current world space position of the camera.
  86497. */
  86498. readonly globalPosition: Vector3;
  86499. /**
  86500. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86501. * @returns the active meshe list
  86502. */
  86503. getActiveMeshes(): SmartArray<AbstractMesh>;
  86504. /**
  86505. * Check wether a mesh is part of the current active mesh list of the camera
  86506. * @param mesh Defines the mesh to check
  86507. * @returns true if active, false otherwise
  86508. */
  86509. isActiveMesh(mesh: Mesh): boolean;
  86510. /**
  86511. * Is this camera ready to be used/rendered
  86512. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86513. * @return true if the camera is ready
  86514. */
  86515. isReady(completeCheck?: boolean): boolean;
  86516. /** @hidden */
  86517. _initCache(): void;
  86518. /** @hidden */
  86519. _updateCache(ignoreParentClass?: boolean): void;
  86520. /** @hidden */
  86521. _isSynchronized(): boolean;
  86522. /** @hidden */
  86523. _isSynchronizedViewMatrix(): boolean;
  86524. /** @hidden */
  86525. _isSynchronizedProjectionMatrix(): boolean;
  86526. /**
  86527. * Attach the input controls to a specific dom element to get the input from.
  86528. * @param element Defines the element the controls should be listened from
  86529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86530. */
  86531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86532. /**
  86533. * Detach the current controls from the specified dom element.
  86534. * @param element Defines the element to stop listening the inputs from
  86535. */
  86536. detachControl(element: HTMLElement): void;
  86537. /**
  86538. * Update the camera state according to the different inputs gathered during the frame.
  86539. */
  86540. update(): void;
  86541. /** @hidden */
  86542. _checkInputs(): void;
  86543. /** @hidden */
  86544. readonly rigCameras: Camera[];
  86545. /**
  86546. * Gets the post process used by the rig cameras
  86547. */
  86548. readonly rigPostProcess: Nullable<PostProcess>;
  86549. /**
  86550. * Internal, gets the first post proces.
  86551. * @returns the first post process to be run on this camera.
  86552. */
  86553. _getFirstPostProcess(): Nullable<PostProcess>;
  86554. private _cascadePostProcessesToRigCams;
  86555. /**
  86556. * Attach a post process to the camera.
  86557. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86558. * @param postProcess The post process to attach to the camera
  86559. * @param insertAt The position of the post process in case several of them are in use in the scene
  86560. * @returns the position the post process has been inserted at
  86561. */
  86562. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86563. /**
  86564. * Detach a post process to the camera.
  86565. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86566. * @param postProcess The post process to detach from the camera
  86567. */
  86568. detachPostProcess(postProcess: PostProcess): void;
  86569. /**
  86570. * Gets the current world matrix of the camera
  86571. */
  86572. getWorldMatrix(): Matrix;
  86573. /** @hidden */
  86574. _getViewMatrix(): Matrix;
  86575. /**
  86576. * Gets the current view matrix of the camera.
  86577. * @param force forces the camera to recompute the matrix without looking at the cached state
  86578. * @returns the view matrix
  86579. */
  86580. getViewMatrix(force?: boolean): Matrix;
  86581. /**
  86582. * Freeze the projection matrix.
  86583. * It will prevent the cache check of the camera projection compute and can speed up perf
  86584. * if no parameter of the camera are meant to change
  86585. * @param projection Defines manually a projection if necessary
  86586. */
  86587. freezeProjectionMatrix(projection?: Matrix): void;
  86588. /**
  86589. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86590. */
  86591. unfreezeProjectionMatrix(): void;
  86592. /**
  86593. * Gets the current projection matrix of the camera.
  86594. * @param force forces the camera to recompute the matrix without looking at the cached state
  86595. * @returns the projection matrix
  86596. */
  86597. getProjectionMatrix(force?: boolean): Matrix;
  86598. /**
  86599. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86600. * @returns a Matrix
  86601. */
  86602. getTransformationMatrix(): Matrix;
  86603. private _updateFrustumPlanes;
  86604. /**
  86605. * Checks if a cullable object (mesh...) is in the camera frustum
  86606. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86607. * @param target The object to check
  86608. * @returns true if the object is in frustum otherwise false
  86609. */
  86610. isInFrustum(target: ICullable): boolean;
  86611. /**
  86612. * Checks if a cullable object (mesh...) is in the camera frustum
  86613. * Unlike isInFrustum this cheks the full bounding box
  86614. * @param target The object to check
  86615. * @returns true if the object is in frustum otherwise false
  86616. */
  86617. isCompletelyInFrustum(target: ICullable): boolean;
  86618. /**
  86619. * Gets a ray in the forward direction from the camera.
  86620. * @param length Defines the length of the ray to create
  86621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86622. * @param origin Defines the start point of the ray which defaults to the camera position
  86623. * @returns the forward ray
  86624. */
  86625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86626. /**
  86627. * Releases resources associated with this node.
  86628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86630. */
  86631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86632. /**
  86633. * Gets the left camera of a rig setup in case of Rigged Camera
  86634. */
  86635. readonly leftCamera: Nullable<FreeCamera>;
  86636. /**
  86637. * Gets the right camera of a rig setup in case of Rigged Camera
  86638. */
  86639. readonly rightCamera: Nullable<FreeCamera>;
  86640. /**
  86641. * Gets the left camera target of a rig setup in case of Rigged Camera
  86642. * @returns the target position
  86643. */
  86644. getLeftTarget(): Nullable<Vector3>;
  86645. /**
  86646. * Gets the right camera target of a rig setup in case of Rigged Camera
  86647. * @returns the target position
  86648. */
  86649. getRightTarget(): Nullable<Vector3>;
  86650. /**
  86651. * @hidden
  86652. */
  86653. setCameraRigMode(mode: number, rigParams: any): void;
  86654. /** @hidden */
  86655. static _setStereoscopicRigMode(camera: Camera): void;
  86656. /** @hidden */
  86657. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86658. /** @hidden */
  86659. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86660. /** @hidden */
  86661. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86662. /** @hidden */
  86663. _getVRProjectionMatrix(): Matrix;
  86664. protected _updateCameraRotationMatrix(): void;
  86665. protected _updateWebVRCameraRotationMatrix(): void;
  86666. /**
  86667. * This function MUST be overwritten by the different WebVR cameras available.
  86668. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86669. * @hidden
  86670. */
  86671. _getWebVRProjectionMatrix(): Matrix;
  86672. /**
  86673. * This function MUST be overwritten by the different WebVR cameras available.
  86674. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86675. * @hidden
  86676. */
  86677. _getWebVRViewMatrix(): Matrix;
  86678. /** @hidden */
  86679. setCameraRigParameter(name: string, value: any): void;
  86680. /**
  86681. * needs to be overridden by children so sub has required properties to be copied
  86682. * @hidden
  86683. */
  86684. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86685. /**
  86686. * May need to be overridden by children
  86687. * @hidden
  86688. */
  86689. _updateRigCameras(): void;
  86690. /** @hidden */
  86691. _setupInputs(): void;
  86692. /**
  86693. * Serialiaze the camera setup to a json represention
  86694. * @returns the JSON representation
  86695. */
  86696. serialize(): any;
  86697. /**
  86698. * Clones the current camera.
  86699. * @param name The cloned camera name
  86700. * @returns the cloned camera
  86701. */
  86702. clone(name: string): Camera;
  86703. /**
  86704. * Gets the direction of the camera relative to a given local axis.
  86705. * @param localAxis Defines the reference axis to provide a relative direction.
  86706. * @return the direction
  86707. */
  86708. getDirection(localAxis: Vector3): Vector3;
  86709. /**
  86710. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86711. * @param localAxis Defines the reference axis to provide a relative direction.
  86712. * @param result Defines the vector to store the result in
  86713. */
  86714. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86715. /**
  86716. * Gets a camera constructor for a given camera type
  86717. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86718. * @param name The name of the camera the result will be able to instantiate
  86719. * @param scene The scene the result will construct the camera in
  86720. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86721. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86722. * @returns a factory method to construc the camera
  86723. */
  86724. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86725. /**
  86726. * Compute the world matrix of the camera.
  86727. * @returns the camera workd matrix
  86728. */
  86729. computeWorldMatrix(): Matrix;
  86730. /**
  86731. * Parse a JSON and creates the camera from the parsed information
  86732. * @param parsedCamera The JSON to parse
  86733. * @param scene The scene to instantiate the camera in
  86734. * @returns the newly constructed camera
  86735. */
  86736. static Parse(parsedCamera: any, scene: Scene): Camera;
  86737. }
  86738. }
  86739. declare module BABYLON {
  86740. /**
  86741. * Interface for any object that can request an animation frame
  86742. */
  86743. export interface ICustomAnimationFrameRequester {
  86744. /**
  86745. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86746. */
  86747. renderFunction?: Function;
  86748. /**
  86749. * Called to request the next frame to render to
  86750. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86751. */
  86752. requestAnimationFrame: Function;
  86753. /**
  86754. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86755. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86756. */
  86757. requestID?: number;
  86758. }
  86759. /**
  86760. * Interface containing an array of animations
  86761. */
  86762. export interface IAnimatable {
  86763. /**
  86764. * Array of animations
  86765. */
  86766. animations: Array<Animation>;
  86767. }
  86768. /** Interface used by value gradients (color, factor, ...) */
  86769. export interface IValueGradient {
  86770. /**
  86771. * Gets or sets the gradient value (between 0 and 1)
  86772. */
  86773. gradient: number;
  86774. }
  86775. /** Class used to store color4 gradient */
  86776. export class ColorGradient implements IValueGradient {
  86777. /**
  86778. * Gets or sets the gradient value (between 0 and 1)
  86779. */
  86780. gradient: number;
  86781. /**
  86782. * Gets or sets first associated color
  86783. */
  86784. color1: Color4;
  86785. /**
  86786. * Gets or sets second associated color
  86787. */
  86788. color2?: Color4;
  86789. /**
  86790. * Will get a color picked randomly between color1 and color2.
  86791. * If color2 is undefined then color1 will be used
  86792. * @param result defines the target Color4 to store the result in
  86793. */
  86794. getColorToRef(result: Color4): void;
  86795. }
  86796. /** Class used to store color 3 gradient */
  86797. export class Color3Gradient implements IValueGradient {
  86798. /**
  86799. * Gets or sets the gradient value (between 0 and 1)
  86800. */
  86801. gradient: number;
  86802. /**
  86803. * Gets or sets the associated color
  86804. */
  86805. color: Color3;
  86806. }
  86807. /** Class used to store factor gradient */
  86808. export class FactorGradient implements IValueGradient {
  86809. /**
  86810. * Gets or sets the gradient value (between 0 and 1)
  86811. */
  86812. gradient: number;
  86813. /**
  86814. * Gets or sets first associated factor
  86815. */
  86816. factor1: number;
  86817. /**
  86818. * Gets or sets second associated factor
  86819. */
  86820. factor2?: number;
  86821. /**
  86822. * Will get a number picked randomly between factor1 and factor2.
  86823. * If factor2 is undefined then factor1 will be used
  86824. * @returns the picked number
  86825. */
  86826. getFactor(): number;
  86827. }
  86828. /**
  86829. * @ignore
  86830. * Application error to support additional information when loading a file
  86831. */
  86832. export class LoadFileError extends Error {
  86833. /** defines the optional XHR request */
  86834. request?: XMLHttpRequest | undefined;
  86835. private static _setPrototypeOf;
  86836. /**
  86837. * Creates a new LoadFileError
  86838. * @param message defines the message of the error
  86839. * @param request defines the optional XHR request
  86840. */
  86841. constructor(message: string,
  86842. /** defines the optional XHR request */
  86843. request?: XMLHttpRequest | undefined);
  86844. }
  86845. /**
  86846. * Class used to define a retry strategy when error happens while loading assets
  86847. */
  86848. export class RetryStrategy {
  86849. /**
  86850. * Function used to defines an exponential back off strategy
  86851. * @param maxRetries defines the maximum number of retries (3 by default)
  86852. * @param baseInterval defines the interval between retries
  86853. * @returns the strategy function to use
  86854. */
  86855. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86856. }
  86857. /**
  86858. * File request interface
  86859. */
  86860. export interface IFileRequest {
  86861. /**
  86862. * Raised when the request is complete (success or error).
  86863. */
  86864. onCompleteObservable: Observable<IFileRequest>;
  86865. /**
  86866. * Aborts the request for a file.
  86867. */
  86868. abort: () => void;
  86869. }
  86870. /**
  86871. * Class containing a set of static utilities functions
  86872. */
  86873. export class Tools {
  86874. /**
  86875. * Gets or sets the base URL to use to load assets
  86876. */
  86877. static BaseUrl: string;
  86878. /**
  86879. * Enable/Disable Custom HTTP Request Headers globally.
  86880. * default = false
  86881. * @see CustomRequestHeaders
  86882. */
  86883. static UseCustomRequestHeaders: boolean;
  86884. /**
  86885. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86886. * i.e. when loading files, where the server/service expects an Authorization header.
  86887. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86888. */
  86889. static CustomRequestHeaders: {
  86890. [key: string]: string;
  86891. };
  86892. /**
  86893. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86894. */
  86895. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86896. /**
  86897. * Default behaviour for cors in the application.
  86898. * It can be a string if the expected behavior is identical in the entire app.
  86899. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86900. */
  86901. static CorsBehavior: string | ((url: string | string[]) => string);
  86902. /**
  86903. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86904. * @ignorenaming
  86905. */
  86906. static UseFallbackTexture: boolean;
  86907. /**
  86908. * Use this object to register external classes like custom textures or material
  86909. * to allow the laoders to instantiate them
  86910. */
  86911. static RegisteredExternalClasses: {
  86912. [key: string]: Object;
  86913. };
  86914. /**
  86915. * Texture content used if a texture cannot loaded
  86916. * @ignorenaming
  86917. */
  86918. static fallbackTexture: string;
  86919. /**
  86920. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86921. * @param u defines the coordinate on X axis
  86922. * @param v defines the coordinate on Y axis
  86923. * @param width defines the width of the source data
  86924. * @param height defines the height of the source data
  86925. * @param pixels defines the source byte array
  86926. * @param color defines the output color
  86927. */
  86928. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86929. /**
  86930. * Interpolates between a and b via alpha
  86931. * @param a The lower value (returned when alpha = 0)
  86932. * @param b The upper value (returned when alpha = 1)
  86933. * @param alpha The interpolation-factor
  86934. * @return The mixed value
  86935. */
  86936. static Mix(a: number, b: number, alpha: number): number;
  86937. /**
  86938. * Tries to instantiate a new object from a given class name
  86939. * @param className defines the class name to instantiate
  86940. * @returns the new object or null if the system was not able to do the instantiation
  86941. */
  86942. static Instantiate(className: string): any;
  86943. /**
  86944. * Provides a slice function that will work even on IE
  86945. * @param data defines the array to slice
  86946. * @param start defines the start of the data (optional)
  86947. * @param end defines the end of the data (optional)
  86948. * @returns the new sliced array
  86949. */
  86950. static Slice<T>(data: T, start?: number, end?: number): T;
  86951. /**
  86952. * Polyfill for setImmediate
  86953. * @param action defines the action to execute after the current execution block
  86954. */
  86955. static SetImmediate(action: () => void): void;
  86956. /**
  86957. * Function indicating if a number is an exponent of 2
  86958. * @param value defines the value to test
  86959. * @returns true if the value is an exponent of 2
  86960. */
  86961. static IsExponentOfTwo(value: number): boolean;
  86962. private static _tmpFloatArray;
  86963. /**
  86964. * Returns the nearest 32-bit single precision float representation of a Number
  86965. * @param value A Number. If the parameter is of a different type, it will get converted
  86966. * to a number or to NaN if it cannot be converted
  86967. * @returns number
  86968. */
  86969. static FloatRound(value: number): number;
  86970. /**
  86971. * Find the next highest power of two.
  86972. * @param x Number to start search from.
  86973. * @return Next highest power of two.
  86974. */
  86975. static CeilingPOT(x: number): number;
  86976. /**
  86977. * Find the next lowest power of two.
  86978. * @param x Number to start search from.
  86979. * @return Next lowest power of two.
  86980. */
  86981. static FloorPOT(x: number): number;
  86982. /**
  86983. * Find the nearest power of two.
  86984. * @param x Number to start search from.
  86985. * @return Next nearest power of two.
  86986. */
  86987. static NearestPOT(x: number): number;
  86988. /**
  86989. * Get the closest exponent of two
  86990. * @param value defines the value to approximate
  86991. * @param max defines the maximum value to return
  86992. * @param mode defines how to define the closest value
  86993. * @returns closest exponent of two of the given value
  86994. */
  86995. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86996. /**
  86997. * Extracts the filename from a path
  86998. * @param path defines the path to use
  86999. * @returns the filename
  87000. */
  87001. static GetFilename(path: string): string;
  87002. /**
  87003. * Extracts the "folder" part of a path (everything before the filename).
  87004. * @param uri The URI to extract the info from
  87005. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87006. * @returns The "folder" part of the path
  87007. */
  87008. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87009. /**
  87010. * Extracts text content from a DOM element hierarchy
  87011. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87012. */
  87013. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87014. /**
  87015. * Convert an angle in radians to degrees
  87016. * @param angle defines the angle to convert
  87017. * @returns the angle in degrees
  87018. */
  87019. static ToDegrees(angle: number): number;
  87020. /**
  87021. * Convert an angle in degrees to radians
  87022. * @param angle defines the angle to convert
  87023. * @returns the angle in radians
  87024. */
  87025. static ToRadians(angle: number): number;
  87026. /**
  87027. * Encode a buffer to a base64 string
  87028. * @param buffer defines the buffer to encode
  87029. * @returns the encoded string
  87030. */
  87031. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87032. /**
  87033. * Extracts minimum and maximum values from a list of indexed positions
  87034. * @param positions defines the positions to use
  87035. * @param indices defines the indices to the positions
  87036. * @param indexStart defines the start index
  87037. * @param indexCount defines the end index
  87038. * @param bias defines bias value to add to the result
  87039. * @return minimum and maximum values
  87040. */
  87041. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87042. minimum: Vector3;
  87043. maximum: Vector3;
  87044. };
  87045. /**
  87046. * Extracts minimum and maximum values from a list of positions
  87047. * @param positions defines the positions to use
  87048. * @param start defines the start index in the positions array
  87049. * @param count defines the number of positions to handle
  87050. * @param bias defines bias value to add to the result
  87051. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87052. * @return minimum and maximum values
  87053. */
  87054. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87055. minimum: Vector3;
  87056. maximum: Vector3;
  87057. };
  87058. /**
  87059. * Returns an array if obj is not an array
  87060. * @param obj defines the object to evaluate as an array
  87061. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87062. * @returns either obj directly if obj is an array or a new array containing obj
  87063. */
  87064. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87065. /**
  87066. * Gets the pointer prefix to use
  87067. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87068. */
  87069. static GetPointerPrefix(): string;
  87070. /**
  87071. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87072. * @param func - the function to be called
  87073. * @param requester - the object that will request the next frame. Falls back to window.
  87074. * @returns frame number
  87075. */
  87076. static QueueNewFrame(func: () => void, requester?: any): number;
  87077. /**
  87078. * Ask the browser to promote the current element to fullscreen rendering mode
  87079. * @param element defines the DOM element to promote
  87080. */
  87081. static RequestFullscreen(element: HTMLElement): void;
  87082. /**
  87083. * Asks the browser to exit fullscreen mode
  87084. */
  87085. static ExitFullscreen(): void;
  87086. /**
  87087. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87088. * @param url define the url we are trying
  87089. * @param element define the dom element where to configure the cors policy
  87090. */
  87091. static SetCorsBehavior(url: string | string[], element: {
  87092. crossOrigin: string | null;
  87093. }): void;
  87094. /**
  87095. * Removes unwanted characters from an url
  87096. * @param url defines the url to clean
  87097. * @returns the cleaned url
  87098. */
  87099. static CleanUrl(url: string): string;
  87100. /**
  87101. * Gets or sets a function used to pre-process url before using them to load assets
  87102. */
  87103. static PreprocessUrl: (url: string) => string;
  87104. /**
  87105. * Loads an image as an HTMLImageElement.
  87106. * @param input url string, ArrayBuffer, or Blob to load
  87107. * @param onLoad callback called when the image successfully loads
  87108. * @param onError callback called when the image fails to load
  87109. * @param offlineProvider offline provider for caching
  87110. * @returns the HTMLImageElement of the loaded image
  87111. */
  87112. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87113. /**
  87114. * Loads a file
  87115. * @param url url string, ArrayBuffer, or Blob to load
  87116. * @param onSuccess callback called when the file successfully loads
  87117. * @param onProgress callback called while file is loading (if the server supports this mode)
  87118. * @param offlineProvider defines the offline provider for caching
  87119. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87120. * @param onError callback called when the file fails to load
  87121. * @returns a file request object
  87122. */
  87123. 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;
  87124. /**
  87125. * Load a script (identified by an url). When the url returns, the
  87126. * content of this file is added into a new script element, attached to the DOM (body element)
  87127. * @param scriptUrl defines the url of the script to laod
  87128. * @param onSuccess defines the callback called when the script is loaded
  87129. * @param onError defines the callback to call if an error occurs
  87130. */
  87131. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87132. /**
  87133. * Loads a file from a blob
  87134. * @param fileToLoad defines the blob to use
  87135. * @param callback defines the callback to call when data is loaded
  87136. * @param progressCallback defines the callback to call during loading process
  87137. * @returns a file request object
  87138. */
  87139. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87140. /**
  87141. * Loads a file
  87142. * @param fileToLoad defines the file to load
  87143. * @param callback defines the callback to call when data is loaded
  87144. * @param progressCallBack defines the callback to call during loading process
  87145. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87146. * @returns a file request object
  87147. */
  87148. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87149. /**
  87150. * Creates a data url from a given string content
  87151. * @param content defines the content to convert
  87152. * @returns the new data url link
  87153. */
  87154. static FileAsURL(content: string): string;
  87155. /**
  87156. * Format the given number to a specific decimal format
  87157. * @param value defines the number to format
  87158. * @param decimals defines the number of decimals to use
  87159. * @returns the formatted string
  87160. */
  87161. static Format(value: number, decimals?: number): string;
  87162. /**
  87163. * Checks if a given vector is inside a specific range
  87164. * @param v defines the vector to test
  87165. * @param min defines the minimum range
  87166. * @param max defines the maximum range
  87167. */
  87168. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87169. /**
  87170. * Tries to copy an object by duplicating every property
  87171. * @param source defines the source object
  87172. * @param destination defines the target object
  87173. * @param doNotCopyList defines a list of properties to avoid
  87174. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87175. */
  87176. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87177. /**
  87178. * Gets a boolean indicating if the given object has no own property
  87179. * @param obj defines the object to test
  87180. * @returns true if object has no own property
  87181. */
  87182. static IsEmpty(obj: any): boolean;
  87183. /**
  87184. * Function used to register events at window level
  87185. * @param events defines the events to register
  87186. */
  87187. static RegisterTopRootEvents(events: {
  87188. name: string;
  87189. handler: Nullable<(e: FocusEvent) => any>;
  87190. }[]): void;
  87191. /**
  87192. * Function used to unregister events from window level
  87193. * @param events defines the events to unregister
  87194. */
  87195. static UnregisterTopRootEvents(events: {
  87196. name: string;
  87197. handler: Nullable<(e: FocusEvent) => any>;
  87198. }[]): void;
  87199. /**
  87200. * Dumps the current bound framebuffer
  87201. * @param width defines the rendering width
  87202. * @param height defines the rendering height
  87203. * @param engine defines the hosting engine
  87204. * @param successCallback defines the callback triggered once the data are available
  87205. * @param mimeType defines the mime type of the result
  87206. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87207. */
  87208. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87209. /**
  87210. * Converts the canvas data to blob.
  87211. * This acts as a polyfill for browsers not supporting the to blob function.
  87212. * @param canvas Defines the canvas to extract the data from
  87213. * @param successCallback Defines the callback triggered once the data are available
  87214. * @param mimeType Defines the mime type of the result
  87215. */
  87216. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87217. /**
  87218. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87219. * @param successCallback defines the callback triggered once the data are available
  87220. * @param mimeType defines the mime type of the result
  87221. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87222. */
  87223. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87224. /**
  87225. * Downloads a blob in the browser
  87226. * @param blob defines the blob to download
  87227. * @param fileName defines the name of the downloaded file
  87228. */
  87229. static Download(blob: Blob, fileName: string): void;
  87230. /**
  87231. * Captures a screenshot of the current rendering
  87232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87233. * @param engine defines the rendering engine
  87234. * @param camera defines the source camera
  87235. * @param size This parameter can be set to a single number or to an object with the
  87236. * following (optional) properties: precision, width, height. If a single number is passed,
  87237. * it will be used for both width and height. If an object is passed, the screenshot size
  87238. * will be derived from the parameters. The precision property is a multiplier allowing
  87239. * rendering at a higher or lower resolution
  87240. * @param successCallback defines the callback receives a single parameter which contains the
  87241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87242. * src parameter of an <img> to display it
  87243. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87244. * Check your browser for supported MIME types
  87245. */
  87246. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87247. /**
  87248. * Generates an image screenshot from the specified camera.
  87249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87250. * @param engine The engine to use for rendering
  87251. * @param camera The camera to use for rendering
  87252. * @param size This parameter can be set to a single number or to an object with the
  87253. * following (optional) properties: precision, width, height. If a single number is passed,
  87254. * it will be used for both width and height. If an object is passed, the screenshot size
  87255. * will be derived from the parameters. The precision property is a multiplier allowing
  87256. * rendering at a higher or lower resolution
  87257. * @param successCallback The callback receives a single parameter which contains the
  87258. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87259. * src parameter of an <img> to display it
  87260. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87261. * Check your browser for supported MIME types
  87262. * @param samples Texture samples (default: 1)
  87263. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87264. * @param fileName A name for for the downloaded file.
  87265. */
  87266. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87267. /**
  87268. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87269. * Be aware Math.random() could cause collisions, but:
  87270. * "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"
  87271. * @returns a pseudo random id
  87272. */
  87273. static RandomId(): string;
  87274. /**
  87275. * Test if the given uri is a base64 string
  87276. * @param uri The uri to test
  87277. * @return True if the uri is a base64 string or false otherwise
  87278. */
  87279. static IsBase64(uri: string): boolean;
  87280. /**
  87281. * Decode the given base64 uri.
  87282. * @param uri The uri to decode
  87283. * @return The decoded base64 data.
  87284. */
  87285. static DecodeBase64(uri: string): ArrayBuffer;
  87286. /**
  87287. * No log
  87288. */
  87289. static readonly NoneLogLevel: number;
  87290. /**
  87291. * Only message logs
  87292. */
  87293. static readonly MessageLogLevel: number;
  87294. /**
  87295. * Only warning logs
  87296. */
  87297. static readonly WarningLogLevel: number;
  87298. /**
  87299. * Only error logs
  87300. */
  87301. static readonly ErrorLogLevel: number;
  87302. /**
  87303. * All logs
  87304. */
  87305. static readonly AllLogLevel: number;
  87306. /**
  87307. * Gets a value indicating the number of loading errors
  87308. * @ignorenaming
  87309. */
  87310. static readonly errorsCount: number;
  87311. /**
  87312. * Callback called when a new log is added
  87313. */
  87314. static OnNewCacheEntry: (entry: string) => void;
  87315. /**
  87316. * Log a message to the console
  87317. * @param message defines the message to log
  87318. */
  87319. static Log(message: string): void;
  87320. /**
  87321. * Write a warning message to the console
  87322. * @param message defines the message to log
  87323. */
  87324. static Warn(message: string): void;
  87325. /**
  87326. * Write an error message to the console
  87327. * @param message defines the message to log
  87328. */
  87329. static Error(message: string): void;
  87330. /**
  87331. * Gets current log cache (list of logs)
  87332. */
  87333. static readonly LogCache: string;
  87334. /**
  87335. * Clears the log cache
  87336. */
  87337. static ClearLogCache(): void;
  87338. /**
  87339. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87340. */
  87341. static LogLevels: number;
  87342. /**
  87343. * Checks if the loaded document was accessed via `file:`-Protocol.
  87344. * @returns boolean
  87345. */
  87346. static IsFileURL(): boolean;
  87347. /**
  87348. * Checks if the window object exists
  87349. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87350. */
  87351. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87352. /**
  87353. * No performance log
  87354. */
  87355. static readonly PerformanceNoneLogLevel: number;
  87356. /**
  87357. * Use user marks to log performance
  87358. */
  87359. static readonly PerformanceUserMarkLogLevel: number;
  87360. /**
  87361. * Log performance to the console
  87362. */
  87363. static readonly PerformanceConsoleLogLevel: number;
  87364. private static _performance;
  87365. /**
  87366. * Sets the current performance log level
  87367. */
  87368. static PerformanceLogLevel: number;
  87369. private static _StartPerformanceCounterDisabled;
  87370. private static _EndPerformanceCounterDisabled;
  87371. private static _StartUserMark;
  87372. private static _EndUserMark;
  87373. private static _StartPerformanceConsole;
  87374. private static _EndPerformanceConsole;
  87375. /**
  87376. * Injects the @see CustomRequestHeaders into the given request
  87377. * @param request the request that should be used for injection
  87378. */
  87379. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87380. /**
  87381. * Starts a performance counter
  87382. */
  87383. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87384. /**
  87385. * Ends a specific performance coutner
  87386. */
  87387. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87388. /**
  87389. * Gets either window.performance.now() if supported or Date.now() else
  87390. */
  87391. static readonly Now: number;
  87392. /**
  87393. * This method will return the name of the class used to create the instance of the given object.
  87394. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87395. * @param object the object to get the class name from
  87396. * @param isType defines if the object is actually a type
  87397. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87398. */
  87399. static GetClassName(object: any, isType?: boolean): string;
  87400. /**
  87401. * Gets the first element of an array satisfying a given predicate
  87402. * @param array defines the array to browse
  87403. * @param predicate defines the predicate to use
  87404. * @returns null if not found or the element
  87405. */
  87406. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87407. /**
  87408. * This method will return the name of the full name of the class, including its owning module (if any).
  87409. * 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).
  87410. * @param object the object to get the class name from
  87411. * @param isType defines if the object is actually a type
  87412. * @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.
  87413. * @ignorenaming
  87414. */
  87415. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87416. /**
  87417. * Returns a promise that resolves after the given amount of time.
  87418. * @param delay Number of milliseconds to delay
  87419. * @returns Promise that resolves after the given amount of time
  87420. */
  87421. static DelayAsync(delay: number): Promise<void>;
  87422. /**
  87423. * Gets the current gradient from an array of IValueGradient
  87424. * @param ratio defines the current ratio to get
  87425. * @param gradients defines the array of IValueGradient
  87426. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87427. */
  87428. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87429. }
  87430. /**
  87431. * This class is used to track a performance counter which is number based.
  87432. * The user has access to many properties which give statistics of different nature.
  87433. *
  87434. * The implementer can track two kinds of Performance Counter: time and count.
  87435. * 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.
  87436. * 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.
  87437. */
  87438. export class PerfCounter {
  87439. /**
  87440. * Gets or sets a global boolean to turn on and off all the counters
  87441. */
  87442. static Enabled: boolean;
  87443. /**
  87444. * Returns the smallest value ever
  87445. */
  87446. readonly min: number;
  87447. /**
  87448. * Returns the biggest value ever
  87449. */
  87450. readonly max: number;
  87451. /**
  87452. * Returns the average value since the performance counter is running
  87453. */
  87454. readonly average: number;
  87455. /**
  87456. * Returns the average value of the last second the counter was monitored
  87457. */
  87458. readonly lastSecAverage: number;
  87459. /**
  87460. * Returns the current value
  87461. */
  87462. readonly current: number;
  87463. /**
  87464. * Gets the accumulated total
  87465. */
  87466. readonly total: number;
  87467. /**
  87468. * Gets the total value count
  87469. */
  87470. readonly count: number;
  87471. /**
  87472. * Creates a new counter
  87473. */
  87474. constructor();
  87475. /**
  87476. * Call this method to start monitoring a new frame.
  87477. * 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.
  87478. */
  87479. fetchNewFrame(): void;
  87480. /**
  87481. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87482. * @param newCount the count value to add to the monitored count
  87483. * @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.
  87484. */
  87485. addCount(newCount: number, fetchResult: boolean): void;
  87486. /**
  87487. * Start monitoring this performance counter
  87488. */
  87489. beginMonitoring(): void;
  87490. /**
  87491. * Compute the time lapsed since the previous beginMonitoring() call.
  87492. * @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
  87493. */
  87494. endMonitoring(newFrame?: boolean): void;
  87495. private _fetchResult;
  87496. private _startMonitoringTime;
  87497. private _min;
  87498. private _max;
  87499. private _average;
  87500. private _current;
  87501. private _totalValueCount;
  87502. private _totalAccumulated;
  87503. private _lastSecAverage;
  87504. private _lastSecAccumulated;
  87505. private _lastSecTime;
  87506. private _lastSecValueCount;
  87507. }
  87508. /**
  87509. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87510. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87511. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87512. * @param name The name of the class, case should be preserved
  87513. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87514. */
  87515. export function className(name: string, module?: string): (target: Object) => void;
  87516. /**
  87517. * An implementation of a loop for asynchronous functions.
  87518. */
  87519. export class AsyncLoop {
  87520. /**
  87521. * Defines the number of iterations for the loop
  87522. */
  87523. iterations: number;
  87524. /**
  87525. * Defines the current index of the loop.
  87526. */
  87527. index: number;
  87528. private _done;
  87529. private _fn;
  87530. private _successCallback;
  87531. /**
  87532. * Constructor.
  87533. * @param iterations the number of iterations.
  87534. * @param func the function to run each iteration
  87535. * @param successCallback the callback that will be called upon succesful execution
  87536. * @param offset starting offset.
  87537. */
  87538. constructor(
  87539. /**
  87540. * Defines the number of iterations for the loop
  87541. */
  87542. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87543. /**
  87544. * Execute the next iteration. Must be called after the last iteration was finished.
  87545. */
  87546. executeNext(): void;
  87547. /**
  87548. * Break the loop and run the success callback.
  87549. */
  87550. breakLoop(): void;
  87551. /**
  87552. * Create and run an async loop.
  87553. * @param iterations the number of iterations.
  87554. * @param fn the function to run each iteration
  87555. * @param successCallback the callback that will be called upon succesful execution
  87556. * @param offset starting offset.
  87557. * @returns the created async loop object
  87558. */
  87559. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87560. /**
  87561. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87562. * @param iterations total number of iterations
  87563. * @param syncedIterations number of synchronous iterations in each async iteration.
  87564. * @param fn the function to call each iteration.
  87565. * @param callback a success call back that will be called when iterating stops.
  87566. * @param breakFunction a break condition (optional)
  87567. * @param timeout timeout settings for the setTimeout function. default - 0.
  87568. * @returns the created async loop object
  87569. */
  87570. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87571. }
  87572. }
  87573. declare module BABYLON {
  87574. /** @hidden */
  87575. export interface ICollisionCoordinator {
  87576. createCollider(): Collider;
  87577. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87578. init(scene: Scene): void;
  87579. }
  87580. /** @hidden */
  87581. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87582. private _scene;
  87583. private _scaledPosition;
  87584. private _scaledVelocity;
  87585. private _finalPosition;
  87586. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87587. createCollider(): Collider;
  87588. init(scene: Scene): void;
  87589. private _collideWithWorld;
  87590. }
  87591. }
  87592. declare module BABYLON {
  87593. /**
  87594. * This class defines the direct association between an animation and a target
  87595. */
  87596. export class TargetedAnimation {
  87597. /**
  87598. * Animation to perform
  87599. */
  87600. animation: Animation;
  87601. /**
  87602. * Target to animate
  87603. */
  87604. target: any;
  87605. }
  87606. /**
  87607. * Use this class to create coordinated animations on multiple targets
  87608. */
  87609. export class AnimationGroup implements IDisposable {
  87610. /** The name of the animation group */
  87611. name: string;
  87612. private _scene;
  87613. private _targetedAnimations;
  87614. private _animatables;
  87615. private _from;
  87616. private _to;
  87617. private _isStarted;
  87618. private _isPaused;
  87619. private _speedRatio;
  87620. /**
  87621. * Gets or sets the unique id of the node
  87622. */
  87623. uniqueId: number;
  87624. /**
  87625. * This observable will notify when one animation have ended
  87626. */
  87627. onAnimationEndObservable: Observable<TargetedAnimation>;
  87628. /**
  87629. * Observer raised when one animation loops
  87630. */
  87631. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87632. /**
  87633. * This observable will notify when all animations have ended.
  87634. */
  87635. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87636. /**
  87637. * This observable will notify when all animations have paused.
  87638. */
  87639. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87640. /**
  87641. * This observable will notify when all animations are playing.
  87642. */
  87643. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87644. /**
  87645. * Gets the first frame
  87646. */
  87647. readonly from: number;
  87648. /**
  87649. * Gets the last frame
  87650. */
  87651. readonly to: number;
  87652. /**
  87653. * Define if the animations are started
  87654. */
  87655. readonly isStarted: boolean;
  87656. /**
  87657. * Gets a value indicating that the current group is playing
  87658. */
  87659. readonly isPlaying: boolean;
  87660. /**
  87661. * Gets or sets the speed ratio to use for all animations
  87662. */
  87663. /**
  87664. * Gets or sets the speed ratio to use for all animations
  87665. */
  87666. speedRatio: number;
  87667. /**
  87668. * Gets the targeted animations for this animation group
  87669. */
  87670. readonly targetedAnimations: Array<TargetedAnimation>;
  87671. /**
  87672. * returning the list of animatables controlled by this animation group.
  87673. */
  87674. readonly animatables: Array<Animatable>;
  87675. /**
  87676. * Instantiates a new Animation Group.
  87677. * This helps managing several animations at once.
  87678. * @see http://doc.babylonjs.com/how_to/group
  87679. * @param name Defines the name of the group
  87680. * @param scene Defines the scene the group belongs to
  87681. */
  87682. constructor(
  87683. /** The name of the animation group */
  87684. name: string, scene?: Nullable<Scene>);
  87685. /**
  87686. * Add an animation (with its target) in the group
  87687. * @param animation defines the animation we want to add
  87688. * @param target defines the target of the animation
  87689. * @returns the TargetedAnimation object
  87690. */
  87691. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87692. /**
  87693. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87694. * It can add constant keys at begin or end
  87695. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87696. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87697. * @returns the animation group
  87698. */
  87699. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87700. /**
  87701. * Start all animations on given targets
  87702. * @param loop defines if animations must loop
  87703. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87704. * @param from defines the from key (optional)
  87705. * @param to defines the to key (optional)
  87706. * @returns the current animation group
  87707. */
  87708. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87709. /**
  87710. * Pause all animations
  87711. * @returns the animation group
  87712. */
  87713. pause(): AnimationGroup;
  87714. /**
  87715. * Play all animations to initial state
  87716. * This function will start() the animations if they were not started or will restart() them if they were paused
  87717. * @param loop defines if animations must loop
  87718. * @returns the animation group
  87719. */
  87720. play(loop?: boolean): AnimationGroup;
  87721. /**
  87722. * Reset all animations to initial state
  87723. * @returns the animation group
  87724. */
  87725. reset(): AnimationGroup;
  87726. /**
  87727. * Restart animations from key 0
  87728. * @returns the animation group
  87729. */
  87730. restart(): AnimationGroup;
  87731. /**
  87732. * Stop all animations
  87733. * @returns the animation group
  87734. */
  87735. stop(): AnimationGroup;
  87736. /**
  87737. * Set animation weight for all animatables
  87738. * @param weight defines the weight to use
  87739. * @return the animationGroup
  87740. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87741. */
  87742. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87743. /**
  87744. * Synchronize and normalize all animatables with a source animatable
  87745. * @param root defines the root animatable to synchronize with
  87746. * @return the animationGroup
  87747. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87748. */
  87749. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87750. /**
  87751. * Goes to a specific frame in this animation group
  87752. * @param frame the frame number to go to
  87753. * @return the animationGroup
  87754. */
  87755. goToFrame(frame: number): AnimationGroup;
  87756. /**
  87757. * Dispose all associated resources
  87758. */
  87759. dispose(): void;
  87760. private _checkAnimationGroupEnded;
  87761. /**
  87762. * Clone the current animation group and returns a copy
  87763. * @param newName defines the name of the new group
  87764. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  87765. * @returns the new aniamtion group
  87766. */
  87767. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  87768. /**
  87769. * Returns a new AnimationGroup object parsed from the source provided.
  87770. * @param parsedAnimationGroup defines the source
  87771. * @param scene defines the scene that will receive the animationGroup
  87772. * @returns a new AnimationGroup
  87773. */
  87774. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87775. /**
  87776. * Returns the string "AnimationGroup"
  87777. * @returns "AnimationGroup"
  87778. */
  87779. getClassName(): string;
  87780. /**
  87781. * Creates a detailled string about the object
  87782. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87783. * @returns a string representing the object
  87784. */
  87785. toString(fullDetails?: boolean): string;
  87786. }
  87787. }
  87788. declare module BABYLON {
  87789. /**
  87790. * Define an interface for all classes that will hold resources
  87791. */
  87792. export interface IDisposable {
  87793. /**
  87794. * Releases all held resources
  87795. */
  87796. dispose(): void;
  87797. }
  87798. /** Interface defining initialization parameters for Scene class */
  87799. export interface SceneOptions {
  87800. /**
  87801. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87802. * It will improve performance when the number of geometries becomes important.
  87803. */
  87804. useGeometryUniqueIdsMap?: boolean;
  87805. /**
  87806. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87807. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87808. */
  87809. useMaterialMeshMap?: boolean;
  87810. /**
  87811. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87813. */
  87814. useClonedMeshhMap?: boolean;
  87815. }
  87816. /**
  87817. * Represents a scene to be rendered by the engine.
  87818. * @see http://doc.babylonjs.com/features/scene
  87819. */
  87820. export class Scene extends AbstractScene implements IAnimatable {
  87821. private static _uniqueIdCounter;
  87822. /** The fog is deactivated */
  87823. static readonly FOGMODE_NONE: number;
  87824. /** The fog density is following an exponential function */
  87825. static readonly FOGMODE_EXP: number;
  87826. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87827. static readonly FOGMODE_EXP2: number;
  87828. /** The fog density is following a linear function. */
  87829. static readonly FOGMODE_LINEAR: number;
  87830. /**
  87831. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87833. */
  87834. static MinDeltaTime: number;
  87835. /**
  87836. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87837. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87838. */
  87839. static MaxDeltaTime: number;
  87840. /**
  87841. * Factory used to create the default material.
  87842. * @param name The name of the material to create
  87843. * @param scene The scene to create the material for
  87844. * @returns The default material
  87845. */
  87846. static DefaultMaterialFactory(scene: Scene): Material;
  87847. /**
  87848. * Factory used to create the a collision coordinator.
  87849. * @returns The collision coordinator
  87850. */
  87851. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87852. /** @hidden */
  87853. readonly _isScene: boolean;
  87854. /**
  87855. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87856. */
  87857. autoClear: boolean;
  87858. /**
  87859. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87860. */
  87861. autoClearDepthAndStencil: boolean;
  87862. /**
  87863. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87864. */
  87865. clearColor: Color4;
  87866. /**
  87867. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87868. */
  87869. ambientColor: Color3;
  87870. /** @hidden */
  87871. _environmentBRDFTexture: BaseTexture;
  87872. /** @hidden */
  87873. protected _environmentTexture: Nullable<BaseTexture>;
  87874. /**
  87875. * Texture used in all pbr material as the reflection texture.
  87876. * As in the majority of the scene they are the same (exception for multi room and so on),
  87877. * this is easier to reference from here than from all the materials.
  87878. */
  87879. /**
  87880. * Texture used in all pbr material as the reflection texture.
  87881. * As in the majority of the scene they are the same (exception for multi room and so on),
  87882. * this is easier to set here than in all the materials.
  87883. */
  87884. environmentTexture: Nullable<BaseTexture>;
  87885. /** @hidden */
  87886. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87887. /**
  87888. * Default image processing configuration used either in the rendering
  87889. * Forward main pass or through the imageProcessingPostProcess if present.
  87890. * As in the majority of the scene they are the same (exception for multi camera),
  87891. * this is easier to reference from here than from all the materials and post process.
  87892. *
  87893. * No setter as we it is a shared configuration, you can set the values instead.
  87894. */
  87895. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87896. private _forceWireframe;
  87897. /**
  87898. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87899. */
  87900. forceWireframe: boolean;
  87901. private _forcePointsCloud;
  87902. /**
  87903. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87904. */
  87905. forcePointsCloud: boolean;
  87906. /**
  87907. * Gets or sets the active clipplane 1
  87908. */
  87909. clipPlane: Nullable<Plane>;
  87910. /**
  87911. * Gets or sets the active clipplane 2
  87912. */
  87913. clipPlane2: Nullable<Plane>;
  87914. /**
  87915. * Gets or sets the active clipplane 3
  87916. */
  87917. clipPlane3: Nullable<Plane>;
  87918. /**
  87919. * Gets or sets the active clipplane 4
  87920. */
  87921. clipPlane4: Nullable<Plane>;
  87922. /**
  87923. * Gets or sets a boolean indicating if animations are enabled
  87924. */
  87925. animationsEnabled: boolean;
  87926. private _animationPropertiesOverride;
  87927. /**
  87928. * Gets or sets the animation properties override
  87929. */
  87930. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87931. /**
  87932. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87933. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87934. */
  87935. useConstantAnimationDeltaTime: boolean;
  87936. /**
  87937. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87938. * Please note that it requires to run a ray cast through the scene on every frame
  87939. */
  87940. constantlyUpdateMeshUnderPointer: boolean;
  87941. /**
  87942. * Defines the HTML cursor to use when hovering over interactive elements
  87943. */
  87944. hoverCursor: string;
  87945. /**
  87946. * Defines the HTML default cursor to use (empty by default)
  87947. */
  87948. defaultCursor: string;
  87949. /**
  87950. * This is used to call preventDefault() on pointer down
  87951. * in order to block unwanted artifacts like system double clicks
  87952. */
  87953. preventDefaultOnPointerDown: boolean;
  87954. /**
  87955. * This is used to call preventDefault() on pointer up
  87956. * in order to block unwanted artifacts like system double clicks
  87957. */
  87958. preventDefaultOnPointerUp: boolean;
  87959. /**
  87960. * Gets or sets user defined metadata
  87961. */
  87962. metadata: any;
  87963. /**
  87964. * For internal use only. Please do not use.
  87965. */
  87966. reservedDataStore: any;
  87967. /**
  87968. * Gets the name of the plugin used to load this scene (null by default)
  87969. */
  87970. loadingPluginName: string;
  87971. /**
  87972. * Use this array to add regular expressions used to disable offline support for specific urls
  87973. */
  87974. disableOfflineSupportExceptionRules: RegExp[];
  87975. /**
  87976. * An event triggered when the scene is disposed.
  87977. */
  87978. onDisposeObservable: Observable<Scene>;
  87979. private _onDisposeObserver;
  87980. /** Sets a function to be executed when this scene is disposed. */
  87981. onDispose: () => void;
  87982. /**
  87983. * An event triggered before rendering the scene (right after animations and physics)
  87984. */
  87985. onBeforeRenderObservable: Observable<Scene>;
  87986. private _onBeforeRenderObserver;
  87987. /** Sets a function to be executed before rendering this scene */
  87988. beforeRender: Nullable<() => void>;
  87989. /**
  87990. * An event triggered after rendering the scene
  87991. */
  87992. onAfterRenderObservable: Observable<Scene>;
  87993. private _onAfterRenderObserver;
  87994. /** Sets a function to be executed after rendering this scene */
  87995. afterRender: Nullable<() => void>;
  87996. /**
  87997. * An event triggered before animating the scene
  87998. */
  87999. onBeforeAnimationsObservable: Observable<Scene>;
  88000. /**
  88001. * An event triggered after animations processing
  88002. */
  88003. onAfterAnimationsObservable: Observable<Scene>;
  88004. /**
  88005. * An event triggered before draw calls are ready to be sent
  88006. */
  88007. onBeforeDrawPhaseObservable: Observable<Scene>;
  88008. /**
  88009. * An event triggered after draw calls have been sent
  88010. */
  88011. onAfterDrawPhaseObservable: Observable<Scene>;
  88012. /**
  88013. * An event triggered when the scene is ready
  88014. */
  88015. onReadyObservable: Observable<Scene>;
  88016. /**
  88017. * An event triggered before rendering a camera
  88018. */
  88019. onBeforeCameraRenderObservable: Observable<Camera>;
  88020. private _onBeforeCameraRenderObserver;
  88021. /** Sets a function to be executed before rendering a camera*/
  88022. beforeCameraRender: () => void;
  88023. /**
  88024. * An event triggered after rendering a camera
  88025. */
  88026. onAfterCameraRenderObservable: Observable<Camera>;
  88027. private _onAfterCameraRenderObserver;
  88028. /** Sets a function to be executed after rendering a camera*/
  88029. afterCameraRender: () => void;
  88030. /**
  88031. * An event triggered when active meshes evaluation is about to start
  88032. */
  88033. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88034. /**
  88035. * An event triggered when active meshes evaluation is done
  88036. */
  88037. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88038. /**
  88039. * An event triggered when particles rendering is about to start
  88040. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88041. */
  88042. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88043. /**
  88044. * An event triggered when particles rendering is done
  88045. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88046. */
  88047. onAfterParticlesRenderingObservable: Observable<Scene>;
  88048. /**
  88049. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88050. */
  88051. onDataLoadedObservable: Observable<Scene>;
  88052. /**
  88053. * An event triggered when a camera is created
  88054. */
  88055. onNewCameraAddedObservable: Observable<Camera>;
  88056. /**
  88057. * An event triggered when a camera is removed
  88058. */
  88059. onCameraRemovedObservable: Observable<Camera>;
  88060. /**
  88061. * An event triggered when a light is created
  88062. */
  88063. onNewLightAddedObservable: Observable<Light>;
  88064. /**
  88065. * An event triggered when a light is removed
  88066. */
  88067. onLightRemovedObservable: Observable<Light>;
  88068. /**
  88069. * An event triggered when a geometry is created
  88070. */
  88071. onNewGeometryAddedObservable: Observable<Geometry>;
  88072. /**
  88073. * An event triggered when a geometry is removed
  88074. */
  88075. onGeometryRemovedObservable: Observable<Geometry>;
  88076. /**
  88077. * An event triggered when a transform node is created
  88078. */
  88079. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88080. /**
  88081. * An event triggered when a transform node is removed
  88082. */
  88083. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88084. /**
  88085. * An event triggered when a mesh is created
  88086. */
  88087. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88088. /**
  88089. * An event triggered when a mesh is removed
  88090. */
  88091. onMeshRemovedObservable: Observable<AbstractMesh>;
  88092. /**
  88093. * An event triggered when a material is created
  88094. */
  88095. onNewMaterialAddedObservable: Observable<Material>;
  88096. /**
  88097. * An event triggered when a material is removed
  88098. */
  88099. onMaterialRemovedObservable: Observable<Material>;
  88100. /**
  88101. * An event triggered when a texture is created
  88102. */
  88103. onNewTextureAddedObservable: Observable<BaseTexture>;
  88104. /**
  88105. * An event triggered when a texture is removed
  88106. */
  88107. onTextureRemovedObservable: Observable<BaseTexture>;
  88108. /**
  88109. * An event triggered when render targets are about to be rendered
  88110. * Can happen multiple times per frame.
  88111. */
  88112. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88113. /**
  88114. * An event triggered when render targets were rendered.
  88115. * Can happen multiple times per frame.
  88116. */
  88117. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88118. /**
  88119. * An event triggered before calculating deterministic simulation step
  88120. */
  88121. onBeforeStepObservable: Observable<Scene>;
  88122. /**
  88123. * An event triggered after calculating deterministic simulation step
  88124. */
  88125. onAfterStepObservable: Observable<Scene>;
  88126. /**
  88127. * An event triggered when the activeCamera property is updated
  88128. */
  88129. onActiveCameraChanged: Observable<Scene>;
  88130. /**
  88131. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88132. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88133. * 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)
  88134. */
  88135. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88136. /**
  88137. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88138. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88139. * 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)
  88140. */
  88141. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88142. /**
  88143. * This Observable will when a mesh has been imported into the scene.
  88144. */
  88145. onMeshImportedObservable: Observable<AbstractMesh>;
  88146. /** @hidden */
  88147. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88148. /**
  88149. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88150. */
  88151. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88152. /**
  88153. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88154. */
  88155. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88156. /**
  88157. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88158. */
  88159. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88160. private _onPointerMove;
  88161. private _onPointerDown;
  88162. private _onPointerUp;
  88163. /** Callback called when a pointer move is detected */
  88164. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88165. /** Callback called when a pointer down is detected */
  88166. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88167. /** Callback called when a pointer up is detected */
  88168. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88169. /** Callback called when a pointer pick is detected */
  88170. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88171. /**
  88172. * 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).
  88173. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88174. */
  88175. onPrePointerObservable: Observable<PointerInfoPre>;
  88176. /**
  88177. * Observable event triggered each time an input event is received from the rendering canvas
  88178. */
  88179. onPointerObservable: Observable<PointerInfo>;
  88180. /**
  88181. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88182. */
  88183. readonly unTranslatedPointer: Vector2;
  88184. /** The distance in pixel that you have to move to prevent some events */
  88185. static DragMovementThreshold: number;
  88186. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88187. static LongPressDelay: number;
  88188. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88189. static DoubleClickDelay: number;
  88190. /** If you need to check double click without raising a single click at first click, enable this flag */
  88191. static ExclusiveDoubleClickMode: boolean;
  88192. private _initClickEvent;
  88193. private _initActionManager;
  88194. private _delayedSimpleClick;
  88195. private _delayedSimpleClickTimeout;
  88196. private _previousDelayedSimpleClickTimeout;
  88197. private _meshPickProceed;
  88198. private _previousButtonPressed;
  88199. private _currentPickResult;
  88200. private _previousPickResult;
  88201. private _totalPointersPressed;
  88202. private _doubleClickOccured;
  88203. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88204. cameraToUseForPointers: Nullable<Camera>;
  88205. private _pointerX;
  88206. private _pointerY;
  88207. private _unTranslatedPointerX;
  88208. private _unTranslatedPointerY;
  88209. private _startingPointerPosition;
  88210. private _previousStartingPointerPosition;
  88211. private _startingPointerTime;
  88212. private _previousStartingPointerTime;
  88213. private _pointerCaptures;
  88214. private _timeAccumulator;
  88215. private _currentStepId;
  88216. private _currentInternalStep;
  88217. /** @hidden */
  88218. _mirroredCameraPosition: Nullable<Vector3>;
  88219. /**
  88220. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88221. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88222. */
  88223. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88224. /**
  88225. * Observable event triggered each time an keyboard event is received from the hosting window
  88226. */
  88227. onKeyboardObservable: Observable<KeyboardInfo>;
  88228. private _onKeyDown;
  88229. private _onKeyUp;
  88230. private _onCanvasFocusObserver;
  88231. private _onCanvasBlurObserver;
  88232. private _useRightHandedSystem;
  88233. /**
  88234. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88235. */
  88236. useRightHandedSystem: boolean;
  88237. /**
  88238. * Sets the step Id used by deterministic lock step
  88239. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88240. * @param newStepId defines the step Id
  88241. */
  88242. setStepId(newStepId: number): void;
  88243. /**
  88244. * Gets the step Id used by deterministic lock step
  88245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88246. * @returns the step Id
  88247. */
  88248. getStepId(): number;
  88249. /**
  88250. * Gets the internal step used by deterministic lock step
  88251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88252. * @returns the internal step
  88253. */
  88254. getInternalStep(): number;
  88255. private _fogEnabled;
  88256. /**
  88257. * Gets or sets a boolean indicating if fog is enabled on this scene
  88258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88259. * (Default is true)
  88260. */
  88261. fogEnabled: boolean;
  88262. private _fogMode;
  88263. /**
  88264. * Gets or sets the fog mode to use
  88265. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88266. * | mode | value |
  88267. * | --- | --- |
  88268. * | FOGMODE_NONE | 0 |
  88269. * | FOGMODE_EXP | 1 |
  88270. * | FOGMODE_EXP2 | 2 |
  88271. * | FOGMODE_LINEAR | 3 |
  88272. */
  88273. fogMode: number;
  88274. /**
  88275. * Gets or sets the fog color to use
  88276. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88277. * (Default is Color3(0.2, 0.2, 0.3))
  88278. */
  88279. fogColor: Color3;
  88280. /**
  88281. * Gets or sets the fog density to use
  88282. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88283. * (Default is 0.1)
  88284. */
  88285. fogDensity: number;
  88286. /**
  88287. * Gets or sets the fog start distance to use
  88288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88289. * (Default is 0)
  88290. */
  88291. fogStart: number;
  88292. /**
  88293. * Gets or sets the fog end distance to use
  88294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88295. * (Default is 1000)
  88296. */
  88297. fogEnd: number;
  88298. private _shadowsEnabled;
  88299. /**
  88300. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88301. */
  88302. shadowsEnabled: boolean;
  88303. private _lightsEnabled;
  88304. /**
  88305. * Gets or sets a boolean indicating if lights are enabled on this scene
  88306. */
  88307. lightsEnabled: boolean;
  88308. /** All of the active cameras added to this scene. */
  88309. activeCameras: Camera[];
  88310. private _activeCamera;
  88311. /** Gets or sets the current active camera */
  88312. activeCamera: Nullable<Camera>;
  88313. private _defaultMaterial;
  88314. /** The default material used on meshes when no material is affected */
  88315. /** The default material used on meshes when no material is affected */
  88316. defaultMaterial: Material;
  88317. private _texturesEnabled;
  88318. /**
  88319. * Gets or sets a boolean indicating if textures are enabled on this scene
  88320. */
  88321. texturesEnabled: boolean;
  88322. /**
  88323. * Gets or sets a boolean indicating if particles are enabled on this scene
  88324. */
  88325. particlesEnabled: boolean;
  88326. /**
  88327. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88328. */
  88329. spritesEnabled: boolean;
  88330. private _skeletonsEnabled;
  88331. /**
  88332. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88333. */
  88334. skeletonsEnabled: boolean;
  88335. /**
  88336. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88337. */
  88338. lensFlaresEnabled: boolean;
  88339. /**
  88340. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88342. */
  88343. collisionsEnabled: boolean;
  88344. private _collisionCoordinator;
  88345. /** @hidden */
  88346. readonly collisionCoordinator: ICollisionCoordinator;
  88347. /**
  88348. * Defines the gravity applied to this scene (used only for collisions)
  88349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88350. */
  88351. gravity: Vector3;
  88352. /**
  88353. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88354. */
  88355. postProcessesEnabled: boolean;
  88356. /**
  88357. * The list of postprocesses added to the scene
  88358. */
  88359. postProcesses: PostProcess[];
  88360. /**
  88361. * Gets the current postprocess manager
  88362. */
  88363. postProcessManager: PostProcessManager;
  88364. /**
  88365. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88366. */
  88367. renderTargetsEnabled: boolean;
  88368. /**
  88369. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88370. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88371. */
  88372. dumpNextRenderTargets: boolean;
  88373. /**
  88374. * The list of user defined render targets added to the scene
  88375. */
  88376. customRenderTargets: RenderTargetTexture[];
  88377. /**
  88378. * Defines if texture loading must be delayed
  88379. * If true, textures will only be loaded when they need to be rendered
  88380. */
  88381. useDelayedTextureLoading: boolean;
  88382. /**
  88383. * Gets the list of meshes imported to the scene through SceneLoader
  88384. */
  88385. importedMeshesFiles: String[];
  88386. /**
  88387. * Gets or sets a boolean indicating if probes are enabled on this scene
  88388. */
  88389. probesEnabled: boolean;
  88390. /**
  88391. * Gets or sets the current offline provider to use to store scene data
  88392. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88393. */
  88394. offlineProvider: IOfflineProvider;
  88395. /**
  88396. * Gets or sets the action manager associated with the scene
  88397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88398. */
  88399. actionManager: AbstractActionManager;
  88400. private _meshesForIntersections;
  88401. /**
  88402. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88403. */
  88404. proceduralTexturesEnabled: boolean;
  88405. private _engine;
  88406. private _totalVertices;
  88407. /** @hidden */
  88408. _activeIndices: PerfCounter;
  88409. /** @hidden */
  88410. _activeParticles: PerfCounter;
  88411. /** @hidden */
  88412. _activeBones: PerfCounter;
  88413. private _animationRatio;
  88414. /** @hidden */
  88415. _animationTimeLast: number;
  88416. /** @hidden */
  88417. _animationTime: number;
  88418. /**
  88419. * Gets or sets a general scale for animation speed
  88420. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88421. */
  88422. animationTimeScale: number;
  88423. /** @hidden */
  88424. _cachedMaterial: Nullable<Material>;
  88425. /** @hidden */
  88426. _cachedEffect: Nullable<Effect>;
  88427. /** @hidden */
  88428. _cachedVisibility: Nullable<number>;
  88429. private _renderId;
  88430. private _frameId;
  88431. private _executeWhenReadyTimeoutId;
  88432. private _intermediateRendering;
  88433. private _viewUpdateFlag;
  88434. private _projectionUpdateFlag;
  88435. private _alternateViewUpdateFlag;
  88436. private _alternateProjectionUpdateFlag;
  88437. /** @hidden */
  88438. _toBeDisposed: Nullable<IDisposable>[];
  88439. private _activeRequests;
  88440. /** @hidden */
  88441. _pendingData: any[];
  88442. private _isDisposed;
  88443. /**
  88444. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88445. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88446. */
  88447. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88448. private _activeMeshes;
  88449. private _processedMaterials;
  88450. private _renderTargets;
  88451. /** @hidden */
  88452. _activeParticleSystems: SmartArray<IParticleSystem>;
  88453. private _activeSkeletons;
  88454. private _softwareSkinnedMeshes;
  88455. private _renderingManager;
  88456. /** @hidden */
  88457. _activeAnimatables: Animatable[];
  88458. private _transformMatrix;
  88459. private _sceneUbo;
  88460. private _alternateSceneUbo;
  88461. private _viewMatrix;
  88462. private _projectionMatrix;
  88463. private _alternateViewMatrix;
  88464. private _alternateProjectionMatrix;
  88465. private _alternateTransformMatrix;
  88466. private _useAlternateCameraConfiguration;
  88467. private _alternateRendering;
  88468. private _wheelEventName;
  88469. /** @hidden */
  88470. _forcedViewPosition: Nullable<Vector3>;
  88471. /** @hidden */
  88472. readonly _isAlternateRenderingEnabled: boolean;
  88473. private _frustumPlanes;
  88474. /**
  88475. * Gets the list of frustum planes (built from the active camera)
  88476. */
  88477. readonly frustumPlanes: Plane[];
  88478. /**
  88479. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88480. * This is useful if there are more lights that the maximum simulteanous authorized
  88481. */
  88482. requireLightSorting: boolean;
  88483. /** @hidden */
  88484. readonly useMaterialMeshMap: boolean;
  88485. /** @hidden */
  88486. readonly useClonedMeshhMap: boolean;
  88487. private _pointerOverMesh;
  88488. private _pickedDownMesh;
  88489. private _pickedUpMesh;
  88490. private _externalData;
  88491. private _uid;
  88492. /**
  88493. * @hidden
  88494. * Backing store of defined scene components.
  88495. */
  88496. _components: ISceneComponent[];
  88497. /**
  88498. * @hidden
  88499. * Backing store of defined scene components.
  88500. */
  88501. _serializableComponents: ISceneSerializableComponent[];
  88502. /**
  88503. * List of components to register on the next registration step.
  88504. */
  88505. private _transientComponents;
  88506. /**
  88507. * Registers the transient components if needed.
  88508. */
  88509. private _registerTransientComponents;
  88510. /**
  88511. * @hidden
  88512. * Add a component to the scene.
  88513. * Note that the ccomponent could be registered on th next frame if this is called after
  88514. * the register component stage.
  88515. * @param component Defines the component to add to the scene
  88516. */
  88517. _addComponent(component: ISceneComponent): void;
  88518. /**
  88519. * @hidden
  88520. * Gets a component from the scene.
  88521. * @param name defines the name of the component to retrieve
  88522. * @returns the component or null if not present
  88523. */
  88524. _getComponent(name: string): Nullable<ISceneComponent>;
  88525. /**
  88526. * @hidden
  88527. * Defines the actions happening before camera updates.
  88528. */
  88529. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88530. /**
  88531. * @hidden
  88532. * Defines the actions happening before clear the canvas.
  88533. */
  88534. _beforeClearStage: Stage<SimpleStageAction>;
  88535. /**
  88536. * @hidden
  88537. * Defines the actions when collecting render targets for the frame.
  88538. */
  88539. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88540. /**
  88541. * @hidden
  88542. * Defines the actions happening for one camera in the frame.
  88543. */
  88544. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88545. /**
  88546. * @hidden
  88547. * Defines the actions happening during the per mesh ready checks.
  88548. */
  88549. _isReadyForMeshStage: Stage<MeshStageAction>;
  88550. /**
  88551. * @hidden
  88552. * Defines the actions happening before evaluate active mesh checks.
  88553. */
  88554. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88555. /**
  88556. * @hidden
  88557. * Defines the actions happening during the evaluate sub mesh checks.
  88558. */
  88559. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88560. /**
  88561. * @hidden
  88562. * Defines the actions happening during the active mesh stage.
  88563. */
  88564. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88565. /**
  88566. * @hidden
  88567. * Defines the actions happening during the per camera render target step.
  88568. */
  88569. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88570. /**
  88571. * @hidden
  88572. * Defines the actions happening just before the active camera is drawing.
  88573. */
  88574. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88575. /**
  88576. * @hidden
  88577. * Defines the actions happening just before a render target is drawing.
  88578. */
  88579. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88580. /**
  88581. * @hidden
  88582. * Defines the actions happening just before a rendering group is drawing.
  88583. */
  88584. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88585. /**
  88586. * @hidden
  88587. * Defines the actions happening just before a mesh is drawing.
  88588. */
  88589. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88590. /**
  88591. * @hidden
  88592. * Defines the actions happening just after a mesh has been drawn.
  88593. */
  88594. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88595. /**
  88596. * @hidden
  88597. * Defines the actions happening just after a rendering group has been drawn.
  88598. */
  88599. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88600. /**
  88601. * @hidden
  88602. * Defines the actions happening just after the active camera has been drawn.
  88603. */
  88604. _afterCameraDrawStage: Stage<CameraStageAction>;
  88605. /**
  88606. * @hidden
  88607. * Defines the actions happening just after a render target has been drawn.
  88608. */
  88609. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88610. /**
  88611. * @hidden
  88612. * Defines the actions happening just after rendering all cameras and computing intersections.
  88613. */
  88614. _afterRenderStage: Stage<SimpleStageAction>;
  88615. /**
  88616. * @hidden
  88617. * Defines the actions happening when a pointer move event happens.
  88618. */
  88619. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88620. /**
  88621. * @hidden
  88622. * Defines the actions happening when a pointer down event happens.
  88623. */
  88624. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88625. /**
  88626. * @hidden
  88627. * Defines the actions happening when a pointer up event happens.
  88628. */
  88629. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88630. /**
  88631. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88632. */
  88633. private geometriesByUniqueId;
  88634. /**
  88635. * Creates a new Scene
  88636. * @param engine defines the engine to use to render this scene
  88637. * @param options defines the scene options
  88638. */
  88639. constructor(engine: Engine, options?: SceneOptions);
  88640. private _defaultMeshCandidates;
  88641. /**
  88642. * @hidden
  88643. */
  88644. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88645. private _defaultSubMeshCandidates;
  88646. /**
  88647. * @hidden
  88648. */
  88649. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88650. /**
  88651. * Sets the default candidate providers for the scene.
  88652. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88653. * and getCollidingSubMeshCandidates to their default function
  88654. */
  88655. setDefaultCandidateProviders(): void;
  88656. /**
  88657. * Gets the mesh that is currently under the pointer
  88658. */
  88659. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88660. /**
  88661. * Gets or sets the current on-screen X position of the pointer
  88662. */
  88663. pointerX: number;
  88664. /**
  88665. * Gets or sets the current on-screen Y position of the pointer
  88666. */
  88667. pointerY: number;
  88668. /**
  88669. * Gets the cached material (ie. the latest rendered one)
  88670. * @returns the cached material
  88671. */
  88672. getCachedMaterial(): Nullable<Material>;
  88673. /**
  88674. * Gets the cached effect (ie. the latest rendered one)
  88675. * @returns the cached effect
  88676. */
  88677. getCachedEffect(): Nullable<Effect>;
  88678. /**
  88679. * Gets the cached visibility state (ie. the latest rendered one)
  88680. * @returns the cached visibility state
  88681. */
  88682. getCachedVisibility(): Nullable<number>;
  88683. /**
  88684. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88685. * @param material defines the current material
  88686. * @param effect defines the current effect
  88687. * @param visibility defines the current visibility state
  88688. * @returns true if one parameter is not cached
  88689. */
  88690. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88691. /**
  88692. * Gets the engine associated with the scene
  88693. * @returns an Engine
  88694. */
  88695. getEngine(): Engine;
  88696. /**
  88697. * Gets the total number of vertices rendered per frame
  88698. * @returns the total number of vertices rendered per frame
  88699. */
  88700. getTotalVertices(): number;
  88701. /**
  88702. * Gets the performance counter for total vertices
  88703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88704. */
  88705. readonly totalVerticesPerfCounter: PerfCounter;
  88706. /**
  88707. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88708. * @returns the total number of active indices rendered per frame
  88709. */
  88710. getActiveIndices(): number;
  88711. /**
  88712. * Gets the performance counter for active indices
  88713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88714. */
  88715. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88716. /**
  88717. * Gets the total number of active particles rendered per frame
  88718. * @returns the total number of active particles rendered per frame
  88719. */
  88720. getActiveParticles(): number;
  88721. /**
  88722. * Gets the performance counter for active particles
  88723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88724. */
  88725. readonly activeParticlesPerfCounter: PerfCounter;
  88726. /**
  88727. * Gets the total number of active bones rendered per frame
  88728. * @returns the total number of active bones rendered per frame
  88729. */
  88730. getActiveBones(): number;
  88731. /**
  88732. * Gets the performance counter for active bones
  88733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88734. */
  88735. readonly activeBonesPerfCounter: PerfCounter;
  88736. /**
  88737. * Gets the array of active meshes
  88738. * @returns an array of AbstractMesh
  88739. */
  88740. getActiveMeshes(): SmartArray<AbstractMesh>;
  88741. /**
  88742. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88743. * @returns a number
  88744. */
  88745. getAnimationRatio(): number;
  88746. /**
  88747. * Gets an unique Id for the current render phase
  88748. * @returns a number
  88749. */
  88750. getRenderId(): number;
  88751. /**
  88752. * Gets an unique Id for the current frame
  88753. * @returns a number
  88754. */
  88755. getFrameId(): number;
  88756. /** Call this function if you want to manually increment the render Id*/
  88757. incrementRenderId(): void;
  88758. private _updatePointerPosition;
  88759. private _createUbo;
  88760. private _createAlternateUbo;
  88761. private _setRayOnPointerInfo;
  88762. /**
  88763. * Use this method to simulate a pointer move on a mesh
  88764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88767. * @returns the current scene
  88768. */
  88769. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88770. private _processPointerMove;
  88771. private _checkPrePointerObservable;
  88772. /**
  88773. * Use this method to simulate a pointer down on a mesh
  88774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88777. * @returns the current scene
  88778. */
  88779. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88780. private _processPointerDown;
  88781. /**
  88782. * Use this method to simulate a pointer up on a mesh
  88783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88787. * @returns the current scene
  88788. */
  88789. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88790. private _processPointerUp;
  88791. /**
  88792. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88793. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88794. * @returns true if the pointer was captured
  88795. */
  88796. isPointerCaptured(pointerId?: number): boolean;
  88797. /** @hidden */
  88798. _isPointerSwiping(): boolean;
  88799. /**
  88800. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88801. * @param attachUp defines if you want to attach events to pointerup
  88802. * @param attachDown defines if you want to attach events to pointerdown
  88803. * @param attachMove defines if you want to attach events to pointermove
  88804. */
  88805. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88806. /** Detaches all event handlers*/
  88807. detachControl(): void;
  88808. /**
  88809. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88810. * Delay loaded resources are not taking in account
  88811. * @return true if all required resources are ready
  88812. */
  88813. isReady(): boolean;
  88814. /** Resets all cached information relative to material (including effect and visibility) */
  88815. resetCachedMaterial(): void;
  88816. /**
  88817. * Registers a function to be called before every frame render
  88818. * @param func defines the function to register
  88819. */
  88820. registerBeforeRender(func: () => void): void;
  88821. /**
  88822. * Unregisters a function called before every frame render
  88823. * @param func defines the function to unregister
  88824. */
  88825. unregisterBeforeRender(func: () => void): void;
  88826. /**
  88827. * Registers a function to be called after every frame render
  88828. * @param func defines the function to register
  88829. */
  88830. registerAfterRender(func: () => void): void;
  88831. /**
  88832. * Unregisters a function called after every frame render
  88833. * @param func defines the function to unregister
  88834. */
  88835. unregisterAfterRender(func: () => void): void;
  88836. private _executeOnceBeforeRender;
  88837. /**
  88838. * The provided function will run before render once and will be disposed afterwards.
  88839. * A timeout delay can be provided so that the function will be executed in N ms.
  88840. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88841. * @param func The function to be executed.
  88842. * @param timeout optional delay in ms
  88843. */
  88844. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88845. /** @hidden */
  88846. _addPendingData(data: any): void;
  88847. /** @hidden */
  88848. _removePendingData(data: any): void;
  88849. /**
  88850. * Returns the number of items waiting to be loaded
  88851. * @returns the number of items waiting to be loaded
  88852. */
  88853. getWaitingItemsCount(): number;
  88854. /**
  88855. * Returns a boolean indicating if the scene is still loading data
  88856. */
  88857. readonly isLoading: boolean;
  88858. /**
  88859. * Registers a function to be executed when the scene is ready
  88860. * @param {Function} func - the function to be executed
  88861. */
  88862. executeWhenReady(func: () => void): void;
  88863. /**
  88864. * Returns a promise that resolves when the scene is ready
  88865. * @returns A promise that resolves when the scene is ready
  88866. */
  88867. whenReadyAsync(): Promise<void>;
  88868. /** @hidden */
  88869. _checkIsReady(): void;
  88870. /**
  88871. * Gets all animatable attached to the scene
  88872. */
  88873. readonly animatables: Animatable[];
  88874. /**
  88875. * Resets the last animation time frame.
  88876. * Useful to override when animations start running when loading a scene for the first time.
  88877. */
  88878. resetLastAnimationTimeFrame(): void;
  88879. /** @hidden */
  88880. _switchToAlternateCameraConfiguration(active: boolean): void;
  88881. /**
  88882. * Gets the current view matrix
  88883. * @returns a Matrix
  88884. */
  88885. getViewMatrix(): Matrix;
  88886. /**
  88887. * Gets the current projection matrix
  88888. * @returns a Matrix
  88889. */
  88890. getProjectionMatrix(): Matrix;
  88891. /**
  88892. * Gets the current transform matrix
  88893. * @returns a Matrix made of View * Projection
  88894. */
  88895. getTransformMatrix(): Matrix;
  88896. /**
  88897. * Sets the current transform matrix
  88898. * @param view defines the View matrix to use
  88899. * @param projection defines the Projection matrix to use
  88900. */
  88901. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88902. /** @hidden */
  88903. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88904. /**
  88905. * Gets the uniform buffer used to store scene data
  88906. * @returns a UniformBuffer
  88907. */
  88908. getSceneUniformBuffer(): UniformBuffer;
  88909. /**
  88910. * Gets an unique (relatively to the current scene) Id
  88911. * @returns an unique number for the scene
  88912. */
  88913. getUniqueId(): number;
  88914. /**
  88915. * Add a mesh to the list of scene's meshes
  88916. * @param newMesh defines the mesh to add
  88917. * @param recursive if all child meshes should also be added to the scene
  88918. */
  88919. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88920. /**
  88921. * Remove a mesh for the list of scene's meshes
  88922. * @param toRemove defines the mesh to remove
  88923. * @param recursive if all child meshes should also be removed from the scene
  88924. * @returns the index where the mesh was in the mesh list
  88925. */
  88926. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88927. /**
  88928. * Add a transform node to the list of scene's transform nodes
  88929. * @param newTransformNode defines the transform node to add
  88930. */
  88931. addTransformNode(newTransformNode: TransformNode): void;
  88932. /**
  88933. * Remove a transform node for the list of scene's transform nodes
  88934. * @param toRemove defines the transform node to remove
  88935. * @returns the index where the transform node was in the transform node list
  88936. */
  88937. removeTransformNode(toRemove: TransformNode): number;
  88938. /**
  88939. * Remove a skeleton for the list of scene's skeletons
  88940. * @param toRemove defines the skeleton to remove
  88941. * @returns the index where the skeleton was in the skeleton list
  88942. */
  88943. removeSkeleton(toRemove: Skeleton): number;
  88944. /**
  88945. * Remove a morph target for the list of scene's morph targets
  88946. * @param toRemove defines the morph target to remove
  88947. * @returns the index where the morph target was in the morph target list
  88948. */
  88949. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88950. /**
  88951. * Remove a light for the list of scene's lights
  88952. * @param toRemove defines the light to remove
  88953. * @returns the index where the light was in the light list
  88954. */
  88955. removeLight(toRemove: Light): number;
  88956. /**
  88957. * Remove a camera for the list of scene's cameras
  88958. * @param toRemove defines the camera to remove
  88959. * @returns the index where the camera was in the camera list
  88960. */
  88961. removeCamera(toRemove: Camera): number;
  88962. /**
  88963. * Remove a particle system for the list of scene's particle systems
  88964. * @param toRemove defines the particle system to remove
  88965. * @returns the index where the particle system was in the particle system list
  88966. */
  88967. removeParticleSystem(toRemove: IParticleSystem): number;
  88968. /**
  88969. * Remove a animation for the list of scene's animations
  88970. * @param toRemove defines the animation to remove
  88971. * @returns the index where the animation was in the animation list
  88972. */
  88973. removeAnimation(toRemove: Animation): number;
  88974. /**
  88975. * Removes the given animation group from this scene.
  88976. * @param toRemove The animation group to remove
  88977. * @returns The index of the removed animation group
  88978. */
  88979. removeAnimationGroup(toRemove: AnimationGroup): number;
  88980. /**
  88981. * Removes the given multi-material from this scene.
  88982. * @param toRemove The multi-material to remove
  88983. * @returns The index of the removed multi-material
  88984. */
  88985. removeMultiMaterial(toRemove: MultiMaterial): number;
  88986. /**
  88987. * Removes the given material from this scene.
  88988. * @param toRemove The material to remove
  88989. * @returns The index of the removed material
  88990. */
  88991. removeMaterial(toRemove: Material): number;
  88992. /**
  88993. * Removes the given action manager from this scene.
  88994. * @param toRemove The action manager to remove
  88995. * @returns The index of the removed action manager
  88996. */
  88997. removeActionManager(toRemove: AbstractActionManager): number;
  88998. /**
  88999. * Removes the given texture from this scene.
  89000. * @param toRemove The texture to remove
  89001. * @returns The index of the removed texture
  89002. */
  89003. removeTexture(toRemove: BaseTexture): number;
  89004. /**
  89005. * Adds the given light to this scene
  89006. * @param newLight The light to add
  89007. */
  89008. addLight(newLight: Light): void;
  89009. /**
  89010. * Sorts the list list based on light priorities
  89011. */
  89012. sortLightsByPriority(): void;
  89013. /**
  89014. * Adds the given camera to this scene
  89015. * @param newCamera The camera to add
  89016. */
  89017. addCamera(newCamera: Camera): void;
  89018. /**
  89019. * Adds the given skeleton to this scene
  89020. * @param newSkeleton The skeleton to add
  89021. */
  89022. addSkeleton(newSkeleton: Skeleton): void;
  89023. /**
  89024. * Adds the given particle system to this scene
  89025. * @param newParticleSystem The particle system to add
  89026. */
  89027. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89028. /**
  89029. * Adds the given animation to this scene
  89030. * @param newAnimation The animation to add
  89031. */
  89032. addAnimation(newAnimation: Animation): void;
  89033. /**
  89034. * Adds the given animation group to this scene.
  89035. * @param newAnimationGroup The animation group to add
  89036. */
  89037. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89038. /**
  89039. * Adds the given multi-material to this scene
  89040. * @param newMultiMaterial The multi-material to add
  89041. */
  89042. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89043. /**
  89044. * Adds the given material to this scene
  89045. * @param newMaterial The material to add
  89046. */
  89047. addMaterial(newMaterial: Material): void;
  89048. /**
  89049. * Adds the given morph target to this scene
  89050. * @param newMorphTargetManager The morph target to add
  89051. */
  89052. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89053. /**
  89054. * Adds the given geometry to this scene
  89055. * @param newGeometry The geometry to add
  89056. */
  89057. addGeometry(newGeometry: Geometry): void;
  89058. /**
  89059. * Adds the given action manager to this scene
  89060. * @param newActionManager The action manager to add
  89061. */
  89062. addActionManager(newActionManager: AbstractActionManager): void;
  89063. /**
  89064. * Adds the given texture to this scene.
  89065. * @param newTexture The texture to add
  89066. */
  89067. addTexture(newTexture: BaseTexture): void;
  89068. /**
  89069. * Switch active camera
  89070. * @param newCamera defines the new active camera
  89071. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89072. */
  89073. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89074. /**
  89075. * sets the active camera of the scene using its ID
  89076. * @param id defines the camera's ID
  89077. * @return the new active camera or null if none found.
  89078. */
  89079. setActiveCameraByID(id: string): Nullable<Camera>;
  89080. /**
  89081. * sets the active camera of the scene using its name
  89082. * @param name defines the camera's name
  89083. * @returns the new active camera or null if none found.
  89084. */
  89085. setActiveCameraByName(name: string): Nullable<Camera>;
  89086. /**
  89087. * get an animation group using its name
  89088. * @param name defines the material's name
  89089. * @return the animation group or null if none found.
  89090. */
  89091. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89092. /**
  89093. * get a material using its id
  89094. * @param id defines the material's ID
  89095. * @return the material or null if none found.
  89096. */
  89097. getMaterialByID(id: string): Nullable<Material>;
  89098. /**
  89099. * Gets a material using its name
  89100. * @param name defines the material's name
  89101. * @return the material or null if none found.
  89102. */
  89103. getMaterialByName(name: string): Nullable<Material>;
  89104. /**
  89105. * Gets a camera using its id
  89106. * @param id defines the id to look for
  89107. * @returns the camera or null if not found
  89108. */
  89109. getCameraByID(id: string): Nullable<Camera>;
  89110. /**
  89111. * Gets a camera using its unique id
  89112. * @param uniqueId defines the unique id to look for
  89113. * @returns the camera or null if not found
  89114. */
  89115. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89116. /**
  89117. * Gets a camera using its name
  89118. * @param name defines the camera's name
  89119. * @return the camera or null if none found.
  89120. */
  89121. getCameraByName(name: string): Nullable<Camera>;
  89122. /**
  89123. * Gets a bone using its id
  89124. * @param id defines the bone's id
  89125. * @return the bone or null if not found
  89126. */
  89127. getBoneByID(id: string): Nullable<Bone>;
  89128. /**
  89129. * Gets a bone using its id
  89130. * @param name defines the bone's name
  89131. * @return the bone or null if not found
  89132. */
  89133. getBoneByName(name: string): Nullable<Bone>;
  89134. /**
  89135. * Gets a light node using its name
  89136. * @param name defines the the light's name
  89137. * @return the light or null if none found.
  89138. */
  89139. getLightByName(name: string): Nullable<Light>;
  89140. /**
  89141. * Gets a light node using its id
  89142. * @param id defines the light's id
  89143. * @return the light or null if none found.
  89144. */
  89145. getLightByID(id: string): Nullable<Light>;
  89146. /**
  89147. * Gets a light node using its scene-generated unique ID
  89148. * @param uniqueId defines the light's unique id
  89149. * @return the light or null if none found.
  89150. */
  89151. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89152. /**
  89153. * Gets a particle system by id
  89154. * @param id defines the particle system id
  89155. * @return the corresponding system or null if none found
  89156. */
  89157. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89158. /**
  89159. * Gets a geometry using its ID
  89160. * @param id defines the geometry's id
  89161. * @return the geometry or null if none found.
  89162. */
  89163. getGeometryByID(id: string): Nullable<Geometry>;
  89164. private _getGeometryByUniqueID;
  89165. /**
  89166. * Add a new geometry to this scene
  89167. * @param geometry defines the geometry to be added to the scene.
  89168. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89169. * @return a boolean defining if the geometry was added or not
  89170. */
  89171. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89172. /**
  89173. * Removes an existing geometry
  89174. * @param geometry defines the geometry to be removed from the scene
  89175. * @return a boolean defining if the geometry was removed or not
  89176. */
  89177. removeGeometry(geometry: Geometry): boolean;
  89178. /**
  89179. * Gets the list of geometries attached to the scene
  89180. * @returns an array of Geometry
  89181. */
  89182. getGeometries(): Geometry[];
  89183. /**
  89184. * Gets the first added mesh found of a given ID
  89185. * @param id defines the id to search for
  89186. * @return the mesh found or null if not found at all
  89187. */
  89188. getMeshByID(id: string): Nullable<AbstractMesh>;
  89189. /**
  89190. * Gets a list of meshes using their id
  89191. * @param id defines the id to search for
  89192. * @returns a list of meshes
  89193. */
  89194. getMeshesByID(id: string): Array<AbstractMesh>;
  89195. /**
  89196. * Gets the first added transform node found of a given ID
  89197. * @param id defines the id to search for
  89198. * @return the found transform node or null if not found at all.
  89199. */
  89200. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89201. /**
  89202. * Gets a list of transform nodes using their id
  89203. * @param id defines the id to search for
  89204. * @returns a list of transform nodes
  89205. */
  89206. getTransformNodesByID(id: string): Array<TransformNode>;
  89207. /**
  89208. * Gets a mesh with its auto-generated unique id
  89209. * @param uniqueId defines the unique id to search for
  89210. * @return the found mesh or null if not found at all.
  89211. */
  89212. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89213. /**
  89214. * Gets a the last added mesh using a given id
  89215. * @param id defines the id to search for
  89216. * @return the found mesh or null if not found at all.
  89217. */
  89218. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89219. /**
  89220. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89221. * @param id defines the id to search for
  89222. * @return the found node or null if not found at all
  89223. */
  89224. getLastEntryByID(id: string): Nullable<Node>;
  89225. /**
  89226. * Gets a node (Mesh, Camera, Light) using a given id
  89227. * @param id defines the id to search for
  89228. * @return the found node or null if not found at all
  89229. */
  89230. getNodeByID(id: string): Nullable<Node>;
  89231. /**
  89232. * Gets a node (Mesh, Camera, Light) using a given name
  89233. * @param name defines the name to search for
  89234. * @return the found node or null if not found at all.
  89235. */
  89236. getNodeByName(name: string): Nullable<Node>;
  89237. /**
  89238. * Gets a mesh using a given name
  89239. * @param name defines the name to search for
  89240. * @return the found mesh or null if not found at all.
  89241. */
  89242. getMeshByName(name: string): Nullable<AbstractMesh>;
  89243. /**
  89244. * Gets a transform node using a given name
  89245. * @param name defines the name to search for
  89246. * @return the found transform node or null if not found at all.
  89247. */
  89248. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89249. /**
  89250. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89251. * @param id defines the id to search for
  89252. * @return the found skeleton or null if not found at all.
  89253. */
  89254. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89255. /**
  89256. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89257. * @param id defines the id to search for
  89258. * @return the found skeleton or null if not found at all.
  89259. */
  89260. getSkeletonById(id: string): Nullable<Skeleton>;
  89261. /**
  89262. * Gets a skeleton using a given name
  89263. * @param name defines the name to search for
  89264. * @return the found skeleton or null if not found at all.
  89265. */
  89266. getSkeletonByName(name: string): Nullable<Skeleton>;
  89267. /**
  89268. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89269. * @param id defines the id to search for
  89270. * @return the found morph target manager or null if not found at all.
  89271. */
  89272. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89273. /**
  89274. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89275. * @param id defines the id to search for
  89276. * @return the found morph target or null if not found at all.
  89277. */
  89278. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89279. /**
  89280. * Gets a boolean indicating if the given mesh is active
  89281. * @param mesh defines the mesh to look for
  89282. * @returns true if the mesh is in the active list
  89283. */
  89284. isActiveMesh(mesh: AbstractMesh): boolean;
  89285. /**
  89286. * Return a unique id as a string which can serve as an identifier for the scene
  89287. */
  89288. readonly uid: string;
  89289. /**
  89290. * Add an externaly attached data from its key.
  89291. * This method call will fail and return false, if such key already exists.
  89292. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89293. * @param key the unique key that identifies the data
  89294. * @param data the data object to associate to the key for this Engine instance
  89295. * @return true if no such key were already present and the data was added successfully, false otherwise
  89296. */
  89297. addExternalData<T>(key: string, data: T): boolean;
  89298. /**
  89299. * Get an externaly attached data from its key
  89300. * @param key the unique key that identifies the data
  89301. * @return the associated data, if present (can be null), or undefined if not present
  89302. */
  89303. getExternalData<T>(key: string): Nullable<T>;
  89304. /**
  89305. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89306. * @param key the unique key that identifies the data
  89307. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89308. * @return the associated data, can be null if the factory returned null.
  89309. */
  89310. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89311. /**
  89312. * Remove an externaly attached data from the Engine instance
  89313. * @param key the unique key that identifies the data
  89314. * @return true if the data was successfully removed, false if it doesn't exist
  89315. */
  89316. removeExternalData(key: string): boolean;
  89317. private _evaluateSubMesh;
  89318. /**
  89319. * Clear the processed materials smart array preventing retention point in material dispose.
  89320. */
  89321. freeProcessedMaterials(): void;
  89322. private _preventFreeActiveMeshesAndRenderingGroups;
  89323. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89324. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89325. * when disposing several meshes in a row or a hierarchy of meshes.
  89326. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89327. */
  89328. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89329. /**
  89330. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89331. */
  89332. freeActiveMeshes(): void;
  89333. /**
  89334. * Clear the info related to rendering groups preventing retention points during dispose.
  89335. */
  89336. freeRenderingGroups(): void;
  89337. /** @hidden */
  89338. _isInIntermediateRendering(): boolean;
  89339. /**
  89340. * Lambda returning the list of potentially active meshes.
  89341. */
  89342. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89343. /**
  89344. * Lambda returning the list of potentially active sub meshes.
  89345. */
  89346. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89347. /**
  89348. * Lambda returning the list of potentially intersecting sub meshes.
  89349. */
  89350. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89351. /**
  89352. * Lambda returning the list of potentially colliding sub meshes.
  89353. */
  89354. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89355. private _activeMeshesFrozen;
  89356. /**
  89357. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89358. * @returns the current scene
  89359. */
  89360. freezeActiveMeshes(): Scene;
  89361. /**
  89362. * Use this function to restart evaluating active meshes on every frame
  89363. * @returns the current scene
  89364. */
  89365. unfreezeActiveMeshes(): Scene;
  89366. private _evaluateActiveMeshes;
  89367. private _activeMesh;
  89368. /**
  89369. * Update the transform matrix to update from the current active camera
  89370. * @param force defines a boolean used to force the update even if cache is up to date
  89371. */
  89372. updateTransformMatrix(force?: boolean): void;
  89373. /**
  89374. * 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)
  89375. * @param alternateCamera defines the camera to use
  89376. */
  89377. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89378. /** @hidden */
  89379. _allowPostProcessClearColor: boolean;
  89380. private _renderForCamera;
  89381. private _processSubCameras;
  89382. private _checkIntersections;
  89383. /** @hidden */
  89384. _advancePhysicsEngineStep(step: number): void;
  89385. /**
  89386. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89387. */
  89388. getDeterministicFrameTime: () => number;
  89389. /** @hidden */
  89390. _animate(): void;
  89391. /**
  89392. * Render the scene
  89393. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89394. */
  89395. render(updateCameras?: boolean): void;
  89396. /**
  89397. * Freeze all materials
  89398. * A frozen material will not be updatable but should be faster to render
  89399. */
  89400. freezeMaterials(): void;
  89401. /**
  89402. * Unfreeze all materials
  89403. * A frozen material will not be updatable but should be faster to render
  89404. */
  89405. unfreezeMaterials(): void;
  89406. /**
  89407. * Releases all held ressources
  89408. */
  89409. dispose(): void;
  89410. /**
  89411. * Gets if the scene is already disposed
  89412. */
  89413. readonly isDisposed: boolean;
  89414. /**
  89415. * Call this function to reduce memory footprint of the scene.
  89416. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89417. */
  89418. clearCachedVertexData(): void;
  89419. /**
  89420. * This function will remove the local cached buffer data from texture.
  89421. * It will save memory but will prevent the texture from being rebuilt
  89422. */
  89423. cleanCachedTextureBuffer(): void;
  89424. /**
  89425. * Get the world extend vectors with an optional filter
  89426. *
  89427. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89428. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89429. */
  89430. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89431. min: Vector3;
  89432. max: Vector3;
  89433. };
  89434. /**
  89435. * Creates a ray that can be used to pick in the scene
  89436. * @param x defines the x coordinate of the origin (on-screen)
  89437. * @param y defines the y coordinate of the origin (on-screen)
  89438. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89439. * @param camera defines the camera to use for the picking
  89440. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89441. * @returns a Ray
  89442. */
  89443. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89444. /**
  89445. * Creates a ray that can be used to pick in the scene
  89446. * @param x defines the x coordinate of the origin (on-screen)
  89447. * @param y defines the y coordinate of the origin (on-screen)
  89448. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89449. * @param result defines the ray where to store the picking ray
  89450. * @param camera defines the camera to use for the picking
  89451. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89452. * @returns the current scene
  89453. */
  89454. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89455. /**
  89456. * Creates a ray that can be used to pick in the scene
  89457. * @param x defines the x coordinate of the origin (on-screen)
  89458. * @param y defines the y coordinate of the origin (on-screen)
  89459. * @param camera defines the camera to use for the picking
  89460. * @returns a Ray
  89461. */
  89462. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89463. /**
  89464. * Creates a ray that can be used to pick in the scene
  89465. * @param x defines the x coordinate of the origin (on-screen)
  89466. * @param y defines the y coordinate of the origin (on-screen)
  89467. * @param result defines the ray where to store the picking ray
  89468. * @param camera defines the camera to use for the picking
  89469. * @returns the current scene
  89470. */
  89471. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89472. /** Launch a ray to try to pick a mesh in the scene
  89473. * @param x position on screen
  89474. * @param y position on screen
  89475. * @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
  89476. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89477. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89478. * @returns a PickingInfo
  89479. */
  89480. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89481. /** Use the given ray to pick a mesh in the scene
  89482. * @param ray The ray to use to pick meshes
  89483. * @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
  89484. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89485. * @returns a PickingInfo
  89486. */
  89487. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89488. /**
  89489. * Launch a ray to try to pick a mesh in the scene
  89490. * @param x X position on screen
  89491. * @param y Y position on screen
  89492. * @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
  89493. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89494. * @returns an array of PickingInfo
  89495. */
  89496. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89497. /**
  89498. * Launch a ray to try to pick a mesh in the scene
  89499. * @param ray Ray to use
  89500. * @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
  89501. * @returns an array of PickingInfo
  89502. */
  89503. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89504. /**
  89505. * Force the value of meshUnderPointer
  89506. * @param mesh defines the mesh to use
  89507. */
  89508. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89509. /**
  89510. * Gets the mesh under the pointer
  89511. * @returns a Mesh or null if no mesh is under the pointer
  89512. */
  89513. getPointerOverMesh(): Nullable<AbstractMesh>;
  89514. /** @hidden */
  89515. _rebuildGeometries(): void;
  89516. /** @hidden */
  89517. _rebuildTextures(): void;
  89518. private _getByTags;
  89519. /**
  89520. * Get a list of meshes by tags
  89521. * @param tagsQuery defines the tags query to use
  89522. * @param forEach defines a predicate used to filter results
  89523. * @returns an array of Mesh
  89524. */
  89525. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89526. /**
  89527. * Get a list of cameras by tags
  89528. * @param tagsQuery defines the tags query to use
  89529. * @param forEach defines a predicate used to filter results
  89530. * @returns an array of Camera
  89531. */
  89532. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89533. /**
  89534. * Get a list of lights by tags
  89535. * @param tagsQuery defines the tags query to use
  89536. * @param forEach defines a predicate used to filter results
  89537. * @returns an array of Light
  89538. */
  89539. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89540. /**
  89541. * Get a list of materials by tags
  89542. * @param tagsQuery defines the tags query to use
  89543. * @param forEach defines a predicate used to filter results
  89544. * @returns an array of Material
  89545. */
  89546. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89547. /**
  89548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89549. * This allowed control for front to back rendering or reversly depending of the special needs.
  89550. *
  89551. * @param renderingGroupId The rendering group id corresponding to its index
  89552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89555. */
  89556. 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;
  89557. /**
  89558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89559. *
  89560. * @param renderingGroupId The rendering group id corresponding to its index
  89561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89564. */
  89565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89566. /**
  89567. * Gets the current auto clear configuration for one rendering group of the rendering
  89568. * manager.
  89569. * @param index the rendering group index to get the information for
  89570. * @returns The auto clear setup for the requested rendering group
  89571. */
  89572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89573. private _blockMaterialDirtyMechanism;
  89574. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89575. blockMaterialDirtyMechanism: boolean;
  89576. /**
  89577. * Will flag all materials as dirty to trigger new shader compilation
  89578. * @param flag defines the flag used to specify which material part must be marked as dirty
  89579. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89580. */
  89581. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89582. /** @hidden */
  89583. _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;
  89584. /** @hidden */
  89585. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89586. }
  89587. }
  89588. declare module BABYLON {
  89589. /**
  89590. * Set of assets to keep when moving a scene into an asset container.
  89591. */
  89592. export class KeepAssets extends AbstractScene {
  89593. }
  89594. /**
  89595. * Container with a set of assets that can be added or removed from a scene.
  89596. */
  89597. export class AssetContainer extends AbstractScene {
  89598. /**
  89599. * The scene the AssetContainer belongs to.
  89600. */
  89601. scene: Scene;
  89602. /**
  89603. * Instantiates an AssetContainer.
  89604. * @param scene The scene the AssetContainer belongs to.
  89605. */
  89606. constructor(scene: Scene);
  89607. /**
  89608. * Adds all the assets from the container to the scene.
  89609. */
  89610. addAllToScene(): void;
  89611. /**
  89612. * Removes all the assets in the container from the scene
  89613. */
  89614. removeAllFromScene(): void;
  89615. /**
  89616. * Disposes all the assets in the container
  89617. */
  89618. dispose(): void;
  89619. private _moveAssets;
  89620. /**
  89621. * Removes all the assets contained in the scene and adds them to the container.
  89622. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89623. */
  89624. moveAllFromScene(keepAssets?: KeepAssets): void;
  89625. /**
  89626. * 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.
  89627. * @returns the root mesh
  89628. */
  89629. createRootMesh(): Mesh;
  89630. }
  89631. }
  89632. declare module BABYLON {
  89633. /**
  89634. * Defines how the parser contract is defined.
  89635. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89636. */
  89637. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89638. /**
  89639. * Defines how the individual parser contract is defined.
  89640. * These parser can parse an individual asset
  89641. */
  89642. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89643. /**
  89644. * Base class of the scene acting as a container for the different elements composing a scene.
  89645. * This class is dynamically extended by the different components of the scene increasing
  89646. * flexibility and reducing coupling
  89647. */
  89648. export abstract class AbstractScene {
  89649. /**
  89650. * Stores the list of available parsers in the application.
  89651. */
  89652. private static _BabylonFileParsers;
  89653. /**
  89654. * Stores the list of available individual parsers in the application.
  89655. */
  89656. private static _IndividualBabylonFileParsers;
  89657. /**
  89658. * Adds a parser in the list of available ones
  89659. * @param name Defines the name of the parser
  89660. * @param parser Defines the parser to add
  89661. */
  89662. static AddParser(name: string, parser: BabylonFileParser): void;
  89663. /**
  89664. * Gets a general parser from the list of avaialble ones
  89665. * @param name Defines the name of the parser
  89666. * @returns the requested parser or null
  89667. */
  89668. static GetParser(name: string): Nullable<BabylonFileParser>;
  89669. /**
  89670. * Adds n individual parser in the list of available ones
  89671. * @param name Defines the name of the parser
  89672. * @param parser Defines the parser to add
  89673. */
  89674. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89675. /**
  89676. * Gets an individual parser from the list of avaialble ones
  89677. * @param name Defines the name of the parser
  89678. * @returns the requested parser or null
  89679. */
  89680. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89681. /**
  89682. * Parser json data and populate both a scene and its associated container object
  89683. * @param jsonData Defines the data to parse
  89684. * @param scene Defines the scene to parse the data for
  89685. * @param container Defines the container attached to the parsing sequence
  89686. * @param rootUrl Defines the root url of the data
  89687. */
  89688. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89689. /**
  89690. * Gets the list of root nodes (ie. nodes with no parent)
  89691. */
  89692. rootNodes: Node[];
  89693. /** All of the cameras added to this scene
  89694. * @see http://doc.babylonjs.com/babylon101/cameras
  89695. */
  89696. cameras: Camera[];
  89697. /**
  89698. * All of the lights added to this scene
  89699. * @see http://doc.babylonjs.com/babylon101/lights
  89700. */
  89701. lights: Light[];
  89702. /**
  89703. * All of the (abstract) meshes added to this scene
  89704. */
  89705. meshes: AbstractMesh[];
  89706. /**
  89707. * The list of skeletons added to the scene
  89708. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89709. */
  89710. skeletons: Skeleton[];
  89711. /**
  89712. * All of the particle systems added to this scene
  89713. * @see http://doc.babylonjs.com/babylon101/particles
  89714. */
  89715. particleSystems: IParticleSystem[];
  89716. /**
  89717. * Gets a list of Animations associated with the scene
  89718. */
  89719. animations: Animation[];
  89720. /**
  89721. * All of the animation groups added to this scene
  89722. * @see http://doc.babylonjs.com/how_to/group
  89723. */
  89724. animationGroups: AnimationGroup[];
  89725. /**
  89726. * All of the multi-materials added to this scene
  89727. * @see http://doc.babylonjs.com/how_to/multi_materials
  89728. */
  89729. multiMaterials: MultiMaterial[];
  89730. /**
  89731. * All of the materials added to this scene
  89732. * In the context of a Scene, it is not supposed to be modified manually.
  89733. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89734. * Note also that the order of the Material wihin the array is not significant and might change.
  89735. * @see http://doc.babylonjs.com/babylon101/materials
  89736. */
  89737. materials: Material[];
  89738. /**
  89739. * The list of morph target managers added to the scene
  89740. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89741. */
  89742. morphTargetManagers: MorphTargetManager[];
  89743. /**
  89744. * The list of geometries used in the scene.
  89745. */
  89746. geometries: Geometry[];
  89747. /**
  89748. * All of the tranform nodes added to this scene
  89749. * In the context of a Scene, it is not supposed to be modified manually.
  89750. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89751. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89752. * @see http://doc.babylonjs.com/how_to/transformnode
  89753. */
  89754. transformNodes: TransformNode[];
  89755. /**
  89756. * ActionManagers available on the scene.
  89757. */
  89758. actionManagers: AbstractActionManager[];
  89759. /**
  89760. * Textures to keep.
  89761. */
  89762. textures: BaseTexture[];
  89763. }
  89764. }
  89765. declare module BABYLON {
  89766. /**
  89767. * Defines a sound that can be played in the application.
  89768. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89770. */
  89771. export class Sound {
  89772. /**
  89773. * The name of the sound in the scene.
  89774. */
  89775. name: string;
  89776. /**
  89777. * Does the sound autoplay once loaded.
  89778. */
  89779. autoplay: boolean;
  89780. /**
  89781. * Does the sound loop after it finishes playing once.
  89782. */
  89783. loop: boolean;
  89784. /**
  89785. * Does the sound use a custom attenuation curve to simulate the falloff
  89786. * happening when the source gets further away from the camera.
  89787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89788. */
  89789. useCustomAttenuation: boolean;
  89790. /**
  89791. * The sound track id this sound belongs to.
  89792. */
  89793. soundTrackId: number;
  89794. /**
  89795. * Is this sound currently played.
  89796. */
  89797. isPlaying: boolean;
  89798. /**
  89799. * Is this sound currently paused.
  89800. */
  89801. isPaused: boolean;
  89802. /**
  89803. * Does this sound enables spatial sound.
  89804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89805. */
  89806. spatialSound: boolean;
  89807. /**
  89808. * Define the reference distance the sound should be heard perfectly.
  89809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89810. */
  89811. refDistance: number;
  89812. /**
  89813. * Define the roll off factor of spatial sounds.
  89814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89815. */
  89816. rolloffFactor: number;
  89817. /**
  89818. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89820. */
  89821. maxDistance: number;
  89822. /**
  89823. * Define the distance attenuation model the sound will follow.
  89824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89825. */
  89826. distanceModel: string;
  89827. /**
  89828. * @hidden
  89829. * Back Compat
  89830. **/
  89831. onended: () => any;
  89832. /**
  89833. * Observable event when the current playing sound finishes.
  89834. */
  89835. onEndedObservable: Observable<Sound>;
  89836. private _panningModel;
  89837. private _playbackRate;
  89838. private _streaming;
  89839. private _startTime;
  89840. private _startOffset;
  89841. private _position;
  89842. /** @hidden */
  89843. _positionInEmitterSpace: boolean;
  89844. private _localDirection;
  89845. private _volume;
  89846. private _isReadyToPlay;
  89847. private _isDirectional;
  89848. private _readyToPlayCallback;
  89849. private _audioBuffer;
  89850. private _soundSource;
  89851. private _streamingSource;
  89852. private _soundPanner;
  89853. private _soundGain;
  89854. private _inputAudioNode;
  89855. private _outputAudioNode;
  89856. private _coneInnerAngle;
  89857. private _coneOuterAngle;
  89858. private _coneOuterGain;
  89859. private _scene;
  89860. private _connectedTransformNode;
  89861. private _customAttenuationFunction;
  89862. private _registerFunc;
  89863. private _isOutputConnected;
  89864. private _htmlAudioElement;
  89865. private _urlType;
  89866. /** @hidden */
  89867. static _SceneComponentInitialization: (scene: Scene) => void;
  89868. /**
  89869. * Create a sound and attach it to a scene
  89870. * @param name Name of your sound
  89871. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89872. * @param scene defines the scene the sound belongs to
  89873. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89874. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89875. */
  89876. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89877. /**
  89878. * Release the sound and its associated resources
  89879. */
  89880. dispose(): void;
  89881. /**
  89882. * Gets if the sounds is ready to be played or not.
  89883. * @returns true if ready, otherwise false
  89884. */
  89885. isReady(): boolean;
  89886. private _soundLoaded;
  89887. /**
  89888. * Sets the data of the sound from an audiobuffer
  89889. * @param audioBuffer The audioBuffer containing the data
  89890. */
  89891. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89892. /**
  89893. * Updates the current sounds options such as maxdistance, loop...
  89894. * @param options A JSON object containing values named as the object properties
  89895. */
  89896. updateOptions(options: any): void;
  89897. private _createSpatialParameters;
  89898. private _updateSpatialParameters;
  89899. /**
  89900. * Switch the panning model to HRTF:
  89901. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89903. */
  89904. switchPanningModelToHRTF(): void;
  89905. /**
  89906. * Switch the panning model to Equal Power:
  89907. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89909. */
  89910. switchPanningModelToEqualPower(): void;
  89911. private _switchPanningModel;
  89912. /**
  89913. * Connect this sound to a sound track audio node like gain...
  89914. * @param soundTrackAudioNode the sound track audio node to connect to
  89915. */
  89916. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89917. /**
  89918. * Transform this sound into a directional source
  89919. * @param coneInnerAngle Size of the inner cone in degree
  89920. * @param coneOuterAngle Size of the outer cone in degree
  89921. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89922. */
  89923. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89924. /**
  89925. * Gets or sets the inner angle for the directional cone.
  89926. */
  89927. /**
  89928. * Gets or sets the inner angle for the directional cone.
  89929. */
  89930. directionalConeInnerAngle: number;
  89931. /**
  89932. * Gets or sets the outer angle for the directional cone.
  89933. */
  89934. /**
  89935. * Gets or sets the outer angle for the directional cone.
  89936. */
  89937. directionalConeOuterAngle: number;
  89938. /**
  89939. * Sets the position of the emitter if spatial sound is enabled
  89940. * @param newPosition Defines the new posisiton
  89941. */
  89942. setPosition(newPosition: Vector3): void;
  89943. /**
  89944. * Sets the local direction of the emitter if spatial sound is enabled
  89945. * @param newLocalDirection Defines the new local direction
  89946. */
  89947. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89948. private _updateDirection;
  89949. /** @hidden */
  89950. updateDistanceFromListener(): void;
  89951. /**
  89952. * Sets a new custom attenuation function for the sound.
  89953. * @param callback Defines the function used for the attenuation
  89954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89955. */
  89956. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89957. /**
  89958. * Play the sound
  89959. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89960. * @param offset (optional) Start the sound setting it at a specific time
  89961. */
  89962. play(time?: number, offset?: number): void;
  89963. private _onended;
  89964. /**
  89965. * Stop the sound
  89966. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89967. */
  89968. stop(time?: number): void;
  89969. /**
  89970. * Put the sound in pause
  89971. */
  89972. pause(): void;
  89973. /**
  89974. * Sets a dedicated volume for this sounds
  89975. * @param newVolume Define the new volume of the sound
  89976. * @param time Define in how long the sound should be at this value
  89977. */
  89978. setVolume(newVolume: number, time?: number): void;
  89979. /**
  89980. * Set the sound play back rate
  89981. * @param newPlaybackRate Define the playback rate the sound should be played at
  89982. */
  89983. setPlaybackRate(newPlaybackRate: number): void;
  89984. /**
  89985. * Gets the volume of the sound.
  89986. * @returns the volume of the sound
  89987. */
  89988. getVolume(): number;
  89989. /**
  89990. * Attach the sound to a dedicated mesh
  89991. * @param transformNode The transform node to connect the sound with
  89992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89993. */
  89994. attachToMesh(transformNode: TransformNode): void;
  89995. /**
  89996. * Detach the sound from the previously attached mesh
  89997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89998. */
  89999. detachFromMesh(): void;
  90000. private _onRegisterAfterWorldMatrixUpdate;
  90001. /**
  90002. * Clone the current sound in the scene.
  90003. * @returns the new sound clone
  90004. */
  90005. clone(): Nullable<Sound>;
  90006. /**
  90007. * Gets the current underlying audio buffer containing the data
  90008. * @returns the audio buffer
  90009. */
  90010. getAudioBuffer(): Nullable<AudioBuffer>;
  90011. /**
  90012. * Serializes the Sound in a JSON representation
  90013. * @returns the JSON representation of the sound
  90014. */
  90015. serialize(): any;
  90016. /**
  90017. * Parse a JSON representation of a sound to innstantiate in a given scene
  90018. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90019. * @param scene Define the scene the new parsed sound should be created in
  90020. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90021. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90022. * @returns the newly parsed sound
  90023. */
  90024. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90025. }
  90026. }
  90027. declare module BABYLON {
  90028. /**
  90029. * This defines an action helpful to play a defined sound on a triggered action.
  90030. */
  90031. export class PlaySoundAction extends Action {
  90032. private _sound;
  90033. /**
  90034. * Instantiate the action
  90035. * @param triggerOptions defines the trigger options
  90036. * @param sound defines the sound to play
  90037. * @param condition defines the trigger related conditions
  90038. */
  90039. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90040. /** @hidden */
  90041. _prepare(): void;
  90042. /**
  90043. * Execute the action and play the sound.
  90044. */
  90045. execute(): void;
  90046. /**
  90047. * Serializes the actions and its related information.
  90048. * @param parent defines the object to serialize in
  90049. * @returns the serialized object
  90050. */
  90051. serialize(parent: any): any;
  90052. }
  90053. /**
  90054. * This defines an action helpful to stop a defined sound on a triggered action.
  90055. */
  90056. export class StopSoundAction extends Action {
  90057. private _sound;
  90058. /**
  90059. * Instantiate the action
  90060. * @param triggerOptions defines the trigger options
  90061. * @param sound defines the sound to stop
  90062. * @param condition defines the trigger related conditions
  90063. */
  90064. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90065. /** @hidden */
  90066. _prepare(): void;
  90067. /**
  90068. * Execute the action and stop the sound.
  90069. */
  90070. execute(): void;
  90071. /**
  90072. * Serializes the actions and its related information.
  90073. * @param parent defines the object to serialize in
  90074. * @returns the serialized object
  90075. */
  90076. serialize(parent: any): any;
  90077. }
  90078. }
  90079. declare module BABYLON {
  90080. /**
  90081. * This defines an action responsible to change the value of a property
  90082. * by interpolating between its current value and the newly set one once triggered.
  90083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90084. */
  90085. export class InterpolateValueAction extends Action {
  90086. /**
  90087. * Defines the path of the property where the value should be interpolated
  90088. */
  90089. propertyPath: string;
  90090. /**
  90091. * Defines the target value at the end of the interpolation.
  90092. */
  90093. value: any;
  90094. /**
  90095. * Defines the time it will take for the property to interpolate to the value.
  90096. */
  90097. duration: number;
  90098. /**
  90099. * Defines if the other scene animations should be stopped when the action has been triggered
  90100. */
  90101. stopOtherAnimations?: boolean;
  90102. /**
  90103. * Defines a callback raised once the interpolation animation has been done.
  90104. */
  90105. onInterpolationDone?: () => void;
  90106. /**
  90107. * Observable triggered once the interpolation animation has been done.
  90108. */
  90109. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90110. private _target;
  90111. private _effectiveTarget;
  90112. private _property;
  90113. /**
  90114. * Instantiate the action
  90115. * @param triggerOptions defines the trigger options
  90116. * @param target defines the object containing the value to interpolate
  90117. * @param propertyPath defines the path to the property in the target object
  90118. * @param value defines the target value at the end of the interpolation
  90119. * @param duration deines the time it will take for the property to interpolate to the value.
  90120. * @param condition defines the trigger related conditions
  90121. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90122. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90123. */
  90124. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90125. /** @hidden */
  90126. _prepare(): void;
  90127. /**
  90128. * Execute the action starts the value interpolation.
  90129. */
  90130. execute(): void;
  90131. /**
  90132. * Serializes the actions and its related information.
  90133. * @param parent defines the object to serialize in
  90134. * @returns the serialized object
  90135. */
  90136. serialize(parent: any): any;
  90137. }
  90138. }
  90139. declare module BABYLON {
  90140. /**
  90141. * Options allowed during the creation of a sound track.
  90142. */
  90143. export interface ISoundTrackOptions {
  90144. /**
  90145. * The volume the sound track should take during creation
  90146. */
  90147. volume?: number;
  90148. /**
  90149. * Define if the sound track is the main sound track of the scene
  90150. */
  90151. mainTrack?: boolean;
  90152. }
  90153. /**
  90154. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90155. * It will be also used in a future release to apply effects on a specific track.
  90156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90157. */
  90158. export class SoundTrack {
  90159. /**
  90160. * The unique identifier of the sound track in the scene.
  90161. */
  90162. id: number;
  90163. /**
  90164. * The list of sounds included in the sound track.
  90165. */
  90166. soundCollection: Array<Sound>;
  90167. private _outputAudioNode;
  90168. private _scene;
  90169. private _isMainTrack;
  90170. private _connectedAnalyser;
  90171. private _options;
  90172. private _isInitialized;
  90173. /**
  90174. * Creates a new sound track.
  90175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90176. * @param scene Define the scene the sound track belongs to
  90177. * @param options
  90178. */
  90179. constructor(scene: Scene, options?: ISoundTrackOptions);
  90180. private _initializeSoundTrackAudioGraph;
  90181. /**
  90182. * Release the sound track and its associated resources
  90183. */
  90184. dispose(): void;
  90185. /**
  90186. * Adds a sound to this sound track
  90187. * @param sound define the cound to add
  90188. * @ignoreNaming
  90189. */
  90190. AddSound(sound: Sound): void;
  90191. /**
  90192. * Removes a sound to this sound track
  90193. * @param sound define the cound to remove
  90194. * @ignoreNaming
  90195. */
  90196. RemoveSound(sound: Sound): void;
  90197. /**
  90198. * Set a global volume for the full sound track.
  90199. * @param newVolume Define the new volume of the sound track
  90200. */
  90201. setVolume(newVolume: number): void;
  90202. /**
  90203. * Switch the panning model to HRTF:
  90204. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90206. */
  90207. switchPanningModelToHRTF(): void;
  90208. /**
  90209. * Switch the panning model to Equal Power:
  90210. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90212. */
  90213. switchPanningModelToEqualPower(): void;
  90214. /**
  90215. * Connect the sound track to an audio analyser allowing some amazing
  90216. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90218. * @param analyser The analyser to connect to the engine
  90219. */
  90220. connectToAnalyser(analyser: Analyser): void;
  90221. }
  90222. }
  90223. declare module BABYLON {
  90224. interface AbstractScene {
  90225. /**
  90226. * The list of sounds used in the scene.
  90227. */
  90228. sounds: Nullable<Array<Sound>>;
  90229. }
  90230. interface Scene {
  90231. /**
  90232. * @hidden
  90233. * Backing field
  90234. */
  90235. _mainSoundTrack: SoundTrack;
  90236. /**
  90237. * The main sound track played by the scene.
  90238. * It cotains your primary collection of sounds.
  90239. */
  90240. mainSoundTrack: SoundTrack;
  90241. /**
  90242. * The list of sound tracks added to the scene
  90243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90244. */
  90245. soundTracks: Nullable<Array<SoundTrack>>;
  90246. /**
  90247. * Gets a sound using a given name
  90248. * @param name defines the name to search for
  90249. * @return the found sound or null if not found at all.
  90250. */
  90251. getSoundByName(name: string): Nullable<Sound>;
  90252. /**
  90253. * Gets or sets if audio support is enabled
  90254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90255. */
  90256. audioEnabled: boolean;
  90257. /**
  90258. * Gets or sets if audio will be output to headphones
  90259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90260. */
  90261. headphone: boolean;
  90262. }
  90263. /**
  90264. * Defines the sound scene component responsible to manage any sounds
  90265. * in a given scene.
  90266. */
  90267. export class AudioSceneComponent implements ISceneSerializableComponent {
  90268. /**
  90269. * The component name helpfull to identify the component in the list of scene components.
  90270. */
  90271. readonly name: string;
  90272. /**
  90273. * The scene the component belongs to.
  90274. */
  90275. scene: Scene;
  90276. private _audioEnabled;
  90277. /**
  90278. * Gets whether audio is enabled or not.
  90279. * Please use related enable/disable method to switch state.
  90280. */
  90281. readonly audioEnabled: boolean;
  90282. private _headphone;
  90283. /**
  90284. * Gets whether audio is outputing to headphone or not.
  90285. * Please use the according Switch methods to change output.
  90286. */
  90287. readonly headphone: boolean;
  90288. /**
  90289. * Creates a new instance of the component for the given scene
  90290. * @param scene Defines the scene to register the component in
  90291. */
  90292. constructor(scene: Scene);
  90293. /**
  90294. * Registers the component in a given scene
  90295. */
  90296. register(): void;
  90297. /**
  90298. * Rebuilds the elements related to this component in case of
  90299. * context lost for instance.
  90300. */
  90301. rebuild(): void;
  90302. /**
  90303. * Serializes the component data to the specified json object
  90304. * @param serializationObject The object to serialize to
  90305. */
  90306. serialize(serializationObject: any): void;
  90307. /**
  90308. * Adds all the element from the container to the scene
  90309. * @param container the container holding the elements
  90310. */
  90311. addFromContainer(container: AbstractScene): void;
  90312. /**
  90313. * Removes all the elements in the container from the scene
  90314. * @param container contains the elements to remove
  90315. */
  90316. removeFromContainer(container: AbstractScene): void;
  90317. /**
  90318. * Disposes the component and the associated ressources.
  90319. */
  90320. dispose(): void;
  90321. /**
  90322. * Disables audio in the associated scene.
  90323. */
  90324. disableAudio(): void;
  90325. /**
  90326. * Enables audio in the associated scene.
  90327. */
  90328. enableAudio(): void;
  90329. /**
  90330. * Switch audio to headphone output.
  90331. */
  90332. switchAudioModeForHeadphones(): void;
  90333. /**
  90334. * Switch audio to normal speakers.
  90335. */
  90336. switchAudioModeForNormalSpeakers(): void;
  90337. private _afterRender;
  90338. }
  90339. }
  90340. declare module BABYLON {
  90341. /**
  90342. * Wraps one or more Sound objects and selects one with random weight for playback.
  90343. */
  90344. export class WeightedSound {
  90345. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90346. loop: boolean;
  90347. private _coneInnerAngle;
  90348. private _coneOuterAngle;
  90349. private _volume;
  90350. /** A Sound is currently playing. */
  90351. isPlaying: boolean;
  90352. /** A Sound is currently paused. */
  90353. isPaused: boolean;
  90354. private _sounds;
  90355. private _weights;
  90356. private _currentIndex?;
  90357. /**
  90358. * Creates a new WeightedSound from the list of sounds given.
  90359. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90360. * @param sounds Array of Sounds that will be selected from.
  90361. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90362. */
  90363. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90364. /**
  90365. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90366. */
  90367. /**
  90368. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90369. */
  90370. directionalConeInnerAngle: number;
  90371. /**
  90372. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90373. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90374. */
  90375. /**
  90376. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90377. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90378. */
  90379. directionalConeOuterAngle: number;
  90380. /**
  90381. * Playback volume.
  90382. */
  90383. /**
  90384. * Playback volume.
  90385. */
  90386. volume: number;
  90387. private _onended;
  90388. /**
  90389. * Suspend playback
  90390. */
  90391. pause(): void;
  90392. /**
  90393. * Stop playback
  90394. */
  90395. stop(): void;
  90396. /**
  90397. * Start playback.
  90398. * @param startOffset Position the clip head at a specific time in seconds.
  90399. */
  90400. play(startOffset?: number): void;
  90401. }
  90402. }
  90403. declare module BABYLON {
  90404. /**
  90405. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90407. */
  90408. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90409. /**
  90410. * Gets the name of the behavior.
  90411. */
  90412. readonly name: string;
  90413. /**
  90414. * The easing function used by animations
  90415. */
  90416. static EasingFunction: BackEase;
  90417. /**
  90418. * The easing mode used by animations
  90419. */
  90420. static EasingMode: number;
  90421. /**
  90422. * The duration of the animation, in milliseconds
  90423. */
  90424. transitionDuration: number;
  90425. /**
  90426. * Length of the distance animated by the transition when lower radius is reached
  90427. */
  90428. lowerRadiusTransitionRange: number;
  90429. /**
  90430. * Length of the distance animated by the transition when upper radius is reached
  90431. */
  90432. upperRadiusTransitionRange: number;
  90433. private _autoTransitionRange;
  90434. /**
  90435. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90436. */
  90437. /**
  90438. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90439. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90440. */
  90441. autoTransitionRange: boolean;
  90442. private _attachedCamera;
  90443. private _onAfterCheckInputsObserver;
  90444. private _onMeshTargetChangedObserver;
  90445. /**
  90446. * Initializes the behavior.
  90447. */
  90448. init(): void;
  90449. /**
  90450. * Attaches the behavior to its arc rotate camera.
  90451. * @param camera Defines the camera to attach the behavior to
  90452. */
  90453. attach(camera: ArcRotateCamera): void;
  90454. /**
  90455. * Detaches the behavior from its current arc rotate camera.
  90456. */
  90457. detach(): void;
  90458. private _radiusIsAnimating;
  90459. private _radiusBounceTransition;
  90460. private _animatables;
  90461. private _cachedWheelPrecision;
  90462. /**
  90463. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90464. * @param radiusLimit The limit to check against.
  90465. * @return Bool to indicate if at limit.
  90466. */
  90467. private _isRadiusAtLimit;
  90468. /**
  90469. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90470. * @param radiusDelta The delta by which to animate to. Can be negative.
  90471. */
  90472. private _applyBoundRadiusAnimation;
  90473. /**
  90474. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90475. */
  90476. protected _clearAnimationLocks(): void;
  90477. /**
  90478. * Stops and removes all animations that have been applied to the camera
  90479. */
  90480. stopAllAnimations(): void;
  90481. }
  90482. }
  90483. declare module BABYLON {
  90484. /**
  90485. * 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.
  90486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90487. */
  90488. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90489. /**
  90490. * Gets the name of the behavior.
  90491. */
  90492. readonly name: string;
  90493. private _mode;
  90494. private _radiusScale;
  90495. private _positionScale;
  90496. private _defaultElevation;
  90497. private _elevationReturnTime;
  90498. private _elevationReturnWaitTime;
  90499. private _zoomStopsAnimation;
  90500. private _framingTime;
  90501. /**
  90502. * The easing function used by animations
  90503. */
  90504. static EasingFunction: ExponentialEase;
  90505. /**
  90506. * The easing mode used by animations
  90507. */
  90508. static EasingMode: number;
  90509. /**
  90510. * Sets the current mode used by the behavior
  90511. */
  90512. /**
  90513. * Gets current mode used by the behavior.
  90514. */
  90515. mode: number;
  90516. /**
  90517. * Sets the scale applied to the radius (1 by default)
  90518. */
  90519. /**
  90520. * Gets the scale applied to the radius
  90521. */
  90522. radiusScale: number;
  90523. /**
  90524. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90525. */
  90526. /**
  90527. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90528. */
  90529. positionScale: number;
  90530. /**
  90531. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90532. * behaviour is triggered, in radians.
  90533. */
  90534. /**
  90535. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90536. * behaviour is triggered, in radians.
  90537. */
  90538. defaultElevation: number;
  90539. /**
  90540. * Sets the time (in milliseconds) taken to return to the default beta position.
  90541. * Negative value indicates camera should not return to default.
  90542. */
  90543. /**
  90544. * Gets the time (in milliseconds) taken to return to the default beta position.
  90545. * Negative value indicates camera should not return to default.
  90546. */
  90547. elevationReturnTime: number;
  90548. /**
  90549. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90550. */
  90551. /**
  90552. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90553. */
  90554. elevationReturnWaitTime: number;
  90555. /**
  90556. * Sets the flag that indicates if user zooming should stop animation.
  90557. */
  90558. /**
  90559. * Gets the flag that indicates if user zooming should stop animation.
  90560. */
  90561. zoomStopsAnimation: boolean;
  90562. /**
  90563. * Sets the transition time when framing the mesh, in milliseconds
  90564. */
  90565. /**
  90566. * Gets the transition time when framing the mesh, in milliseconds
  90567. */
  90568. framingTime: number;
  90569. /**
  90570. * Define if the behavior should automatically change the configured
  90571. * camera limits and sensibilities.
  90572. */
  90573. autoCorrectCameraLimitsAndSensibility: boolean;
  90574. private _onPrePointerObservableObserver;
  90575. private _onAfterCheckInputsObserver;
  90576. private _onMeshTargetChangedObserver;
  90577. private _attachedCamera;
  90578. private _isPointerDown;
  90579. private _lastInteractionTime;
  90580. /**
  90581. * Initializes the behavior.
  90582. */
  90583. init(): void;
  90584. /**
  90585. * Attaches the behavior to its arc rotate camera.
  90586. * @param camera Defines the camera to attach the behavior to
  90587. */
  90588. attach(camera: ArcRotateCamera): void;
  90589. /**
  90590. * Detaches the behavior from its current arc rotate camera.
  90591. */
  90592. detach(): void;
  90593. private _animatables;
  90594. private _betaIsAnimating;
  90595. private _betaTransition;
  90596. private _radiusTransition;
  90597. private _vectorTransition;
  90598. /**
  90599. * Targets the given mesh and updates zoom level accordingly.
  90600. * @param mesh The mesh to target.
  90601. * @param radius Optional. If a cached radius position already exists, overrides default.
  90602. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90603. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90604. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90605. */
  90606. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90607. /**
  90608. * Targets the given mesh with its children and updates zoom level accordingly.
  90609. * @param mesh The mesh to target.
  90610. * @param radius Optional. If a cached radius position already exists, overrides default.
  90611. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90614. */
  90615. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90616. /**
  90617. * Targets the given meshes with their children and updates zoom level accordingly.
  90618. * @param meshes The mesh to target.
  90619. * @param radius Optional. If a cached radius position already exists, overrides default.
  90620. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90621. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90622. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90623. */
  90624. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90625. /**
  90626. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90627. * @param minimumWorld Determines the smaller position of the bounding box extend
  90628. * @param maximumWorld Determines the bigger position of the bounding box extend
  90629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90631. */
  90632. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90633. /**
  90634. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90635. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90636. * frustum width.
  90637. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90638. * to fully enclose the mesh in the viewing frustum.
  90639. */
  90640. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90641. /**
  90642. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90643. * is automatically returned to its default position (expected to be above ground plane).
  90644. */
  90645. private _maintainCameraAboveGround;
  90646. /**
  90647. * Returns the frustum slope based on the canvas ratio and camera FOV
  90648. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90649. */
  90650. private _getFrustumSlope;
  90651. /**
  90652. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90653. */
  90654. private _clearAnimationLocks;
  90655. /**
  90656. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90657. */
  90658. private _applyUserInteraction;
  90659. /**
  90660. * Stops and removes all animations that have been applied to the camera
  90661. */
  90662. stopAllAnimations(): void;
  90663. /**
  90664. * Gets a value indicating if the user is moving the camera
  90665. */
  90666. readonly isUserIsMoving: boolean;
  90667. /**
  90668. * The camera can move all the way towards the mesh.
  90669. */
  90670. static IgnoreBoundsSizeMode: number;
  90671. /**
  90672. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90673. */
  90674. static FitFrustumSidesMode: number;
  90675. }
  90676. }
  90677. declare module BABYLON {
  90678. /**
  90679. * Manage the pointers inputs to control an arc rotate camera.
  90680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90681. */
  90682. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90683. /**
  90684. * Defines the camera the input is attached to.
  90685. */
  90686. camera: ArcRotateCamera;
  90687. /**
  90688. * Defines the buttons associated with the input to handle camera move.
  90689. */
  90690. buttons: number[];
  90691. /**
  90692. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90693. */
  90694. angularSensibilityX: number;
  90695. /**
  90696. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90697. */
  90698. angularSensibilityY: number;
  90699. /**
  90700. * Defines the pointer pinch precision or how fast is the camera zooming.
  90701. */
  90702. pinchPrecision: number;
  90703. /**
  90704. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90705. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90706. */
  90707. pinchDeltaPercentage: number;
  90708. /**
  90709. * Defines the pointer panning sensibility or how fast is the camera moving.
  90710. */
  90711. panningSensibility: number;
  90712. /**
  90713. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90714. */
  90715. multiTouchPanning: boolean;
  90716. /**
  90717. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90718. */
  90719. multiTouchPanAndZoom: boolean;
  90720. /**
  90721. * Revers pinch action direction.
  90722. */
  90723. pinchInwards: boolean;
  90724. private _isPanClick;
  90725. private _pointerInput;
  90726. private _observer;
  90727. private _onMouseMove;
  90728. private _onGestureStart;
  90729. private _onGesture;
  90730. private _MSGestureHandler;
  90731. private _onLostFocus;
  90732. private _onContextMenu;
  90733. /**
  90734. * Attach the input controls to a specific dom element to get the input from.
  90735. * @param element Defines the element the controls should be listened from
  90736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90737. */
  90738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90739. /**
  90740. * Detach the current controls from the specified dom element.
  90741. * @param element Defines the element to stop listening the inputs from
  90742. */
  90743. detachControl(element: Nullable<HTMLElement>): void;
  90744. /**
  90745. * Gets the class name of the current intput.
  90746. * @returns the class name
  90747. */
  90748. getClassName(): string;
  90749. /**
  90750. * Get the friendly name associated with the input class.
  90751. * @returns the input friendly name
  90752. */
  90753. getSimpleName(): string;
  90754. }
  90755. }
  90756. declare module BABYLON {
  90757. /**
  90758. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90760. */
  90761. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90762. /**
  90763. * Defines the camera the input is attached to.
  90764. */
  90765. camera: ArcRotateCamera;
  90766. /**
  90767. * Defines the list of key codes associated with the up action (increase alpha)
  90768. */
  90769. keysUp: number[];
  90770. /**
  90771. * Defines the list of key codes associated with the down action (decrease alpha)
  90772. */
  90773. keysDown: number[];
  90774. /**
  90775. * Defines the list of key codes associated with the left action (increase beta)
  90776. */
  90777. keysLeft: number[];
  90778. /**
  90779. * Defines the list of key codes associated with the right action (decrease beta)
  90780. */
  90781. keysRight: number[];
  90782. /**
  90783. * Defines the list of key codes associated with the reset action.
  90784. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90785. */
  90786. keysReset: number[];
  90787. /**
  90788. * Defines the panning sensibility of the inputs.
  90789. * (How fast is the camera paning)
  90790. */
  90791. panningSensibility: number;
  90792. /**
  90793. * Defines the zooming sensibility of the inputs.
  90794. * (How fast is the camera zooming)
  90795. */
  90796. zoomingSensibility: number;
  90797. /**
  90798. * Defines wether maintaining the alt key down switch the movement mode from
  90799. * orientation to zoom.
  90800. */
  90801. useAltToZoom: boolean;
  90802. /**
  90803. * Rotation speed of the camera
  90804. */
  90805. angularSpeed: number;
  90806. private _keys;
  90807. private _ctrlPressed;
  90808. private _altPressed;
  90809. private _onCanvasBlurObserver;
  90810. private _onKeyboardObserver;
  90811. private _engine;
  90812. private _scene;
  90813. /**
  90814. * Attach the input controls to a specific dom element to get the input from.
  90815. * @param element Defines the element the controls should be listened from
  90816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90817. */
  90818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90819. /**
  90820. * Detach the current controls from the specified dom element.
  90821. * @param element Defines the element to stop listening the inputs from
  90822. */
  90823. detachControl(element: Nullable<HTMLElement>): void;
  90824. /**
  90825. * Update the current camera state depending on the inputs that have been used this frame.
  90826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90827. */
  90828. checkInputs(): void;
  90829. /**
  90830. * Gets the class name of the current intput.
  90831. * @returns the class name
  90832. */
  90833. getClassName(): string;
  90834. /**
  90835. * Get the friendly name associated with the input class.
  90836. * @returns the input friendly name
  90837. */
  90838. getSimpleName(): string;
  90839. }
  90840. }
  90841. declare module BABYLON {
  90842. /**
  90843. * Manage the mouse wheel inputs to control an arc rotate camera.
  90844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90845. */
  90846. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90847. /**
  90848. * Defines the camera the input is attached to.
  90849. */
  90850. camera: ArcRotateCamera;
  90851. /**
  90852. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90853. */
  90854. wheelPrecision: number;
  90855. /**
  90856. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90857. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90858. */
  90859. wheelDeltaPercentage: number;
  90860. private _wheel;
  90861. private _observer;
  90862. /**
  90863. * Attach the input controls to a specific dom element to get the input from.
  90864. * @param element Defines the element the controls should be listened from
  90865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90866. */
  90867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90868. /**
  90869. * Detach the current controls from the specified dom element.
  90870. * @param element Defines the element to stop listening the inputs from
  90871. */
  90872. detachControl(element: Nullable<HTMLElement>): void;
  90873. /**
  90874. * Gets the class name of the current intput.
  90875. * @returns the class name
  90876. */
  90877. getClassName(): string;
  90878. /**
  90879. * Get the friendly name associated with the input class.
  90880. * @returns the input friendly name
  90881. */
  90882. getSimpleName(): string;
  90883. }
  90884. }
  90885. declare module BABYLON {
  90886. /**
  90887. * Default Inputs manager for the ArcRotateCamera.
  90888. * It groups all the default supported inputs for ease of use.
  90889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90890. */
  90891. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90892. /**
  90893. * Instantiates a new ArcRotateCameraInputsManager.
  90894. * @param camera Defines the camera the inputs belong to
  90895. */
  90896. constructor(camera: ArcRotateCamera);
  90897. /**
  90898. * Add mouse wheel input support to the input manager.
  90899. * @returns the current input manager
  90900. */
  90901. addMouseWheel(): ArcRotateCameraInputsManager;
  90902. /**
  90903. * Add pointers input support to the input manager.
  90904. * @returns the current input manager
  90905. */
  90906. addPointers(): ArcRotateCameraInputsManager;
  90907. /**
  90908. * Add keyboard input support to the input manager.
  90909. * @returns the current input manager
  90910. */
  90911. addKeyboard(): ArcRotateCameraInputsManager;
  90912. }
  90913. }
  90914. declare module BABYLON {
  90915. /**
  90916. * This represents an orbital type of camera.
  90917. *
  90918. * 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.
  90919. * 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.
  90920. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90921. */
  90922. export class ArcRotateCamera extends TargetCamera {
  90923. /**
  90924. * Defines the rotation angle of the camera along the longitudinal axis.
  90925. */
  90926. alpha: number;
  90927. /**
  90928. * Defines the rotation angle of the camera along the latitudinal axis.
  90929. */
  90930. beta: number;
  90931. /**
  90932. * Defines the radius of the camera from it s target point.
  90933. */
  90934. radius: number;
  90935. protected _target: Vector3;
  90936. protected _targetHost: Nullable<AbstractMesh>;
  90937. /**
  90938. * Defines the target point of the camera.
  90939. * The camera looks towards it form the radius distance.
  90940. */
  90941. target: Vector3;
  90942. /**
  90943. * Define the current local position of the camera in the scene
  90944. */
  90945. position: Vector3;
  90946. /**
  90947. * Current inertia value on the longitudinal axis.
  90948. * The bigger this number the longer it will take for the camera to stop.
  90949. */
  90950. inertialAlphaOffset: number;
  90951. /**
  90952. * Current inertia value on the latitudinal axis.
  90953. * The bigger this number the longer it will take for the camera to stop.
  90954. */
  90955. inertialBetaOffset: number;
  90956. /**
  90957. * Current inertia value on the radius axis.
  90958. * The bigger this number the longer it will take for the camera to stop.
  90959. */
  90960. inertialRadiusOffset: number;
  90961. /**
  90962. * Minimum allowed angle on the longitudinal axis.
  90963. * This can help limiting how the Camera is able to move in the scene.
  90964. */
  90965. lowerAlphaLimit: Nullable<number>;
  90966. /**
  90967. * Maximum allowed angle on the longitudinal axis.
  90968. * This can help limiting how the Camera is able to move in the scene.
  90969. */
  90970. upperAlphaLimit: Nullable<number>;
  90971. /**
  90972. * Minimum allowed angle on the latitudinal axis.
  90973. * This can help limiting how the Camera is able to move in the scene.
  90974. */
  90975. lowerBetaLimit: number;
  90976. /**
  90977. * Maximum allowed angle on the latitudinal axis.
  90978. * This can help limiting how the Camera is able to move in the scene.
  90979. */
  90980. upperBetaLimit: number;
  90981. /**
  90982. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90983. * This can help limiting how the Camera is able to move in the scene.
  90984. */
  90985. lowerRadiusLimit: Nullable<number>;
  90986. /**
  90987. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90988. * This can help limiting how the Camera is able to move in the scene.
  90989. */
  90990. upperRadiusLimit: Nullable<number>;
  90991. /**
  90992. * Defines the current inertia value used during panning of the camera along the X axis.
  90993. */
  90994. inertialPanningX: number;
  90995. /**
  90996. * Defines the current inertia value used during panning of the camera along the Y axis.
  90997. */
  90998. inertialPanningY: number;
  90999. /**
  91000. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91001. * Basically if your fingers moves away from more than this distance you will be considered
  91002. * in pinch mode.
  91003. */
  91004. pinchToPanMaxDistance: number;
  91005. /**
  91006. * Defines the maximum distance the camera can pan.
  91007. * This could help keeping the cammera always in your scene.
  91008. */
  91009. panningDistanceLimit: Nullable<number>;
  91010. /**
  91011. * Defines the target of the camera before paning.
  91012. */
  91013. panningOriginTarget: Vector3;
  91014. /**
  91015. * Defines the value of the inertia used during panning.
  91016. * 0 would mean stop inertia and one would mean no decelleration at all.
  91017. */
  91018. panningInertia: number;
  91019. /**
  91020. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91021. */
  91022. angularSensibilityX: number;
  91023. /**
  91024. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91025. */
  91026. angularSensibilityY: number;
  91027. /**
  91028. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91029. */
  91030. pinchPrecision: number;
  91031. /**
  91032. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91033. * It will be used instead of pinchDeltaPrecision if different from 0.
  91034. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91035. */
  91036. pinchDeltaPercentage: number;
  91037. /**
  91038. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91039. */
  91040. panningSensibility: number;
  91041. /**
  91042. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91043. */
  91044. keysUp: number[];
  91045. /**
  91046. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91047. */
  91048. keysDown: number[];
  91049. /**
  91050. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91051. */
  91052. keysLeft: number[];
  91053. /**
  91054. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91055. */
  91056. keysRight: number[];
  91057. /**
  91058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91059. */
  91060. wheelPrecision: number;
  91061. /**
  91062. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91063. * It will be used instead of pinchDeltaPrecision if different from 0.
  91064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91065. */
  91066. wheelDeltaPercentage: number;
  91067. /**
  91068. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91069. */
  91070. zoomOnFactor: number;
  91071. /**
  91072. * Defines a screen offset for the camera position.
  91073. */
  91074. targetScreenOffset: Vector2;
  91075. /**
  91076. * Allows the camera to be completely reversed.
  91077. * If false the camera can not arrive upside down.
  91078. */
  91079. allowUpsideDown: boolean;
  91080. /**
  91081. * Define if double tap/click is used to restore the previously saved state of the camera.
  91082. */
  91083. useInputToRestoreState: boolean;
  91084. /** @hidden */
  91085. _viewMatrix: Matrix;
  91086. /** @hidden */
  91087. _useCtrlForPanning: boolean;
  91088. /** @hidden */
  91089. _panningMouseButton: number;
  91090. /**
  91091. * Defines the input associated to the camera.
  91092. */
  91093. inputs: ArcRotateCameraInputsManager;
  91094. /** @hidden */
  91095. _reset: () => void;
  91096. /**
  91097. * Defines the allowed panning axis.
  91098. */
  91099. panningAxis: Vector3;
  91100. protected _localDirection: Vector3;
  91101. protected _transformedDirection: Vector3;
  91102. private _bouncingBehavior;
  91103. /**
  91104. * Gets the bouncing behavior of the camera if it has been enabled.
  91105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91106. */
  91107. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91108. /**
  91109. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91110. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91111. */
  91112. useBouncingBehavior: boolean;
  91113. private _framingBehavior;
  91114. /**
  91115. * Gets the framing behavior of the camera if it has been enabled.
  91116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91117. */
  91118. readonly framingBehavior: Nullable<FramingBehavior>;
  91119. /**
  91120. * Defines if the framing behavior of the camera is enabled on the camera.
  91121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91122. */
  91123. useFramingBehavior: boolean;
  91124. private _autoRotationBehavior;
  91125. /**
  91126. * Gets the auto rotation behavior of the camera if it has been enabled.
  91127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91128. */
  91129. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91130. /**
  91131. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91133. */
  91134. useAutoRotationBehavior: boolean;
  91135. /**
  91136. * Observable triggered when the mesh target has been changed on the camera.
  91137. */
  91138. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91139. /**
  91140. * Event raised when the camera is colliding with a mesh.
  91141. */
  91142. onCollide: (collidedMesh: AbstractMesh) => void;
  91143. /**
  91144. * Defines whether the camera should check collision with the objects oh the scene.
  91145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91146. */
  91147. checkCollisions: boolean;
  91148. /**
  91149. * Defines the collision radius of the camera.
  91150. * This simulates a sphere around the camera.
  91151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91152. */
  91153. collisionRadius: Vector3;
  91154. protected _collider: Collider;
  91155. protected _previousPosition: Vector3;
  91156. protected _collisionVelocity: Vector3;
  91157. protected _newPosition: Vector3;
  91158. protected _previousAlpha: number;
  91159. protected _previousBeta: number;
  91160. protected _previousRadius: number;
  91161. protected _collisionTriggered: boolean;
  91162. protected _targetBoundingCenter: Nullable<Vector3>;
  91163. private _computationVector;
  91164. private _tempAxisVector;
  91165. private _tempAxisRotationMatrix;
  91166. /**
  91167. * Instantiates a new ArcRotateCamera in a given scene
  91168. * @param name Defines the name of the camera
  91169. * @param alpha Defines the camera rotation along the logitudinal axis
  91170. * @param beta Defines the camera rotation along the latitudinal axis
  91171. * @param radius Defines the camera distance from its target
  91172. * @param target Defines the camera target
  91173. * @param scene Defines the scene the camera belongs to
  91174. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91175. */
  91176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91177. /** @hidden */
  91178. _initCache(): void;
  91179. /** @hidden */
  91180. _updateCache(ignoreParentClass?: boolean): void;
  91181. protected _getTargetPosition(): Vector3;
  91182. private _storedAlpha;
  91183. private _storedBeta;
  91184. private _storedRadius;
  91185. private _storedTarget;
  91186. /**
  91187. * Stores the current state of the camera (alpha, beta, radius and target)
  91188. * @returns the camera itself
  91189. */
  91190. storeState(): Camera;
  91191. /**
  91192. * @hidden
  91193. * Restored camera state. You must call storeState() first
  91194. */
  91195. _restoreStateValues(): boolean;
  91196. /** @hidden */
  91197. _isSynchronizedViewMatrix(): boolean;
  91198. /**
  91199. * Attached controls to the current camera.
  91200. * @param element Defines the element the controls should be listened from
  91201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91202. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91203. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91204. */
  91205. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91206. /**
  91207. * Detach the current controls from the camera.
  91208. * The camera will stop reacting to inputs.
  91209. * @param element Defines the element to stop listening the inputs from
  91210. */
  91211. detachControl(element: HTMLElement): void;
  91212. /** @hidden */
  91213. _checkInputs(): void;
  91214. protected _checkLimits(): void;
  91215. /**
  91216. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91217. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91218. */
  91219. rebuildAnglesAndRadius(updateView?: boolean): void;
  91220. /**
  91221. * Use a position to define the current camera related information like aplha, beta and radius
  91222. * @param position Defines the position to set the camera at
  91223. */
  91224. setPosition(position: Vector3): void;
  91225. /**
  91226. * Defines the target the camera should look at.
  91227. * This will automatically adapt alpha beta and radius to fit within the new target.
  91228. * @param target Defines the new target as a Vector or a mesh
  91229. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91230. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91231. */
  91232. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91233. /** @hidden */
  91234. _getViewMatrix(): Matrix;
  91235. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91236. /**
  91237. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91238. * @param meshes Defines the mesh to zoom on
  91239. * @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)
  91240. */
  91241. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91242. /**
  91243. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91244. * The target will be changed but the radius
  91245. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91246. * @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)
  91247. */
  91248. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91249. min: Vector3;
  91250. max: Vector3;
  91251. distance: number;
  91252. }, doNotUpdateMaxZ?: boolean): void;
  91253. /**
  91254. * @override
  91255. * Override Camera.createRigCamera
  91256. */
  91257. createRigCamera(name: string, cameraIndex: number): Camera;
  91258. /**
  91259. * @hidden
  91260. * @override
  91261. * Override Camera._updateRigCameras
  91262. */
  91263. _updateRigCameras(): void;
  91264. /**
  91265. * Destroy the camera and release the current resources hold by it.
  91266. */
  91267. dispose(): void;
  91268. /**
  91269. * Gets the current object class name.
  91270. * @return the class name
  91271. */
  91272. getClassName(): string;
  91273. }
  91274. }
  91275. declare module BABYLON {
  91276. /**
  91277. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91279. */
  91280. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91281. /**
  91282. * Gets the name of the behavior.
  91283. */
  91284. readonly name: string;
  91285. private _zoomStopsAnimation;
  91286. private _idleRotationSpeed;
  91287. private _idleRotationWaitTime;
  91288. private _idleRotationSpinupTime;
  91289. /**
  91290. * Sets the flag that indicates if user zooming should stop animation.
  91291. */
  91292. /**
  91293. * Gets the flag that indicates if user zooming should stop animation.
  91294. */
  91295. zoomStopsAnimation: boolean;
  91296. /**
  91297. * Sets the default speed at which the camera rotates around the model.
  91298. */
  91299. /**
  91300. * Gets the default speed at which the camera rotates around the model.
  91301. */
  91302. idleRotationSpeed: number;
  91303. /**
  91304. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91305. */
  91306. /**
  91307. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91308. */
  91309. idleRotationWaitTime: number;
  91310. /**
  91311. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91312. */
  91313. /**
  91314. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91315. */
  91316. idleRotationSpinupTime: number;
  91317. /**
  91318. * Gets a value indicating if the camera is currently rotating because of this behavior
  91319. */
  91320. readonly rotationInProgress: boolean;
  91321. private _onPrePointerObservableObserver;
  91322. private _onAfterCheckInputsObserver;
  91323. private _attachedCamera;
  91324. private _isPointerDown;
  91325. private _lastFrameTime;
  91326. private _lastInteractionTime;
  91327. private _cameraRotationSpeed;
  91328. /**
  91329. * Initializes the behavior.
  91330. */
  91331. init(): void;
  91332. /**
  91333. * Attaches the behavior to its arc rotate camera.
  91334. * @param camera Defines the camera to attach the behavior to
  91335. */
  91336. attach(camera: ArcRotateCamera): void;
  91337. /**
  91338. * Detaches the behavior from its current arc rotate camera.
  91339. */
  91340. detach(): void;
  91341. /**
  91342. * Returns true if user is scrolling.
  91343. * @return true if user is scrolling.
  91344. */
  91345. private _userIsZooming;
  91346. private _lastFrameRadius;
  91347. private _shouldAnimationStopForInteraction;
  91348. /**
  91349. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91350. */
  91351. private _applyUserInteraction;
  91352. private _userIsMoving;
  91353. }
  91354. }
  91355. declare module BABYLON {
  91356. /**
  91357. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  91358. */
  91359. export class AttachToBoxBehavior implements Behavior<Mesh> {
  91360. private ui;
  91361. /**
  91362. * The name of the behavior
  91363. */
  91364. name: string;
  91365. /**
  91366. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  91367. */
  91368. distanceAwayFromFace: number;
  91369. /**
  91370. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  91371. */
  91372. distanceAwayFromBottomOfFace: number;
  91373. private _faceVectors;
  91374. private _target;
  91375. private _scene;
  91376. private _onRenderObserver;
  91377. private _tmpMatrix;
  91378. private _tmpVector;
  91379. /**
  91380. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  91381. * @param ui The transform node that should be attched to the mesh
  91382. */
  91383. constructor(ui: TransformNode);
  91384. /**
  91385. * Initializes the behavior
  91386. */
  91387. init(): void;
  91388. private _closestFace;
  91389. private _zeroVector;
  91390. private _lookAtTmpMatrix;
  91391. private _lookAtToRef;
  91392. /**
  91393. * Attaches the AttachToBoxBehavior to the passed in mesh
  91394. * @param target The mesh that the specified node will be attached to
  91395. */
  91396. attach(target: Mesh): void;
  91397. /**
  91398. * Detaches the behavior from the mesh
  91399. */
  91400. detach(): void;
  91401. }
  91402. }
  91403. declare module BABYLON {
  91404. /**
  91405. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  91406. */
  91407. export class FadeInOutBehavior implements Behavior<Mesh> {
  91408. /**
  91409. * Time in milliseconds to delay before fading in (Default: 0)
  91410. */
  91411. delay: number;
  91412. /**
  91413. * Time in milliseconds for the mesh to fade in (Default: 300)
  91414. */
  91415. fadeInTime: number;
  91416. private _millisecondsPerFrame;
  91417. private _hovered;
  91418. private _hoverValue;
  91419. private _ownerNode;
  91420. /**
  91421. * Instatiates the FadeInOutBehavior
  91422. */
  91423. constructor();
  91424. /**
  91425. * The name of the behavior
  91426. */
  91427. readonly name: string;
  91428. /**
  91429. * Initializes the behavior
  91430. */
  91431. init(): void;
  91432. /**
  91433. * Attaches the fade behavior on the passed in mesh
  91434. * @param ownerNode The mesh that will be faded in/out once attached
  91435. */
  91436. attach(ownerNode: Mesh): void;
  91437. /**
  91438. * Detaches the behavior from the mesh
  91439. */
  91440. detach(): void;
  91441. /**
  91442. * Triggers the mesh to begin fading in or out
  91443. * @param value if the object should fade in or out (true to fade in)
  91444. */
  91445. fadeIn(value: boolean): void;
  91446. private _update;
  91447. private _setAllVisibility;
  91448. }
  91449. }
  91450. declare module BABYLON {
  91451. /**
  91452. * Class containing a set of static utilities functions for managing Pivots
  91453. * @hidden
  91454. */
  91455. export class PivotTools {
  91456. private static _PivotCached;
  91457. private static _OldPivotPoint;
  91458. private static _PivotTranslation;
  91459. private static _PivotTmpVector;
  91460. /** @hidden */
  91461. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  91462. /** @hidden */
  91463. static _RestorePivotPoint(mesh: AbstractMesh): void;
  91464. }
  91465. }
  91466. declare module BABYLON {
  91467. /**
  91468. * Class containing static functions to help procedurally build meshes
  91469. */
  91470. export class PlaneBuilder {
  91471. /**
  91472. * Creates a plane mesh
  91473. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91474. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91475. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91479. * @param name defines the name of the mesh
  91480. * @param options defines the options used to create the mesh
  91481. * @param scene defines the hosting scene
  91482. * @returns the plane mesh
  91483. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91484. */
  91485. static CreatePlane(name: string, options: {
  91486. size?: number;
  91487. width?: number;
  91488. height?: number;
  91489. sideOrientation?: number;
  91490. frontUVs?: Vector4;
  91491. backUVs?: Vector4;
  91492. updatable?: boolean;
  91493. sourcePlane?: Plane;
  91494. }, scene: Scene): Mesh;
  91495. }
  91496. }
  91497. declare module BABYLON {
  91498. /**
  91499. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91500. */
  91501. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91502. private static _AnyMouseID;
  91503. private _attachedNode;
  91504. private _dragPlane;
  91505. private _scene;
  91506. private _pointerObserver;
  91507. private _beforeRenderObserver;
  91508. private static _planeScene;
  91509. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  91510. /**
  91511. * 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)
  91512. */
  91513. maxDragAngle: number;
  91514. /**
  91515. * @hidden
  91516. */
  91517. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91518. /**
  91519. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91520. */
  91521. currentDraggingPointerID: number;
  91522. /**
  91523. * The last position where the pointer hit the drag plane in world space
  91524. */
  91525. lastDragPosition: Vector3;
  91526. /**
  91527. * If the behavior is currently in a dragging state
  91528. */
  91529. dragging: boolean;
  91530. /**
  91531. * 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)
  91532. */
  91533. dragDeltaRatio: number;
  91534. /**
  91535. * If the drag plane orientation should be updated during the dragging (Default: true)
  91536. */
  91537. updateDragPlane: boolean;
  91538. private _debugMode;
  91539. private _moving;
  91540. /**
  91541. * Fires each time the attached mesh is dragged with the pointer
  91542. * * delta between last drag position and current drag position in world space
  91543. * * dragDistance along the drag axis
  91544. * * dragPlaneNormal normal of the current drag plane used during the drag
  91545. * * dragPlanePoint in world space where the drag intersects the drag plane
  91546. */
  91547. onDragObservable: Observable<{
  91548. delta: Vector3;
  91549. dragPlanePoint: Vector3;
  91550. dragPlaneNormal: Vector3;
  91551. dragDistance: number;
  91552. pointerId: number;
  91553. }>;
  91554. /**
  91555. * Fires each time a drag begins (eg. mouse down on mesh)
  91556. */
  91557. onDragStartObservable: Observable<{
  91558. dragPlanePoint: Vector3;
  91559. pointerId: number;
  91560. }>;
  91561. /**
  91562. * Fires each time a drag ends (eg. mouse release after drag)
  91563. */
  91564. onDragEndObservable: Observable<{
  91565. dragPlanePoint: Vector3;
  91566. pointerId: number;
  91567. }>;
  91568. /**
  91569. * If the attached mesh should be moved when dragged
  91570. */
  91571. moveAttached: boolean;
  91572. /**
  91573. * If the drag behavior will react to drag events (Default: true)
  91574. */
  91575. enabled: boolean;
  91576. /**
  91577. * If camera controls should be detached during the drag
  91578. */
  91579. detachCameraControls: boolean;
  91580. /**
  91581. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91582. */
  91583. useObjectOrienationForDragging: boolean;
  91584. private _options;
  91585. /**
  91586. * Creates a pointer drag behavior that can be attached to a mesh
  91587. * @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)
  91588. */
  91589. constructor(options?: {
  91590. dragAxis?: Vector3;
  91591. dragPlaneNormal?: Vector3;
  91592. });
  91593. /**
  91594. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91595. */
  91596. validateDrag: (targetPosition: Vector3) => boolean;
  91597. /**
  91598. * The name of the behavior
  91599. */
  91600. readonly name: string;
  91601. /**
  91602. * Initializes the behavior
  91603. */
  91604. init(): void;
  91605. private _tmpVector;
  91606. private _alternatePickedPoint;
  91607. private _worldDragAxis;
  91608. private _targetPosition;
  91609. private _attachedElement;
  91610. /**
  91611. * Attaches the drag behavior the passed in mesh
  91612. * @param ownerNode The mesh that will be dragged around once attached
  91613. */
  91614. attach(ownerNode: AbstractMesh): void;
  91615. /**
  91616. * Force relase the drag action by code.
  91617. */
  91618. releaseDrag(): void;
  91619. private _startDragRay;
  91620. private _lastPointerRay;
  91621. /**
  91622. * Simulates the start of a pointer drag event on the behavior
  91623. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91624. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91625. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91626. */
  91627. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91628. private _startDrag;
  91629. private _dragDelta;
  91630. private _moveDrag;
  91631. private _pickWithRayOnDragPlane;
  91632. private _pointA;
  91633. private _pointB;
  91634. private _pointC;
  91635. private _lineA;
  91636. private _lineB;
  91637. private _localAxis;
  91638. private _lookAt;
  91639. private _updateDragPlanePosition;
  91640. /**
  91641. * Detaches the behavior from the mesh
  91642. */
  91643. detach(): void;
  91644. }
  91645. }
  91646. declare module BABYLON {
  91647. /**
  91648. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91649. */
  91650. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91651. private _dragBehaviorA;
  91652. private _dragBehaviorB;
  91653. private _startDistance;
  91654. private _initialScale;
  91655. private _targetScale;
  91656. private _ownerNode;
  91657. private _sceneRenderObserver;
  91658. /**
  91659. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91660. */
  91661. constructor();
  91662. /**
  91663. * The name of the behavior
  91664. */
  91665. readonly name: string;
  91666. /**
  91667. * Initializes the behavior
  91668. */
  91669. init(): void;
  91670. private _getCurrentDistance;
  91671. /**
  91672. * Attaches the scale behavior the passed in mesh
  91673. * @param ownerNode The mesh that will be scaled around once attached
  91674. */
  91675. attach(ownerNode: Mesh): void;
  91676. /**
  91677. * Detaches the behavior from the mesh
  91678. */
  91679. detach(): void;
  91680. }
  91681. }
  91682. declare module BABYLON {
  91683. /**
  91684. * 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
  91685. */
  91686. export class SixDofDragBehavior implements Behavior<Mesh> {
  91687. private static _virtualScene;
  91688. private _ownerNode;
  91689. private _sceneRenderObserver;
  91690. private _scene;
  91691. private _targetPosition;
  91692. private _virtualOriginMesh;
  91693. private _virtualDragMesh;
  91694. private _pointerObserver;
  91695. private _moving;
  91696. private _startingOrientation;
  91697. /**
  91698. * 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)
  91699. */
  91700. private zDragFactor;
  91701. /**
  91702. * If the object should rotate to face the drag origin
  91703. */
  91704. rotateDraggedObject: boolean;
  91705. /**
  91706. * If the behavior is currently in a dragging state
  91707. */
  91708. dragging: boolean;
  91709. /**
  91710. * 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)
  91711. */
  91712. dragDeltaRatio: number;
  91713. /**
  91714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91715. */
  91716. currentDraggingPointerID: number;
  91717. /**
  91718. * If camera controls should be detached during the drag
  91719. */
  91720. detachCameraControls: boolean;
  91721. /**
  91722. * Fires each time a drag starts
  91723. */
  91724. onDragStartObservable: Observable<{}>;
  91725. /**
  91726. * Fires each time a drag ends (eg. mouse release after drag)
  91727. */
  91728. onDragEndObservable: Observable<{}>;
  91729. /**
  91730. * 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
  91731. */
  91732. constructor();
  91733. /**
  91734. * The name of the behavior
  91735. */
  91736. readonly name: string;
  91737. /**
  91738. * Initializes the behavior
  91739. */
  91740. init(): void;
  91741. /**
  91742. * Attaches the scale behavior the passed in mesh
  91743. * @param ownerNode The mesh that will be scaled around once attached
  91744. */
  91745. attach(ownerNode: Mesh): void;
  91746. /**
  91747. * Detaches the behavior from the mesh
  91748. */
  91749. detach(): void;
  91750. }
  91751. }
  91752. declare module BABYLON {
  91753. /**
  91754. * Class used to apply inverse kinematics to bones
  91755. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91756. */
  91757. export class BoneIKController {
  91758. private static _tmpVecs;
  91759. private static _tmpQuat;
  91760. private static _tmpMats;
  91761. /**
  91762. * Gets or sets the target mesh
  91763. */
  91764. targetMesh: AbstractMesh;
  91765. /** Gets or sets the mesh used as pole */
  91766. poleTargetMesh: AbstractMesh;
  91767. /**
  91768. * Gets or sets the bone used as pole
  91769. */
  91770. poleTargetBone: Nullable<Bone>;
  91771. /**
  91772. * Gets or sets the target position
  91773. */
  91774. targetPosition: Vector3;
  91775. /**
  91776. * Gets or sets the pole target position
  91777. */
  91778. poleTargetPosition: Vector3;
  91779. /**
  91780. * Gets or sets the pole target local offset
  91781. */
  91782. poleTargetLocalOffset: Vector3;
  91783. /**
  91784. * Gets or sets the pole angle
  91785. */
  91786. poleAngle: number;
  91787. /**
  91788. * Gets or sets the mesh associated with the controller
  91789. */
  91790. mesh: AbstractMesh;
  91791. /**
  91792. * 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)
  91793. */
  91794. slerpAmount: number;
  91795. private _bone1Quat;
  91796. private _bone1Mat;
  91797. private _bone2Ang;
  91798. private _bone1;
  91799. private _bone2;
  91800. private _bone1Length;
  91801. private _bone2Length;
  91802. private _maxAngle;
  91803. private _maxReach;
  91804. private _rightHandedSystem;
  91805. private _bendAxis;
  91806. private _slerping;
  91807. private _adjustRoll;
  91808. /**
  91809. * Gets or sets maximum allowed angle
  91810. */
  91811. maxAngle: number;
  91812. /**
  91813. * Creates a new BoneIKController
  91814. * @param mesh defines the mesh to control
  91815. * @param bone defines the bone to control
  91816. * @param options defines options to set up the controller
  91817. */
  91818. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91819. targetMesh?: AbstractMesh;
  91820. poleTargetMesh?: AbstractMesh;
  91821. poleTargetBone?: Bone;
  91822. poleTargetLocalOffset?: Vector3;
  91823. poleAngle?: number;
  91824. bendAxis?: Vector3;
  91825. maxAngle?: number;
  91826. slerpAmount?: number;
  91827. });
  91828. private _setMaxAngle;
  91829. /**
  91830. * Force the controller to update the bones
  91831. */
  91832. update(): void;
  91833. }
  91834. }
  91835. declare module BABYLON {
  91836. /**
  91837. * Class used to make a bone look toward a point in space
  91838. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91839. */
  91840. export class BoneLookController {
  91841. private static _tmpVecs;
  91842. private static _tmpQuat;
  91843. private static _tmpMats;
  91844. /**
  91845. * The target Vector3 that the bone will look at
  91846. */
  91847. target: Vector3;
  91848. /**
  91849. * The mesh that the bone is attached to
  91850. */
  91851. mesh: AbstractMesh;
  91852. /**
  91853. * The bone that will be looking to the target
  91854. */
  91855. bone: Bone;
  91856. /**
  91857. * The up axis of the coordinate system that is used when the bone is rotated
  91858. */
  91859. upAxis: Vector3;
  91860. /**
  91861. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91862. */
  91863. upAxisSpace: Space;
  91864. /**
  91865. * Used to make an adjustment to the yaw of the bone
  91866. */
  91867. adjustYaw: number;
  91868. /**
  91869. * Used to make an adjustment to the pitch of the bone
  91870. */
  91871. adjustPitch: number;
  91872. /**
  91873. * Used to make an adjustment to the roll of the bone
  91874. */
  91875. adjustRoll: number;
  91876. /**
  91877. * 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)
  91878. */
  91879. slerpAmount: number;
  91880. private _minYaw;
  91881. private _maxYaw;
  91882. private _minPitch;
  91883. private _maxPitch;
  91884. private _minYawSin;
  91885. private _minYawCos;
  91886. private _maxYawSin;
  91887. private _maxYawCos;
  91888. private _midYawConstraint;
  91889. private _minPitchTan;
  91890. private _maxPitchTan;
  91891. private _boneQuat;
  91892. private _slerping;
  91893. private _transformYawPitch;
  91894. private _transformYawPitchInv;
  91895. private _firstFrameSkipped;
  91896. private _yawRange;
  91897. private _fowardAxis;
  91898. /**
  91899. * Gets or sets the minimum yaw angle that the bone can look to
  91900. */
  91901. minYaw: number;
  91902. /**
  91903. * Gets or sets the maximum yaw angle that the bone can look to
  91904. */
  91905. maxYaw: number;
  91906. /**
  91907. * Gets or sets the minimum pitch angle that the bone can look to
  91908. */
  91909. minPitch: number;
  91910. /**
  91911. * Gets or sets the maximum pitch angle that the bone can look to
  91912. */
  91913. maxPitch: number;
  91914. /**
  91915. * Create a BoneLookController
  91916. * @param mesh the mesh that the bone belongs to
  91917. * @param bone the bone that will be looking to the target
  91918. * @param target the target Vector3 to look at
  91919. * @param options optional settings:
  91920. * * maxYaw: the maximum angle the bone will yaw to
  91921. * * minYaw: the minimum angle the bone will yaw to
  91922. * * maxPitch: the maximum angle the bone will pitch to
  91923. * * minPitch: the minimum angle the bone will yaw to
  91924. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91925. * * upAxis: the up axis of the coordinate system
  91926. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91927. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91928. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91929. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91930. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91931. * * adjustRoll: used to make an adjustment to the roll of the bone
  91932. **/
  91933. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91934. maxYaw?: number;
  91935. minYaw?: number;
  91936. maxPitch?: number;
  91937. minPitch?: number;
  91938. slerpAmount?: number;
  91939. upAxis?: Vector3;
  91940. upAxisSpace?: Space;
  91941. yawAxis?: Vector3;
  91942. pitchAxis?: Vector3;
  91943. adjustYaw?: number;
  91944. adjustPitch?: number;
  91945. adjustRoll?: number;
  91946. });
  91947. /**
  91948. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91949. */
  91950. update(): void;
  91951. private _getAngleDiff;
  91952. private _getAngleBetween;
  91953. private _isAngleBetween;
  91954. }
  91955. }
  91956. declare module BABYLON {
  91957. /**
  91958. * Manage the gamepad inputs to control an arc rotate camera.
  91959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91960. */
  91961. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91962. /**
  91963. * Defines the camera the input is attached to.
  91964. */
  91965. camera: ArcRotateCamera;
  91966. /**
  91967. * Defines the gamepad the input is gathering event from.
  91968. */
  91969. gamepad: Nullable<Gamepad>;
  91970. /**
  91971. * Defines the gamepad rotation sensiblity.
  91972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91973. */
  91974. gamepadRotationSensibility: number;
  91975. /**
  91976. * Defines the gamepad move sensiblity.
  91977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91978. */
  91979. gamepadMoveSensibility: number;
  91980. private _onGamepadConnectedObserver;
  91981. private _onGamepadDisconnectedObserver;
  91982. /**
  91983. * Attach the input controls to a specific dom element to get the input from.
  91984. * @param element Defines the element the controls should be listened from
  91985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91986. */
  91987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91988. /**
  91989. * Detach the current controls from the specified dom element.
  91990. * @param element Defines the element to stop listening the inputs from
  91991. */
  91992. detachControl(element: Nullable<HTMLElement>): void;
  91993. /**
  91994. * Update the current camera state depending on the inputs that have been used this frame.
  91995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91996. */
  91997. checkInputs(): void;
  91998. /**
  91999. * Gets the class name of the current intput.
  92000. * @returns the class name
  92001. */
  92002. getClassName(): string;
  92003. /**
  92004. * Get the friendly name associated with the input class.
  92005. * @returns the input friendly name
  92006. */
  92007. getSimpleName(): string;
  92008. }
  92009. }
  92010. declare module BABYLON {
  92011. interface ArcRotateCameraInputsManager {
  92012. /**
  92013. * Add orientation input support to the input manager.
  92014. * @returns the current input manager
  92015. */
  92016. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92017. }
  92018. /**
  92019. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92021. */
  92022. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92023. /**
  92024. * Defines the camera the input is attached to.
  92025. */
  92026. camera: ArcRotateCamera;
  92027. /**
  92028. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92029. */
  92030. alphaCorrection: number;
  92031. /**
  92032. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92033. */
  92034. gammaCorrection: number;
  92035. private _alpha;
  92036. private _gamma;
  92037. private _dirty;
  92038. private _deviceOrientationHandler;
  92039. /**
  92040. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92041. */
  92042. constructor();
  92043. /**
  92044. * Attach the input controls to a specific dom element to get the input from.
  92045. * @param element Defines the element the controls should be listened from
  92046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92047. */
  92048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92049. /** @hidden */
  92050. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92051. /**
  92052. * Update the current camera state depending on the inputs that have been used this frame.
  92053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92054. */
  92055. checkInputs(): void;
  92056. /**
  92057. * Detach the current controls from the specified dom element.
  92058. * @param element Defines the element to stop listening the inputs from
  92059. */
  92060. detachControl(element: Nullable<HTMLElement>): void;
  92061. /**
  92062. * Gets the class name of the current intput.
  92063. * @returns the class name
  92064. */
  92065. getClassName(): string;
  92066. /**
  92067. * Get the friendly name associated with the input class.
  92068. * @returns the input friendly name
  92069. */
  92070. getSimpleName(): string;
  92071. }
  92072. }
  92073. declare module BABYLON {
  92074. /**
  92075. * Listen to mouse events to control the camera.
  92076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92077. */
  92078. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92079. /**
  92080. * Defines the camera the input is attached to.
  92081. */
  92082. camera: FlyCamera;
  92083. /**
  92084. * Defines if touch is enabled. (Default is true.)
  92085. */
  92086. touchEnabled: boolean;
  92087. /**
  92088. * Defines the buttons associated with the input to handle camera rotation.
  92089. */
  92090. buttons: number[];
  92091. /**
  92092. * Assign buttons for Yaw control.
  92093. */
  92094. buttonsYaw: number[];
  92095. /**
  92096. * Assign buttons for Pitch control.
  92097. */
  92098. buttonsPitch: number[];
  92099. /**
  92100. * Assign buttons for Roll control.
  92101. */
  92102. buttonsRoll: number[];
  92103. /**
  92104. * Detect if any button is being pressed while mouse is moved.
  92105. * -1 = Mouse locked.
  92106. * 0 = Left button.
  92107. * 1 = Middle Button.
  92108. * 2 = Right Button.
  92109. */
  92110. activeButton: number;
  92111. /**
  92112. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92113. * Higher values reduce its sensitivity.
  92114. */
  92115. angularSensibility: number;
  92116. private _mousemoveCallback;
  92117. private _observer;
  92118. private _rollObserver;
  92119. private previousPosition;
  92120. private noPreventDefault;
  92121. private element;
  92122. /**
  92123. * Listen to mouse events to control the camera.
  92124. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92126. */
  92127. constructor(touchEnabled?: boolean);
  92128. /**
  92129. * Attach the mouse control to the HTML DOM element.
  92130. * @param element Defines the element that listens to the input events.
  92131. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92132. */
  92133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92134. /**
  92135. * Detach the current controls from the specified dom element.
  92136. * @param element Defines the element to stop listening the inputs from
  92137. */
  92138. detachControl(element: Nullable<HTMLElement>): void;
  92139. /**
  92140. * Gets the class name of the current input.
  92141. * @returns the class name.
  92142. */
  92143. getClassName(): string;
  92144. /**
  92145. * Get the friendly name associated with the input class.
  92146. * @returns the input's friendly name.
  92147. */
  92148. getSimpleName(): string;
  92149. private _pointerInput;
  92150. private _onMouseMove;
  92151. /**
  92152. * Rotate camera by mouse offset.
  92153. */
  92154. private rotateCamera;
  92155. }
  92156. }
  92157. declare module BABYLON {
  92158. /**
  92159. * Default Inputs manager for the FlyCamera.
  92160. * It groups all the default supported inputs for ease of use.
  92161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92162. */
  92163. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92164. /**
  92165. * Instantiates a new FlyCameraInputsManager.
  92166. * @param camera Defines the camera the inputs belong to.
  92167. */
  92168. constructor(camera: FlyCamera);
  92169. /**
  92170. * Add keyboard input support to the input manager.
  92171. * @returns the new FlyCameraKeyboardMoveInput().
  92172. */
  92173. addKeyboard(): FlyCameraInputsManager;
  92174. /**
  92175. * Add mouse input support to the input manager.
  92176. * @param touchEnabled Enable touch screen support.
  92177. * @returns the new FlyCameraMouseInput().
  92178. */
  92179. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92180. }
  92181. }
  92182. declare module BABYLON {
  92183. /**
  92184. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92185. * such as in a 3D Space Shooter or a Flight Simulator.
  92186. */
  92187. export class FlyCamera extends TargetCamera {
  92188. /**
  92189. * Define the collision ellipsoid of the camera.
  92190. * This is helpful for simulating a camera body, like a player's body.
  92191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92192. */
  92193. ellipsoid: Vector3;
  92194. /**
  92195. * Define an offset for the position of the ellipsoid around the camera.
  92196. * This can be helpful if the camera is attached away from the player's body center,
  92197. * such as at its head.
  92198. */
  92199. ellipsoidOffset: Vector3;
  92200. /**
  92201. * Enable or disable collisions of the camera with the rest of the scene objects.
  92202. */
  92203. checkCollisions: boolean;
  92204. /**
  92205. * Enable or disable gravity on the camera.
  92206. */
  92207. applyGravity: boolean;
  92208. /**
  92209. * Define the current direction the camera is moving to.
  92210. */
  92211. cameraDirection: Vector3;
  92212. /**
  92213. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92214. * This overrides and empties cameraRotation.
  92215. */
  92216. rotationQuaternion: Quaternion;
  92217. /**
  92218. * Track Roll to maintain the wanted Rolling when looking around.
  92219. */
  92220. _trackRoll: number;
  92221. /**
  92222. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92223. */
  92224. rollCorrect: number;
  92225. /**
  92226. * Mimic a banked turn, Rolling the camera when Yawing.
  92227. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92228. */
  92229. bankedTurn: boolean;
  92230. /**
  92231. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92232. */
  92233. bankedTurnLimit: number;
  92234. /**
  92235. * Value of 0 disables the banked Roll.
  92236. * Value of 1 is equal to the Yaw angle in radians.
  92237. */
  92238. bankedTurnMultiplier: number;
  92239. /**
  92240. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92241. */
  92242. inputs: FlyCameraInputsManager;
  92243. /**
  92244. * Gets the input sensibility for mouse input.
  92245. * Higher values reduce sensitivity.
  92246. */
  92247. /**
  92248. * Sets the input sensibility for a mouse input.
  92249. * Higher values reduce sensitivity.
  92250. */
  92251. angularSensibility: number;
  92252. /**
  92253. * Get the keys for camera movement forward.
  92254. */
  92255. /**
  92256. * Set the keys for camera movement forward.
  92257. */
  92258. keysForward: number[];
  92259. /**
  92260. * Get the keys for camera movement backward.
  92261. */
  92262. keysBackward: number[];
  92263. /**
  92264. * Get the keys for camera movement up.
  92265. */
  92266. /**
  92267. * Set the keys for camera movement up.
  92268. */
  92269. keysUp: number[];
  92270. /**
  92271. * Get the keys for camera movement down.
  92272. */
  92273. /**
  92274. * Set the keys for camera movement down.
  92275. */
  92276. keysDown: number[];
  92277. /**
  92278. * Get the keys for camera movement left.
  92279. */
  92280. /**
  92281. * Set the keys for camera movement left.
  92282. */
  92283. keysLeft: number[];
  92284. /**
  92285. * Set the keys for camera movement right.
  92286. */
  92287. /**
  92288. * Set the keys for camera movement right.
  92289. */
  92290. keysRight: number[];
  92291. /**
  92292. * Event raised when the camera collides with a mesh in the scene.
  92293. */
  92294. onCollide: (collidedMesh: AbstractMesh) => void;
  92295. private _collider;
  92296. private _needMoveForGravity;
  92297. private _oldPosition;
  92298. private _diffPosition;
  92299. private _newPosition;
  92300. /** @hidden */
  92301. _localDirection: Vector3;
  92302. /** @hidden */
  92303. _transformedDirection: Vector3;
  92304. /**
  92305. * Instantiates a FlyCamera.
  92306. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92307. * such as in a 3D Space Shooter or a Flight Simulator.
  92308. * @param name Define the name of the camera in the scene.
  92309. * @param position Define the starting position of the camera in the scene.
  92310. * @param scene Define the scene the camera belongs to.
  92311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92312. */
  92313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92314. /**
  92315. * Attach a control to the HTML DOM element.
  92316. * @param element Defines the element that listens to the input events.
  92317. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92318. */
  92319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92320. /**
  92321. * Detach a control from the HTML DOM element.
  92322. * The camera will stop reacting to that input.
  92323. * @param element Defines the element that listens to the input events.
  92324. */
  92325. detachControl(element: HTMLElement): void;
  92326. private _collisionMask;
  92327. /**
  92328. * Get the mask that the camera ignores in collision events.
  92329. */
  92330. /**
  92331. * Set the mask that the camera ignores in collision events.
  92332. */
  92333. collisionMask: number;
  92334. /** @hidden */
  92335. _collideWithWorld(displacement: Vector3): void;
  92336. /** @hidden */
  92337. private _onCollisionPositionChange;
  92338. /** @hidden */
  92339. _checkInputs(): void;
  92340. /** @hidden */
  92341. _decideIfNeedsToMove(): boolean;
  92342. /** @hidden */
  92343. _updatePosition(): void;
  92344. /**
  92345. * Restore the Roll to its target value at the rate specified.
  92346. * @param rate - Higher means slower restoring.
  92347. * @hidden
  92348. */
  92349. restoreRoll(rate: number): void;
  92350. /**
  92351. * Destroy the camera and release the current resources held by it.
  92352. */
  92353. dispose(): void;
  92354. /**
  92355. * Get the current object class name.
  92356. * @returns the class name.
  92357. */
  92358. getClassName(): string;
  92359. }
  92360. }
  92361. declare module BABYLON {
  92362. /**
  92363. * Listen to keyboard events to control the camera.
  92364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92365. */
  92366. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  92367. /**
  92368. * Defines the camera the input is attached to.
  92369. */
  92370. camera: FlyCamera;
  92371. /**
  92372. * The list of keyboard keys used to control the forward move of the camera.
  92373. */
  92374. keysForward: number[];
  92375. /**
  92376. * The list of keyboard keys used to control the backward move of the camera.
  92377. */
  92378. keysBackward: number[];
  92379. /**
  92380. * The list of keyboard keys used to control the forward move of the camera.
  92381. */
  92382. keysUp: number[];
  92383. /**
  92384. * The list of keyboard keys used to control the backward move of the camera.
  92385. */
  92386. keysDown: number[];
  92387. /**
  92388. * The list of keyboard keys used to control the right strafe move of the camera.
  92389. */
  92390. keysRight: number[];
  92391. /**
  92392. * The list of keyboard keys used to control the left strafe move of the camera.
  92393. */
  92394. keysLeft: number[];
  92395. private _keys;
  92396. private _onCanvasBlurObserver;
  92397. private _onKeyboardObserver;
  92398. private _engine;
  92399. private _scene;
  92400. /**
  92401. * Attach the input controls to a specific dom element to get the input from.
  92402. * @param element Defines the element the controls should be listened from
  92403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92404. */
  92405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92406. /**
  92407. * Detach the current controls from the specified dom element.
  92408. * @param element Defines the element to stop listening the inputs from
  92409. */
  92410. detachControl(element: Nullable<HTMLElement>): void;
  92411. /**
  92412. * Gets the class name of the current intput.
  92413. * @returns the class name
  92414. */
  92415. getClassName(): string;
  92416. /** @hidden */
  92417. _onLostFocus(e: FocusEvent): void;
  92418. /**
  92419. * Get the friendly name associated with the input class.
  92420. * @returns the input friendly name
  92421. */
  92422. getSimpleName(): string;
  92423. /**
  92424. * Update the current camera state depending on the inputs that have been used this frame.
  92425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92426. */
  92427. checkInputs(): void;
  92428. }
  92429. }
  92430. declare module BABYLON {
  92431. interface FreeCameraInputsManager {
  92432. /**
  92433. * Add orientation input support to the input manager.
  92434. * @returns the current input manager
  92435. */
  92436. addDeviceOrientation(): FreeCameraInputsManager;
  92437. }
  92438. /**
  92439. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  92440. * Screen rotation is taken into account.
  92441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92442. */
  92443. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  92444. private _camera;
  92445. private _screenOrientationAngle;
  92446. private _constantTranform;
  92447. private _screenQuaternion;
  92448. private _alpha;
  92449. private _beta;
  92450. private _gamma;
  92451. /**
  92452. * Instantiates a new input
  92453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92454. */
  92455. constructor();
  92456. /**
  92457. * Define the camera controlled by the input.
  92458. */
  92459. camera: FreeCamera;
  92460. /**
  92461. * Attach the input controls to a specific dom element to get the input from.
  92462. * @param element Defines the element the controls should be listened from
  92463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92464. */
  92465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92466. private _orientationChanged;
  92467. private _deviceOrientation;
  92468. /**
  92469. * Detach the current controls from the specified dom element.
  92470. * @param element Defines the element to stop listening the inputs from
  92471. */
  92472. detachControl(element: Nullable<HTMLElement>): void;
  92473. /**
  92474. * Update the current camera state depending on the inputs that have been used this frame.
  92475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92476. */
  92477. checkInputs(): void;
  92478. /**
  92479. * Gets the class name of the current intput.
  92480. * @returns the class name
  92481. */
  92482. getClassName(): string;
  92483. /**
  92484. * Get the friendly name associated with the input class.
  92485. * @returns the input friendly name
  92486. */
  92487. getSimpleName(): string;
  92488. }
  92489. }
  92490. declare module BABYLON {
  92491. /**
  92492. * Manage the gamepad inputs to control a free camera.
  92493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92494. */
  92495. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92496. /**
  92497. * Define the camera the input is attached to.
  92498. */
  92499. camera: FreeCamera;
  92500. /**
  92501. * Define the Gamepad controlling the input
  92502. */
  92503. gamepad: Nullable<Gamepad>;
  92504. /**
  92505. * Defines the gamepad rotation sensiblity.
  92506. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92507. */
  92508. gamepadAngularSensibility: number;
  92509. /**
  92510. * Defines the gamepad move sensiblity.
  92511. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92512. */
  92513. gamepadMoveSensibility: number;
  92514. private _onGamepadConnectedObserver;
  92515. private _onGamepadDisconnectedObserver;
  92516. private _cameraTransform;
  92517. private _deltaTransform;
  92518. private _vector3;
  92519. private _vector2;
  92520. /**
  92521. * Attach the input controls to a specific dom element to get the input from.
  92522. * @param element Defines the element the controls should be listened from
  92523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92524. */
  92525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92526. /**
  92527. * Detach the current controls from the specified dom element.
  92528. * @param element Defines the element to stop listening the inputs from
  92529. */
  92530. detachControl(element: Nullable<HTMLElement>): void;
  92531. /**
  92532. * Update the current camera state depending on the inputs that have been used this frame.
  92533. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92534. */
  92535. checkInputs(): void;
  92536. /**
  92537. * Gets the class name of the current intput.
  92538. * @returns the class name
  92539. */
  92540. getClassName(): string;
  92541. /**
  92542. * Get the friendly name associated with the input class.
  92543. * @returns the input friendly name
  92544. */
  92545. getSimpleName(): string;
  92546. }
  92547. }
  92548. declare module BABYLON {
  92549. /**
  92550. * Defines the potential axis of a Joystick
  92551. */
  92552. export enum JoystickAxis {
  92553. /** X axis */
  92554. X = 0,
  92555. /** Y axis */
  92556. Y = 1,
  92557. /** Z axis */
  92558. Z = 2
  92559. }
  92560. /**
  92561. * Class used to define virtual joystick (used in touch mode)
  92562. */
  92563. export class VirtualJoystick {
  92564. /**
  92565. * Gets or sets a boolean indicating that left and right values must be inverted
  92566. */
  92567. reverseLeftRight: boolean;
  92568. /**
  92569. * Gets or sets a boolean indicating that up and down values must be inverted
  92570. */
  92571. reverseUpDown: boolean;
  92572. /**
  92573. * Gets the offset value for the position (ie. the change of the position value)
  92574. */
  92575. deltaPosition: Vector3;
  92576. /**
  92577. * Gets a boolean indicating if the virtual joystick was pressed
  92578. */
  92579. pressed: boolean;
  92580. /**
  92581. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92582. */
  92583. static Canvas: Nullable<HTMLCanvasElement>;
  92584. private static _globalJoystickIndex;
  92585. private static vjCanvasContext;
  92586. private static vjCanvasWidth;
  92587. private static vjCanvasHeight;
  92588. private static halfWidth;
  92589. private _action;
  92590. private _axisTargetedByLeftAndRight;
  92591. private _axisTargetedByUpAndDown;
  92592. private _joystickSensibility;
  92593. private _inversedSensibility;
  92594. private _joystickPointerID;
  92595. private _joystickColor;
  92596. private _joystickPointerPos;
  92597. private _joystickPreviousPointerPos;
  92598. private _joystickPointerStartPos;
  92599. private _deltaJoystickVector;
  92600. private _leftJoystick;
  92601. private _touches;
  92602. private _onPointerDownHandlerRef;
  92603. private _onPointerMoveHandlerRef;
  92604. private _onPointerUpHandlerRef;
  92605. private _onResize;
  92606. /**
  92607. * Creates a new virtual joystick
  92608. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92609. */
  92610. constructor(leftJoystick?: boolean);
  92611. /**
  92612. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92613. * @param newJoystickSensibility defines the new sensibility
  92614. */
  92615. setJoystickSensibility(newJoystickSensibility: number): void;
  92616. private _onPointerDown;
  92617. private _onPointerMove;
  92618. private _onPointerUp;
  92619. /**
  92620. * Change the color of the virtual joystick
  92621. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92622. */
  92623. setJoystickColor(newColor: string): void;
  92624. /**
  92625. * Defines a callback to call when the joystick is touched
  92626. * @param action defines the callback
  92627. */
  92628. setActionOnTouch(action: () => any): void;
  92629. /**
  92630. * Defines which axis you'd like to control for left & right
  92631. * @param axis defines the axis to use
  92632. */
  92633. setAxisForLeftRight(axis: JoystickAxis): void;
  92634. /**
  92635. * Defines which axis you'd like to control for up & down
  92636. * @param axis defines the axis to use
  92637. */
  92638. setAxisForUpDown(axis: JoystickAxis): void;
  92639. private _drawVirtualJoystick;
  92640. /**
  92641. * Release internal HTML canvas
  92642. */
  92643. releaseCanvas(): void;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. interface FreeCameraInputsManager {
  92648. /**
  92649. * Add virtual joystick input support to the input manager.
  92650. * @returns the current input manager
  92651. */
  92652. addVirtualJoystick(): FreeCameraInputsManager;
  92653. }
  92654. /**
  92655. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92657. */
  92658. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92659. /**
  92660. * Defines the camera the input is attached to.
  92661. */
  92662. camera: FreeCamera;
  92663. private _leftjoystick;
  92664. private _rightjoystick;
  92665. /**
  92666. * Gets the left stick of the virtual joystick.
  92667. * @returns The virtual Joystick
  92668. */
  92669. getLeftJoystick(): VirtualJoystick;
  92670. /**
  92671. * Gets the right stick of the virtual joystick.
  92672. * @returns The virtual Joystick
  92673. */
  92674. getRightJoystick(): VirtualJoystick;
  92675. /**
  92676. * Update the current camera state depending on the inputs that have been used this frame.
  92677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92678. */
  92679. checkInputs(): void;
  92680. /**
  92681. * Attach the input controls to a specific dom element to get the input from.
  92682. * @param element Defines the element the controls should be listened from
  92683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92684. */
  92685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92686. /**
  92687. * Detach the current controls from the specified dom element.
  92688. * @param element Defines the element to stop listening the inputs from
  92689. */
  92690. detachControl(element: Nullable<HTMLElement>): void;
  92691. /**
  92692. * Gets the class name of the current intput.
  92693. * @returns the class name
  92694. */
  92695. getClassName(): string;
  92696. /**
  92697. * Get the friendly name associated with the input class.
  92698. * @returns the input friendly name
  92699. */
  92700. getSimpleName(): string;
  92701. }
  92702. }
  92703. declare module BABYLON {
  92704. /**
  92705. * This represents a FPS type of camera controlled by touch.
  92706. * This is like a universal camera minus the Gamepad controls.
  92707. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92708. */
  92709. export class TouchCamera extends FreeCamera {
  92710. /**
  92711. * Defines the touch sensibility for rotation.
  92712. * The higher the faster.
  92713. */
  92714. touchAngularSensibility: number;
  92715. /**
  92716. * Defines the touch sensibility for move.
  92717. * The higher the faster.
  92718. */
  92719. touchMoveSensibility: number;
  92720. /**
  92721. * Instantiates a new touch camera.
  92722. * This represents a FPS type of camera controlled by touch.
  92723. * This is like a universal camera minus the Gamepad controls.
  92724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92725. * @param name Define the name of the camera in the scene
  92726. * @param position Define the start position of the camera in the scene
  92727. * @param scene Define the scene the camera belongs to
  92728. */
  92729. constructor(name: string, position: Vector3, scene: Scene);
  92730. /**
  92731. * Gets the current object class name.
  92732. * @return the class name
  92733. */
  92734. getClassName(): string;
  92735. /** @hidden */
  92736. _setupInputs(): void;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. /**
  92741. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92742. * being tilted forward or back and left or right.
  92743. */
  92744. export class DeviceOrientationCamera extends FreeCamera {
  92745. private _initialQuaternion;
  92746. private _quaternionCache;
  92747. /**
  92748. * Creates a new device orientation camera
  92749. * @param name The name of the camera
  92750. * @param position The start position camera
  92751. * @param scene The scene the camera belongs to
  92752. */
  92753. constructor(name: string, position: Vector3, scene: Scene);
  92754. /**
  92755. * Gets the current instance class name ("DeviceOrientationCamera").
  92756. * This helps avoiding instanceof at run time.
  92757. * @returns the class name
  92758. */
  92759. getClassName(): string;
  92760. /**
  92761. * @hidden
  92762. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92763. */
  92764. _checkInputs(): void;
  92765. /**
  92766. * Reset the camera to its default orientation on the specified axis only.
  92767. * @param axis The axis to reset
  92768. */
  92769. resetToCurrentRotation(axis?: Axis): void;
  92770. }
  92771. }
  92772. declare module BABYLON {
  92773. /**
  92774. * Manage the keyboard inputs to control the movement of a follow camera.
  92775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92776. */
  92777. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92778. /**
  92779. * Defines the camera the input is attached to.
  92780. */
  92781. camera: FollowCamera;
  92782. /**
  92783. * Defines the list of key codes associated with the up action (increase heightOffset)
  92784. */
  92785. keysHeightOffsetIncr: number[];
  92786. /**
  92787. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92788. */
  92789. keysHeightOffsetDecr: number[];
  92790. /**
  92791. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92792. */
  92793. keysHeightOffsetModifierAlt: boolean;
  92794. /**
  92795. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92796. */
  92797. keysHeightOffsetModifierCtrl: boolean;
  92798. /**
  92799. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92800. */
  92801. keysHeightOffsetModifierShift: boolean;
  92802. /**
  92803. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92804. */
  92805. keysRotationOffsetIncr: number[];
  92806. /**
  92807. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92808. */
  92809. keysRotationOffsetDecr: number[];
  92810. /**
  92811. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92812. */
  92813. keysRotationOffsetModifierAlt: boolean;
  92814. /**
  92815. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92816. */
  92817. keysRotationOffsetModifierCtrl: boolean;
  92818. /**
  92819. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92820. */
  92821. keysRotationOffsetModifierShift: boolean;
  92822. /**
  92823. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92824. */
  92825. keysRadiusIncr: number[];
  92826. /**
  92827. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92828. */
  92829. keysRadiusDecr: number[];
  92830. /**
  92831. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92832. */
  92833. keysRadiusModifierAlt: boolean;
  92834. /**
  92835. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92836. */
  92837. keysRadiusModifierCtrl: boolean;
  92838. /**
  92839. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92840. */
  92841. keysRadiusModifierShift: boolean;
  92842. /**
  92843. * Defines the rate of change of heightOffset.
  92844. */
  92845. heightSensibility: number;
  92846. /**
  92847. * Defines the rate of change of rotationOffset.
  92848. */
  92849. rotationSensibility: number;
  92850. /**
  92851. * Defines the rate of change of radius.
  92852. */
  92853. radiusSensibility: number;
  92854. private _keys;
  92855. private _ctrlPressed;
  92856. private _altPressed;
  92857. private _shiftPressed;
  92858. private _onCanvasBlurObserver;
  92859. private _onKeyboardObserver;
  92860. private _engine;
  92861. private _scene;
  92862. /**
  92863. * Attach the input controls to a specific dom element to get the input from.
  92864. * @param element Defines the element the controls should be listened from
  92865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92866. */
  92867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92868. /**
  92869. * Detach the current controls from the specified dom element.
  92870. * @param element Defines the element to stop listening the inputs from
  92871. */
  92872. detachControl(element: Nullable<HTMLElement>): void;
  92873. /**
  92874. * Update the current camera state depending on the inputs that have been used this frame.
  92875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92876. */
  92877. checkInputs(): void;
  92878. /**
  92879. * Gets the class name of the current input.
  92880. * @returns the class name
  92881. */
  92882. getClassName(): string;
  92883. /**
  92884. * Get the friendly name associated with the input class.
  92885. * @returns the input friendly name
  92886. */
  92887. getSimpleName(): string;
  92888. /**
  92889. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92890. * allow modification of the heightOffset value.
  92891. */
  92892. private _modifierHeightOffset;
  92893. /**
  92894. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92895. * allow modification of the rotationOffset value.
  92896. */
  92897. private _modifierRotationOffset;
  92898. /**
  92899. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92900. * allow modification of the radius value.
  92901. */
  92902. private _modifierRadius;
  92903. }
  92904. }
  92905. declare module BABYLON {
  92906. /**
  92907. * Manage the mouse wheel inputs to control a follow camera.
  92908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92909. */
  92910. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92911. /**
  92912. * Defines the camera the input is attached to.
  92913. */
  92914. camera: FollowCamera;
  92915. /**
  92916. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92917. */
  92918. axisControlRadius: boolean;
  92919. /**
  92920. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92921. */
  92922. axisControlHeight: boolean;
  92923. /**
  92924. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92925. */
  92926. axisControlRotation: boolean;
  92927. /**
  92928. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92929. * relation to mouseWheel events.
  92930. */
  92931. wheelPrecision: number;
  92932. /**
  92933. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92934. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92935. */
  92936. wheelDeltaPercentage: number;
  92937. private _wheel;
  92938. private _observer;
  92939. /**
  92940. * Attach the input controls to a specific dom element to get the input from.
  92941. * @param element Defines the element the controls should be listened from
  92942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92943. */
  92944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92945. /**
  92946. * Detach the current controls from the specified dom element.
  92947. * @param element Defines the element to stop listening the inputs from
  92948. */
  92949. detachControl(element: Nullable<HTMLElement>): void;
  92950. /**
  92951. * Gets the class name of the current intput.
  92952. * @returns the class name
  92953. */
  92954. getClassName(): string;
  92955. /**
  92956. * Get the friendly name associated with the input class.
  92957. * @returns the input friendly name
  92958. */
  92959. getSimpleName(): string;
  92960. }
  92961. }
  92962. declare module BABYLON {
  92963. /**
  92964. * Default Inputs manager for the FollowCamera.
  92965. * It groups all the default supported inputs for ease of use.
  92966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92967. */
  92968. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92969. /**
  92970. * Instantiates a new FollowCameraInputsManager.
  92971. * @param camera Defines the camera the inputs belong to
  92972. */
  92973. constructor(camera: FollowCamera);
  92974. /**
  92975. * Add keyboard input support to the input manager.
  92976. * @returns the current input manager
  92977. */
  92978. addKeyboard(): FollowCameraInputsManager;
  92979. /**
  92980. * Add mouse wheel input support to the input manager.
  92981. * @returns the current input manager
  92982. */
  92983. addMouseWheel(): FollowCameraInputsManager;
  92984. /**
  92985. * Add pointers input support to the input manager.
  92986. * @returns the current input manager
  92987. */
  92988. addPointers(): FollowCameraInputsManager;
  92989. /**
  92990. * Add orientation input support to the input manager.
  92991. * @returns the current input manager
  92992. */
  92993. addVRDeviceOrientation(): FollowCameraInputsManager;
  92994. }
  92995. }
  92996. declare module BABYLON {
  92997. /**
  92998. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92999. * an arc rotate version arcFollowCamera are available.
  93000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93001. */
  93002. export class FollowCamera extends TargetCamera {
  93003. /**
  93004. * Distance the follow camera should follow an object at
  93005. */
  93006. radius: number;
  93007. /**
  93008. * Minimum allowed distance of the camera to the axis of rotation
  93009. * (The camera can not get closer).
  93010. * This can help limiting how the Camera is able to move in the scene.
  93011. */
  93012. lowerRadiusLimit: Nullable<number>;
  93013. /**
  93014. * Maximum allowed distance of the camera to the axis of rotation
  93015. * (The camera can not get further).
  93016. * This can help limiting how the Camera is able to move in the scene.
  93017. */
  93018. upperRadiusLimit: Nullable<number>;
  93019. /**
  93020. * Define a rotation offset between the camera and the object it follows
  93021. */
  93022. rotationOffset: number;
  93023. /**
  93024. * Minimum allowed angle to camera position relative to target object.
  93025. * This can help limiting how the Camera is able to move in the scene.
  93026. */
  93027. lowerRotationOffsetLimit: Nullable<number>;
  93028. /**
  93029. * Maximum allowed angle to camera position relative to target object.
  93030. * This can help limiting how the Camera is able to move in the scene.
  93031. */
  93032. upperRotationOffsetLimit: Nullable<number>;
  93033. /**
  93034. * Define a height offset between the camera and the object it follows.
  93035. * It can help following an object from the top (like a car chaing a plane)
  93036. */
  93037. heightOffset: number;
  93038. /**
  93039. * Minimum allowed height of camera position relative to target object.
  93040. * This can help limiting how the Camera is able to move in the scene.
  93041. */
  93042. lowerHeightOffsetLimit: Nullable<number>;
  93043. /**
  93044. * Maximum allowed height of camera position relative to target object.
  93045. * This can help limiting how the Camera is able to move in the scene.
  93046. */
  93047. upperHeightOffsetLimit: Nullable<number>;
  93048. /**
  93049. * Define how fast the camera can accelerate to follow it s target.
  93050. */
  93051. cameraAcceleration: number;
  93052. /**
  93053. * Define the speed limit of the camera following an object.
  93054. */
  93055. maxCameraSpeed: number;
  93056. /**
  93057. * Define the target of the camera.
  93058. */
  93059. lockedTarget: Nullable<AbstractMesh>;
  93060. /**
  93061. * Defines the input associated with the camera.
  93062. */
  93063. inputs: FollowCameraInputsManager;
  93064. /**
  93065. * Instantiates the follow camera.
  93066. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93067. * @param name Define the name of the camera in the scene
  93068. * @param position Define the position of the camera
  93069. * @param scene Define the scene the camera belong to
  93070. * @param lockedTarget Define the target of the camera
  93071. */
  93072. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93073. private _follow;
  93074. /**
  93075. * Attached controls to the current camera.
  93076. * @param element Defines the element the controls should be listened from
  93077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93078. */
  93079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93080. /**
  93081. * Detach the current controls from the camera.
  93082. * The camera will stop reacting to inputs.
  93083. * @param element Defines the element to stop listening the inputs from
  93084. */
  93085. detachControl(element: HTMLElement): void;
  93086. /** @hidden */
  93087. _checkInputs(): void;
  93088. private _checkLimits;
  93089. /**
  93090. * Gets the camera class name.
  93091. * @returns the class name
  93092. */
  93093. getClassName(): string;
  93094. }
  93095. /**
  93096. * Arc Rotate version of the follow camera.
  93097. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93098. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93099. */
  93100. export class ArcFollowCamera extends TargetCamera {
  93101. /** The longitudinal angle of the camera */
  93102. alpha: number;
  93103. /** The latitudinal angle of the camera */
  93104. beta: number;
  93105. /** The radius of the camera from its target */
  93106. radius: number;
  93107. /** Define the camera target (the messh it should follow) */
  93108. target: Nullable<AbstractMesh>;
  93109. private _cartesianCoordinates;
  93110. /**
  93111. * Instantiates a new ArcFollowCamera
  93112. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93113. * @param name Define the name of the camera
  93114. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93115. * @param beta Define the rotation angle of the camera around the elevation axis
  93116. * @param radius Define the radius of the camera from its target point
  93117. * @param target Define the target of the camera
  93118. * @param scene Define the scene the camera belongs to
  93119. */
  93120. constructor(name: string,
  93121. /** The longitudinal angle of the camera */
  93122. alpha: number,
  93123. /** The latitudinal angle of the camera */
  93124. beta: number,
  93125. /** The radius of the camera from its target */
  93126. radius: number,
  93127. /** Define the camera target (the messh it should follow) */
  93128. target: Nullable<AbstractMesh>, scene: Scene);
  93129. private _follow;
  93130. /** @hidden */
  93131. _checkInputs(): void;
  93132. /**
  93133. * Returns the class name of the object.
  93134. * It is mostly used internally for serialization purposes.
  93135. */
  93136. getClassName(): string;
  93137. }
  93138. }
  93139. declare module BABYLON {
  93140. /**
  93141. * 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,
  93142. * which still works and will still be found in many Playgrounds.
  93143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93144. */
  93145. export class UniversalCamera extends TouchCamera {
  93146. /**
  93147. * Defines the gamepad rotation sensiblity.
  93148. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93149. */
  93150. gamepadAngularSensibility: number;
  93151. /**
  93152. * Defines the gamepad move sensiblity.
  93153. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93154. */
  93155. gamepadMoveSensibility: number;
  93156. /**
  93157. * 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,
  93158. * which still works and will still be found in many Playgrounds.
  93159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93160. * @param name Define the name of the camera in the scene
  93161. * @param position Define the start position of the camera in the scene
  93162. * @param scene Define the scene the camera belongs to
  93163. */
  93164. constructor(name: string, position: Vector3, scene: Scene);
  93165. /**
  93166. * Gets the current object class name.
  93167. * @return the class name
  93168. */
  93169. getClassName(): string;
  93170. }
  93171. }
  93172. declare module BABYLON {
  93173. /**
  93174. * This represents a FPS type of camera. This is only here for back compat purpose.
  93175. * Please use the UniversalCamera instead as both are identical.
  93176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93177. */
  93178. export class GamepadCamera extends UniversalCamera {
  93179. /**
  93180. * Instantiates a new Gamepad Camera
  93181. * This represents a FPS type of camera. This is only here for back compat purpose.
  93182. * Please use the UniversalCamera instead as both are identical.
  93183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93184. * @param name Define the name of the camera in the scene
  93185. * @param position Define the start position of the camera in the scene
  93186. * @param scene Define the scene the camera belongs to
  93187. */
  93188. constructor(name: string, position: Vector3, scene: Scene);
  93189. /**
  93190. * Gets the current object class name.
  93191. * @return the class name
  93192. */
  93193. getClassName(): string;
  93194. }
  93195. }
  93196. declare module BABYLON {
  93197. /** @hidden */
  93198. export var passPixelShader: {
  93199. name: string;
  93200. shader: string;
  93201. };
  93202. }
  93203. declare module BABYLON {
  93204. /** @hidden */
  93205. export var passCubePixelShader: {
  93206. name: string;
  93207. shader: string;
  93208. };
  93209. }
  93210. declare module BABYLON {
  93211. /**
  93212. * PassPostProcess which produces an output the same as it's input
  93213. */
  93214. export class PassPostProcess extends PostProcess {
  93215. /**
  93216. * Creates the PassPostProcess
  93217. * @param name The name of the effect.
  93218. * @param options The required width/height ratio to downsize to before computing the render pass.
  93219. * @param camera The camera to apply the render pass to.
  93220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93221. * @param engine The engine which the post process will be applied. (default: current engine)
  93222. * @param reusable If the post process can be reused on the same frame. (default: false)
  93223. * @param textureType The type of texture to be used when performing the post processing.
  93224. * @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)
  93225. */
  93226. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93227. }
  93228. /**
  93229. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93230. */
  93231. export class PassCubePostProcess extends PostProcess {
  93232. private _face;
  93233. /**
  93234. * Gets or sets the cube face to display.
  93235. * * 0 is +X
  93236. * * 1 is -X
  93237. * * 2 is +Y
  93238. * * 3 is -Y
  93239. * * 4 is +Z
  93240. * * 5 is -Z
  93241. */
  93242. face: number;
  93243. /**
  93244. * Creates the PassCubePostProcess
  93245. * @param name The name of the effect.
  93246. * @param options The required width/height ratio to downsize to before computing the render pass.
  93247. * @param camera The camera to apply the render pass to.
  93248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93249. * @param engine The engine which the post process will be applied. (default: current engine)
  93250. * @param reusable If the post process can be reused on the same frame. (default: false)
  93251. * @param textureType The type of texture to be used when performing the post processing.
  93252. * @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)
  93253. */
  93254. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93255. }
  93256. }
  93257. declare module BABYLON {
  93258. /** @hidden */
  93259. export var anaglyphPixelShader: {
  93260. name: string;
  93261. shader: string;
  93262. };
  93263. }
  93264. declare module BABYLON {
  93265. /**
  93266. * Postprocess used to generate anaglyphic rendering
  93267. */
  93268. export class AnaglyphPostProcess extends PostProcess {
  93269. private _passedProcess;
  93270. /**
  93271. * Creates a new AnaglyphPostProcess
  93272. * @param name defines postprocess name
  93273. * @param options defines creation options or target ratio scale
  93274. * @param rigCameras defines cameras using this postprocess
  93275. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  93276. * @param engine defines hosting engine
  93277. * @param reusable defines if the postprocess will be reused multiple times per frame
  93278. */
  93279. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  93280. }
  93281. }
  93282. declare module BABYLON {
  93283. /**
  93284. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  93285. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93286. */
  93287. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  93288. /**
  93289. * Creates a new AnaglyphArcRotateCamera
  93290. * @param name defines camera name
  93291. * @param alpha defines alpha angle (in radians)
  93292. * @param beta defines beta angle (in radians)
  93293. * @param radius defines radius
  93294. * @param target defines camera target
  93295. * @param interaxialDistance defines distance between each color axis
  93296. * @param scene defines the hosting scene
  93297. */
  93298. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  93299. /**
  93300. * Gets camera class name
  93301. * @returns AnaglyphArcRotateCamera
  93302. */
  93303. getClassName(): string;
  93304. }
  93305. }
  93306. declare module BABYLON {
  93307. /**
  93308. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  93309. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93310. */
  93311. export class AnaglyphFreeCamera extends FreeCamera {
  93312. /**
  93313. * Creates a new AnaglyphFreeCamera
  93314. * @param name defines camera name
  93315. * @param position defines initial position
  93316. * @param interaxialDistance defines distance between each color axis
  93317. * @param scene defines the hosting scene
  93318. */
  93319. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93320. /**
  93321. * Gets camera class name
  93322. * @returns AnaglyphFreeCamera
  93323. */
  93324. getClassName(): string;
  93325. }
  93326. }
  93327. declare module BABYLON {
  93328. /**
  93329. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  93330. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93331. */
  93332. export class AnaglyphGamepadCamera extends GamepadCamera {
  93333. /**
  93334. * Creates a new AnaglyphGamepadCamera
  93335. * @param name defines camera name
  93336. * @param position defines initial position
  93337. * @param interaxialDistance defines distance between each color axis
  93338. * @param scene defines the hosting scene
  93339. */
  93340. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93341. /**
  93342. * Gets camera class name
  93343. * @returns AnaglyphGamepadCamera
  93344. */
  93345. getClassName(): string;
  93346. }
  93347. }
  93348. declare module BABYLON {
  93349. /**
  93350. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  93351. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93352. */
  93353. export class AnaglyphUniversalCamera extends UniversalCamera {
  93354. /**
  93355. * Creates a new AnaglyphUniversalCamera
  93356. * @param name defines camera name
  93357. * @param position defines initial position
  93358. * @param interaxialDistance defines distance between each color axis
  93359. * @param scene defines the hosting scene
  93360. */
  93361. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93362. /**
  93363. * Gets camera class name
  93364. * @returns AnaglyphUniversalCamera
  93365. */
  93366. getClassName(): string;
  93367. }
  93368. }
  93369. declare module BABYLON {
  93370. /** @hidden */
  93371. export var stereoscopicInterlacePixelShader: {
  93372. name: string;
  93373. shader: string;
  93374. };
  93375. }
  93376. declare module BABYLON {
  93377. /**
  93378. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  93379. */
  93380. export class StereoscopicInterlacePostProcess extends PostProcess {
  93381. private _stepSize;
  93382. private _passedProcess;
  93383. /**
  93384. * Initializes a StereoscopicInterlacePostProcess
  93385. * @param name The name of the effect.
  93386. * @param rigCameras The rig cameras to be appled to the post process
  93387. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  93388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93389. * @param engine The engine which the post process will be applied. (default: current engine)
  93390. * @param reusable If the post process can be reused on the same frame. (default: false)
  93391. */
  93392. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  93393. }
  93394. }
  93395. declare module BABYLON {
  93396. /**
  93397. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  93398. * @see http://doc.babylonjs.com/features/cameras
  93399. */
  93400. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  93401. /**
  93402. * Creates a new StereoscopicArcRotateCamera
  93403. * @param name defines camera name
  93404. * @param alpha defines alpha angle (in radians)
  93405. * @param beta defines beta angle (in radians)
  93406. * @param radius defines radius
  93407. * @param target defines camera target
  93408. * @param interaxialDistance defines distance between each color axis
  93409. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93410. * @param scene defines the hosting scene
  93411. */
  93412. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93413. /**
  93414. * Gets camera class name
  93415. * @returns StereoscopicArcRotateCamera
  93416. */
  93417. getClassName(): string;
  93418. }
  93419. }
  93420. declare module BABYLON {
  93421. /**
  93422. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  93423. * @see http://doc.babylonjs.com/features/cameras
  93424. */
  93425. export class StereoscopicFreeCamera extends FreeCamera {
  93426. /**
  93427. * Creates a new StereoscopicFreeCamera
  93428. * @param name defines camera name
  93429. * @param position defines initial position
  93430. * @param interaxialDistance defines distance between each color axis
  93431. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93432. * @param scene defines the hosting scene
  93433. */
  93434. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93435. /**
  93436. * Gets camera class name
  93437. * @returns StereoscopicFreeCamera
  93438. */
  93439. getClassName(): string;
  93440. }
  93441. }
  93442. declare module BABYLON {
  93443. /**
  93444. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  93445. * @see http://doc.babylonjs.com/features/cameras
  93446. */
  93447. export class StereoscopicGamepadCamera extends GamepadCamera {
  93448. /**
  93449. * Creates a new StereoscopicGamepadCamera
  93450. * @param name defines camera name
  93451. * @param position defines initial position
  93452. * @param interaxialDistance defines distance between each color axis
  93453. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93454. * @param scene defines the hosting scene
  93455. */
  93456. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93457. /**
  93458. * Gets camera class name
  93459. * @returns StereoscopicGamepadCamera
  93460. */
  93461. getClassName(): string;
  93462. }
  93463. }
  93464. declare module BABYLON {
  93465. /**
  93466. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  93467. * @see http://doc.babylonjs.com/features/cameras
  93468. */
  93469. export class StereoscopicUniversalCamera extends UniversalCamera {
  93470. /**
  93471. * Creates a new StereoscopicUniversalCamera
  93472. * @param name defines camera name
  93473. * @param position defines initial position
  93474. * @param interaxialDistance defines distance between each color axis
  93475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93476. * @param scene defines the hosting scene
  93477. */
  93478. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93479. /**
  93480. * Gets camera class name
  93481. * @returns StereoscopicUniversalCamera
  93482. */
  93483. getClassName(): string;
  93484. }
  93485. }
  93486. declare module BABYLON {
  93487. /**
  93488. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93489. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93490. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93491. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93492. */
  93493. export class VirtualJoysticksCamera extends FreeCamera {
  93494. /**
  93495. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93496. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93497. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93498. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93499. * @param name Define the name of the camera in the scene
  93500. * @param position Define the start position of the camera in the scene
  93501. * @param scene Define the scene the camera belongs to
  93502. */
  93503. constructor(name: string, position: Vector3, scene: Scene);
  93504. /**
  93505. * Gets the current object class name.
  93506. * @return the class name
  93507. */
  93508. getClassName(): string;
  93509. }
  93510. }
  93511. declare module BABYLON {
  93512. /**
  93513. * This represents all the required metrics to create a VR camera.
  93514. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93515. */
  93516. export class VRCameraMetrics {
  93517. /**
  93518. * Define the horizontal resolution off the screen.
  93519. */
  93520. hResolution: number;
  93521. /**
  93522. * Define the vertical resolution off the screen.
  93523. */
  93524. vResolution: number;
  93525. /**
  93526. * Define the horizontal screen size.
  93527. */
  93528. hScreenSize: number;
  93529. /**
  93530. * Define the vertical screen size.
  93531. */
  93532. vScreenSize: number;
  93533. /**
  93534. * Define the vertical screen center position.
  93535. */
  93536. vScreenCenter: number;
  93537. /**
  93538. * Define the distance of the eyes to the screen.
  93539. */
  93540. eyeToScreenDistance: number;
  93541. /**
  93542. * Define the distance between both lenses
  93543. */
  93544. lensSeparationDistance: number;
  93545. /**
  93546. * Define the distance between both viewer's eyes.
  93547. */
  93548. interpupillaryDistance: number;
  93549. /**
  93550. * Define the distortion factor of the VR postprocess.
  93551. * Please, touch with care.
  93552. */
  93553. distortionK: number[];
  93554. /**
  93555. * Define the chromatic aberration correction factors for the VR post process.
  93556. */
  93557. chromaAbCorrection: number[];
  93558. /**
  93559. * Define the scale factor of the post process.
  93560. * The smaller the better but the slower.
  93561. */
  93562. postProcessScaleFactor: number;
  93563. /**
  93564. * Define an offset for the lens center.
  93565. */
  93566. lensCenterOffset: number;
  93567. /**
  93568. * Define if the current vr camera should compensate the distortion of the lense or not.
  93569. */
  93570. compensateDistortion: boolean;
  93571. /**
  93572. * Gets the rendering aspect ratio based on the provided resolutions.
  93573. */
  93574. readonly aspectRatio: number;
  93575. /**
  93576. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93577. */
  93578. readonly aspectRatioFov: number;
  93579. /**
  93580. * @hidden
  93581. */
  93582. readonly leftHMatrix: Matrix;
  93583. /**
  93584. * @hidden
  93585. */
  93586. readonly rightHMatrix: Matrix;
  93587. /**
  93588. * @hidden
  93589. */
  93590. readonly leftPreViewMatrix: Matrix;
  93591. /**
  93592. * @hidden
  93593. */
  93594. readonly rightPreViewMatrix: Matrix;
  93595. /**
  93596. * Get the default VRMetrics based on the most generic setup.
  93597. * @returns the default vr metrics
  93598. */
  93599. static GetDefault(): VRCameraMetrics;
  93600. }
  93601. }
  93602. declare module BABYLON {
  93603. /** @hidden */
  93604. export var vrDistortionCorrectionPixelShader: {
  93605. name: string;
  93606. shader: string;
  93607. };
  93608. }
  93609. declare module BABYLON {
  93610. /**
  93611. * VRDistortionCorrectionPostProcess used for mobile VR
  93612. */
  93613. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93614. private _isRightEye;
  93615. private _distortionFactors;
  93616. private _postProcessScaleFactor;
  93617. private _lensCenterOffset;
  93618. private _scaleIn;
  93619. private _scaleFactor;
  93620. private _lensCenter;
  93621. /**
  93622. * Initializes the VRDistortionCorrectionPostProcess
  93623. * @param name The name of the effect.
  93624. * @param camera The camera to apply the render pass to.
  93625. * @param isRightEye If this is for the right eye distortion
  93626. * @param vrMetrics All the required metrics for the VR camera
  93627. */
  93628. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93629. }
  93630. }
  93631. declare module BABYLON {
  93632. /**
  93633. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93634. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93635. */
  93636. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93637. /**
  93638. * Creates a new VRDeviceOrientationArcRotateCamera
  93639. * @param name defines camera name
  93640. * @param alpha defines the camera rotation along the logitudinal axis
  93641. * @param beta defines the camera rotation along the latitudinal axis
  93642. * @param radius defines the camera distance from its target
  93643. * @param target defines the camera target
  93644. * @param scene defines the scene the camera belongs to
  93645. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93646. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93647. */
  93648. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93649. /**
  93650. * Gets camera class name
  93651. * @returns VRDeviceOrientationArcRotateCamera
  93652. */
  93653. getClassName(): string;
  93654. }
  93655. }
  93656. declare module BABYLON {
  93657. /**
  93658. * Camera used to simulate VR rendering (based on FreeCamera)
  93659. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93660. */
  93661. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93662. /**
  93663. * Creates a new VRDeviceOrientationFreeCamera
  93664. * @param name defines camera name
  93665. * @param position defines the start position of the camera
  93666. * @param scene defines the scene the camera belongs to
  93667. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93668. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93669. */
  93670. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93671. /**
  93672. * Gets camera class name
  93673. * @returns VRDeviceOrientationFreeCamera
  93674. */
  93675. getClassName(): string;
  93676. }
  93677. }
  93678. declare module BABYLON {
  93679. /**
  93680. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93681. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93682. */
  93683. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93684. /**
  93685. * Creates a new VRDeviceOrientationGamepadCamera
  93686. * @param name defines camera name
  93687. * @param position defines the start position of the camera
  93688. * @param scene defines the scene the camera belongs to
  93689. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93690. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93691. */
  93692. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93693. /**
  93694. * Gets camera class name
  93695. * @returns VRDeviceOrientationGamepadCamera
  93696. */
  93697. getClassName(): string;
  93698. }
  93699. }
  93700. declare module BABYLON {
  93701. /**
  93702. * Defines supported buttons for XBox360 compatible gamepads
  93703. */
  93704. export enum Xbox360Button {
  93705. /** A */
  93706. A = 0,
  93707. /** B */
  93708. B = 1,
  93709. /** X */
  93710. X = 2,
  93711. /** Y */
  93712. Y = 3,
  93713. /** Start */
  93714. Start = 4,
  93715. /** Back */
  93716. Back = 5,
  93717. /** Left button */
  93718. LB = 6,
  93719. /** Right button */
  93720. RB = 7,
  93721. /** Left stick */
  93722. LeftStick = 8,
  93723. /** Right stick */
  93724. RightStick = 9
  93725. }
  93726. /** Defines values for XBox360 DPad */
  93727. export enum Xbox360Dpad {
  93728. /** Up */
  93729. Up = 0,
  93730. /** Down */
  93731. Down = 1,
  93732. /** Left */
  93733. Left = 2,
  93734. /** Right */
  93735. Right = 3
  93736. }
  93737. /**
  93738. * Defines a XBox360 gamepad
  93739. */
  93740. export class Xbox360Pad extends Gamepad {
  93741. private _leftTrigger;
  93742. private _rightTrigger;
  93743. private _onlefttriggerchanged;
  93744. private _onrighttriggerchanged;
  93745. private _onbuttondown;
  93746. private _onbuttonup;
  93747. private _ondpaddown;
  93748. private _ondpadup;
  93749. /** Observable raised when a button is pressed */
  93750. onButtonDownObservable: Observable<Xbox360Button>;
  93751. /** Observable raised when a button is released */
  93752. onButtonUpObservable: Observable<Xbox360Button>;
  93753. /** Observable raised when a pad is pressed */
  93754. onPadDownObservable: Observable<Xbox360Dpad>;
  93755. /** Observable raised when a pad is released */
  93756. onPadUpObservable: Observable<Xbox360Dpad>;
  93757. private _buttonA;
  93758. private _buttonB;
  93759. private _buttonX;
  93760. private _buttonY;
  93761. private _buttonBack;
  93762. private _buttonStart;
  93763. private _buttonLB;
  93764. private _buttonRB;
  93765. private _buttonLeftStick;
  93766. private _buttonRightStick;
  93767. private _dPadUp;
  93768. private _dPadDown;
  93769. private _dPadLeft;
  93770. private _dPadRight;
  93771. private _isXboxOnePad;
  93772. /**
  93773. * Creates a new XBox360 gamepad object
  93774. * @param id defines the id of this gamepad
  93775. * @param index defines its index
  93776. * @param gamepad defines the internal HTML gamepad object
  93777. * @param xboxOne defines if it is a XBox One gamepad
  93778. */
  93779. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93780. /**
  93781. * Defines the callback to call when left trigger is pressed
  93782. * @param callback defines the callback to use
  93783. */
  93784. onlefttriggerchanged(callback: (value: number) => void): void;
  93785. /**
  93786. * Defines the callback to call when right trigger is pressed
  93787. * @param callback defines the callback to use
  93788. */
  93789. onrighttriggerchanged(callback: (value: number) => void): void;
  93790. /**
  93791. * Gets the left trigger value
  93792. */
  93793. /**
  93794. * Sets the left trigger value
  93795. */
  93796. leftTrigger: number;
  93797. /**
  93798. * Gets the right trigger value
  93799. */
  93800. /**
  93801. * Sets the right trigger value
  93802. */
  93803. rightTrigger: number;
  93804. /**
  93805. * Defines the callback to call when a button is pressed
  93806. * @param callback defines the callback to use
  93807. */
  93808. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93809. /**
  93810. * Defines the callback to call when a button is released
  93811. * @param callback defines the callback to use
  93812. */
  93813. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93814. /**
  93815. * Defines the callback to call when a pad is pressed
  93816. * @param callback defines the callback to use
  93817. */
  93818. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93819. /**
  93820. * Defines the callback to call when a pad is released
  93821. * @param callback defines the callback to use
  93822. */
  93823. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93824. private _setButtonValue;
  93825. private _setDPadValue;
  93826. /**
  93827. * Gets the value of the `A` button
  93828. */
  93829. /**
  93830. * Sets the value of the `A` button
  93831. */
  93832. buttonA: number;
  93833. /**
  93834. * Gets the value of the `B` button
  93835. */
  93836. /**
  93837. * Sets the value of the `B` button
  93838. */
  93839. buttonB: number;
  93840. /**
  93841. * Gets the value of the `X` button
  93842. */
  93843. /**
  93844. * Sets the value of the `X` button
  93845. */
  93846. buttonX: number;
  93847. /**
  93848. * Gets the value of the `Y` button
  93849. */
  93850. /**
  93851. * Sets the value of the `Y` button
  93852. */
  93853. buttonY: number;
  93854. /**
  93855. * Gets the value of the `Start` button
  93856. */
  93857. /**
  93858. * Sets the value of the `Start` button
  93859. */
  93860. buttonStart: number;
  93861. /**
  93862. * Gets the value of the `Back` button
  93863. */
  93864. /**
  93865. * Sets the value of the `Back` button
  93866. */
  93867. buttonBack: number;
  93868. /**
  93869. * Gets the value of the `Left` button
  93870. */
  93871. /**
  93872. * Sets the value of the `Left` button
  93873. */
  93874. buttonLB: number;
  93875. /**
  93876. * Gets the value of the `Right` button
  93877. */
  93878. /**
  93879. * Sets the value of the `Right` button
  93880. */
  93881. buttonRB: number;
  93882. /**
  93883. * Gets the value of the Left joystick
  93884. */
  93885. /**
  93886. * Sets the value of the Left joystick
  93887. */
  93888. buttonLeftStick: number;
  93889. /**
  93890. * Gets the value of the Right joystick
  93891. */
  93892. /**
  93893. * Sets the value of the Right joystick
  93894. */
  93895. buttonRightStick: number;
  93896. /**
  93897. * Gets the value of D-pad up
  93898. */
  93899. /**
  93900. * Sets the value of D-pad up
  93901. */
  93902. dPadUp: number;
  93903. /**
  93904. * Gets the value of D-pad down
  93905. */
  93906. /**
  93907. * Sets the value of D-pad down
  93908. */
  93909. dPadDown: number;
  93910. /**
  93911. * Gets the value of D-pad left
  93912. */
  93913. /**
  93914. * Sets the value of D-pad left
  93915. */
  93916. dPadLeft: number;
  93917. /**
  93918. * Gets the value of D-pad right
  93919. */
  93920. /**
  93921. * Sets the value of D-pad right
  93922. */
  93923. dPadRight: number;
  93924. /**
  93925. * Force the gamepad to synchronize with device values
  93926. */
  93927. update(): void;
  93928. /**
  93929. * Disposes the gamepad
  93930. */
  93931. dispose(): void;
  93932. }
  93933. }
  93934. declare module BABYLON {
  93935. /**
  93936. * Base class of materials working in push mode in babylon JS
  93937. * @hidden
  93938. */
  93939. export class PushMaterial extends Material {
  93940. protected _activeEffect: Effect;
  93941. protected _normalMatrix: Matrix;
  93942. /**
  93943. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93944. * This means that the material can keep using a previous shader while a new one is being compiled.
  93945. * This is mostly used when shader parallel compilation is supported (true by default)
  93946. */
  93947. allowShaderHotSwapping: boolean;
  93948. constructor(name: string, scene: Scene);
  93949. getEffect(): Effect;
  93950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93951. /**
  93952. * Binds the given world matrix to the active effect
  93953. *
  93954. * @param world the matrix to bind
  93955. */
  93956. bindOnlyWorldMatrix(world: Matrix): void;
  93957. /**
  93958. * Binds the given normal matrix to the active effect
  93959. *
  93960. * @param normalMatrix the matrix to bind
  93961. */
  93962. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93963. bind(world: Matrix, mesh?: Mesh): void;
  93964. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93965. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93966. }
  93967. }
  93968. declare module BABYLON {
  93969. /**
  93970. * This groups all the flags used to control the materials channel.
  93971. */
  93972. export class MaterialFlags {
  93973. private static _DiffuseTextureEnabled;
  93974. /**
  93975. * Are diffuse textures enabled in the application.
  93976. */
  93977. static DiffuseTextureEnabled: boolean;
  93978. private static _AmbientTextureEnabled;
  93979. /**
  93980. * Are ambient textures enabled in the application.
  93981. */
  93982. static AmbientTextureEnabled: boolean;
  93983. private static _OpacityTextureEnabled;
  93984. /**
  93985. * Are opacity textures enabled in the application.
  93986. */
  93987. static OpacityTextureEnabled: boolean;
  93988. private static _ReflectionTextureEnabled;
  93989. /**
  93990. * Are reflection textures enabled in the application.
  93991. */
  93992. static ReflectionTextureEnabled: boolean;
  93993. private static _EmissiveTextureEnabled;
  93994. /**
  93995. * Are emissive textures enabled in the application.
  93996. */
  93997. static EmissiveTextureEnabled: boolean;
  93998. private static _SpecularTextureEnabled;
  93999. /**
  94000. * Are specular textures enabled in the application.
  94001. */
  94002. static SpecularTextureEnabled: boolean;
  94003. private static _BumpTextureEnabled;
  94004. /**
  94005. * Are bump textures enabled in the application.
  94006. */
  94007. static BumpTextureEnabled: boolean;
  94008. private static _LightmapTextureEnabled;
  94009. /**
  94010. * Are lightmap textures enabled in the application.
  94011. */
  94012. static LightmapTextureEnabled: boolean;
  94013. private static _RefractionTextureEnabled;
  94014. /**
  94015. * Are refraction textures enabled in the application.
  94016. */
  94017. static RefractionTextureEnabled: boolean;
  94018. private static _ColorGradingTextureEnabled;
  94019. /**
  94020. * Are color grading textures enabled in the application.
  94021. */
  94022. static ColorGradingTextureEnabled: boolean;
  94023. private static _FresnelEnabled;
  94024. /**
  94025. * Are fresnels enabled in the application.
  94026. */
  94027. static FresnelEnabled: boolean;
  94028. private static _ClearCoatTextureEnabled;
  94029. /**
  94030. * Are clear coat textures enabled in the application.
  94031. */
  94032. static ClearCoatTextureEnabled: boolean;
  94033. private static _ClearCoatBumpTextureEnabled;
  94034. /**
  94035. * Are clear coat bump textures enabled in the application.
  94036. */
  94037. static ClearCoatBumpTextureEnabled: boolean;
  94038. private static _ClearCoatTintTextureEnabled;
  94039. /**
  94040. * Are clear coat tint textures enabled in the application.
  94041. */
  94042. static ClearCoatTintTextureEnabled: boolean;
  94043. }
  94044. }
  94045. declare module BABYLON {
  94046. /** @hidden */
  94047. export var defaultFragmentDeclaration: {
  94048. name: string;
  94049. shader: string;
  94050. };
  94051. }
  94052. declare module BABYLON {
  94053. /** @hidden */
  94054. export var defaultUboDeclaration: {
  94055. name: string;
  94056. shader: string;
  94057. };
  94058. }
  94059. declare module BABYLON {
  94060. /** @hidden */
  94061. export var lightFragmentDeclaration: {
  94062. name: string;
  94063. shader: string;
  94064. };
  94065. }
  94066. declare module BABYLON {
  94067. /** @hidden */
  94068. export var lightUboDeclaration: {
  94069. name: string;
  94070. shader: string;
  94071. };
  94072. }
  94073. declare module BABYLON {
  94074. /** @hidden */
  94075. export var lightsFragmentFunctions: {
  94076. name: string;
  94077. shader: string;
  94078. };
  94079. }
  94080. declare module BABYLON {
  94081. /** @hidden */
  94082. export var shadowsFragmentFunctions: {
  94083. name: string;
  94084. shader: string;
  94085. };
  94086. }
  94087. declare module BABYLON {
  94088. /** @hidden */
  94089. export var fresnelFunction: {
  94090. name: string;
  94091. shader: string;
  94092. };
  94093. }
  94094. declare module BABYLON {
  94095. /** @hidden */
  94096. export var reflectionFunction: {
  94097. name: string;
  94098. shader: string;
  94099. };
  94100. }
  94101. declare module BABYLON {
  94102. /** @hidden */
  94103. export var bumpFragmentFunctions: {
  94104. name: string;
  94105. shader: string;
  94106. };
  94107. }
  94108. declare module BABYLON {
  94109. /** @hidden */
  94110. export var logDepthDeclaration: {
  94111. name: string;
  94112. shader: string;
  94113. };
  94114. }
  94115. declare module BABYLON {
  94116. /** @hidden */
  94117. export var bumpFragment: {
  94118. name: string;
  94119. shader: string;
  94120. };
  94121. }
  94122. declare module BABYLON {
  94123. /** @hidden */
  94124. export var depthPrePass: {
  94125. name: string;
  94126. shader: string;
  94127. };
  94128. }
  94129. declare module BABYLON {
  94130. /** @hidden */
  94131. export var lightFragment: {
  94132. name: string;
  94133. shader: string;
  94134. };
  94135. }
  94136. declare module BABYLON {
  94137. /** @hidden */
  94138. export var logDepthFragment: {
  94139. name: string;
  94140. shader: string;
  94141. };
  94142. }
  94143. declare module BABYLON {
  94144. /** @hidden */
  94145. export var defaultPixelShader: {
  94146. name: string;
  94147. shader: string;
  94148. };
  94149. }
  94150. declare module BABYLON {
  94151. /** @hidden */
  94152. export var defaultVertexDeclaration: {
  94153. name: string;
  94154. shader: string;
  94155. };
  94156. }
  94157. declare module BABYLON {
  94158. /** @hidden */
  94159. export var bumpVertexDeclaration: {
  94160. name: string;
  94161. shader: string;
  94162. };
  94163. }
  94164. declare module BABYLON {
  94165. /** @hidden */
  94166. export var bumpVertex: {
  94167. name: string;
  94168. shader: string;
  94169. };
  94170. }
  94171. declare module BABYLON {
  94172. /** @hidden */
  94173. export var fogVertex: {
  94174. name: string;
  94175. shader: string;
  94176. };
  94177. }
  94178. declare module BABYLON {
  94179. /** @hidden */
  94180. export var shadowsVertex: {
  94181. name: string;
  94182. shader: string;
  94183. };
  94184. }
  94185. declare module BABYLON {
  94186. /** @hidden */
  94187. export var pointCloudVertex: {
  94188. name: string;
  94189. shader: string;
  94190. };
  94191. }
  94192. declare module BABYLON {
  94193. /** @hidden */
  94194. export var logDepthVertex: {
  94195. name: string;
  94196. shader: string;
  94197. };
  94198. }
  94199. declare module BABYLON {
  94200. /** @hidden */
  94201. export var defaultVertexShader: {
  94202. name: string;
  94203. shader: string;
  94204. };
  94205. }
  94206. declare module BABYLON {
  94207. /** @hidden */
  94208. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94209. MAINUV1: boolean;
  94210. MAINUV2: boolean;
  94211. DIFFUSE: boolean;
  94212. DIFFUSEDIRECTUV: number;
  94213. AMBIENT: boolean;
  94214. AMBIENTDIRECTUV: number;
  94215. OPACITY: boolean;
  94216. OPACITYDIRECTUV: number;
  94217. OPACITYRGB: boolean;
  94218. REFLECTION: boolean;
  94219. EMISSIVE: boolean;
  94220. EMISSIVEDIRECTUV: number;
  94221. SPECULAR: boolean;
  94222. SPECULARDIRECTUV: number;
  94223. BUMP: boolean;
  94224. BUMPDIRECTUV: number;
  94225. PARALLAX: boolean;
  94226. PARALLAXOCCLUSION: boolean;
  94227. SPECULAROVERALPHA: boolean;
  94228. CLIPPLANE: boolean;
  94229. CLIPPLANE2: boolean;
  94230. CLIPPLANE3: boolean;
  94231. CLIPPLANE4: boolean;
  94232. ALPHATEST: boolean;
  94233. DEPTHPREPASS: boolean;
  94234. ALPHAFROMDIFFUSE: boolean;
  94235. POINTSIZE: boolean;
  94236. FOG: boolean;
  94237. SPECULARTERM: boolean;
  94238. DIFFUSEFRESNEL: boolean;
  94239. OPACITYFRESNEL: boolean;
  94240. REFLECTIONFRESNEL: boolean;
  94241. REFRACTIONFRESNEL: boolean;
  94242. EMISSIVEFRESNEL: boolean;
  94243. FRESNEL: boolean;
  94244. NORMAL: boolean;
  94245. UV1: boolean;
  94246. UV2: boolean;
  94247. VERTEXCOLOR: boolean;
  94248. VERTEXALPHA: boolean;
  94249. NUM_BONE_INFLUENCERS: number;
  94250. BonesPerMesh: number;
  94251. BONETEXTURE: boolean;
  94252. INSTANCES: boolean;
  94253. GLOSSINESS: boolean;
  94254. ROUGHNESS: boolean;
  94255. EMISSIVEASILLUMINATION: boolean;
  94256. LINKEMISSIVEWITHDIFFUSE: boolean;
  94257. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94258. LIGHTMAP: boolean;
  94259. LIGHTMAPDIRECTUV: number;
  94260. OBJECTSPACE_NORMALMAP: boolean;
  94261. USELIGHTMAPASSHADOWMAP: boolean;
  94262. REFLECTIONMAP_3D: boolean;
  94263. REFLECTIONMAP_SPHERICAL: boolean;
  94264. REFLECTIONMAP_PLANAR: boolean;
  94265. REFLECTIONMAP_CUBIC: boolean;
  94266. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94267. REFLECTIONMAP_PROJECTION: boolean;
  94268. REFLECTIONMAP_SKYBOX: boolean;
  94269. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94270. REFLECTIONMAP_EXPLICIT: boolean;
  94271. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94272. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94273. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94274. INVERTCUBICMAP: boolean;
  94275. LOGARITHMICDEPTH: boolean;
  94276. REFRACTION: boolean;
  94277. REFRACTIONMAP_3D: boolean;
  94278. REFLECTIONOVERALPHA: boolean;
  94279. TWOSIDEDLIGHTING: boolean;
  94280. SHADOWFLOAT: boolean;
  94281. MORPHTARGETS: boolean;
  94282. MORPHTARGETS_NORMAL: boolean;
  94283. MORPHTARGETS_TANGENT: boolean;
  94284. NUM_MORPH_INFLUENCERS: number;
  94285. NONUNIFORMSCALING: boolean;
  94286. PREMULTIPLYALPHA: boolean;
  94287. IMAGEPROCESSING: boolean;
  94288. VIGNETTE: boolean;
  94289. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94290. VIGNETTEBLENDMODEOPAQUE: boolean;
  94291. TONEMAPPING: boolean;
  94292. TONEMAPPING_ACES: boolean;
  94293. CONTRAST: boolean;
  94294. COLORCURVES: boolean;
  94295. COLORGRADING: boolean;
  94296. COLORGRADING3D: boolean;
  94297. SAMPLER3DGREENDEPTH: boolean;
  94298. SAMPLER3DBGRMAP: boolean;
  94299. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94300. /**
  94301. * If the reflection texture on this material is in linear color space
  94302. * @hidden
  94303. */
  94304. IS_REFLECTION_LINEAR: boolean;
  94305. /**
  94306. * If the refraction texture on this material is in linear color space
  94307. * @hidden
  94308. */
  94309. IS_REFRACTION_LINEAR: boolean;
  94310. EXPOSURE: boolean;
  94311. constructor();
  94312. setReflectionMode(modeToEnable: string): void;
  94313. }
  94314. /**
  94315. * This is the default material used in Babylon. It is the best trade off between quality
  94316. * and performances.
  94317. * @see http://doc.babylonjs.com/babylon101/materials
  94318. */
  94319. export class StandardMaterial extends PushMaterial {
  94320. private _diffuseTexture;
  94321. /**
  94322. * The basic texture of the material as viewed under a light.
  94323. */
  94324. diffuseTexture: Nullable<BaseTexture>;
  94325. private _ambientTexture;
  94326. /**
  94327. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94328. */
  94329. ambientTexture: Nullable<BaseTexture>;
  94330. private _opacityTexture;
  94331. /**
  94332. * Define the transparency of the material from a texture.
  94333. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94334. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94335. */
  94336. opacityTexture: Nullable<BaseTexture>;
  94337. private _reflectionTexture;
  94338. /**
  94339. * Define the texture used to display the reflection.
  94340. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94341. */
  94342. reflectionTexture: Nullable<BaseTexture>;
  94343. private _emissiveTexture;
  94344. /**
  94345. * Define texture of the material as if self lit.
  94346. * This will be mixed in the final result even in the absence of light.
  94347. */
  94348. emissiveTexture: Nullable<BaseTexture>;
  94349. private _specularTexture;
  94350. /**
  94351. * Define how the color and intensity of the highlight given by the light in the material.
  94352. */
  94353. specularTexture: Nullable<BaseTexture>;
  94354. private _bumpTexture;
  94355. /**
  94356. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94357. * 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.
  94358. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94359. */
  94360. bumpTexture: Nullable<BaseTexture>;
  94361. private _lightmapTexture;
  94362. /**
  94363. * Complex lighting can be computationally expensive to compute at runtime.
  94364. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94365. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94366. */
  94367. lightmapTexture: Nullable<BaseTexture>;
  94368. private _refractionTexture;
  94369. /**
  94370. * Define the texture used to display the refraction.
  94371. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94372. */
  94373. refractionTexture: Nullable<BaseTexture>;
  94374. /**
  94375. * The color of the material lit by the environmental background lighting.
  94376. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94377. */
  94378. ambientColor: Color3;
  94379. /**
  94380. * The basic color of the material as viewed under a light.
  94381. */
  94382. diffuseColor: Color3;
  94383. /**
  94384. * Define how the color and intensity of the highlight given by the light in the material.
  94385. */
  94386. specularColor: Color3;
  94387. /**
  94388. * Define the color of the material as if self lit.
  94389. * This will be mixed in the final result even in the absence of light.
  94390. */
  94391. emissiveColor: Color3;
  94392. /**
  94393. * Defines how sharp are the highlights in the material.
  94394. * The bigger the value the sharper giving a more glossy feeling to the result.
  94395. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94396. */
  94397. specularPower: number;
  94398. private _useAlphaFromDiffuseTexture;
  94399. /**
  94400. * Does the transparency come from the diffuse texture alpha channel.
  94401. */
  94402. useAlphaFromDiffuseTexture: boolean;
  94403. private _useEmissiveAsIllumination;
  94404. /**
  94405. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94406. */
  94407. useEmissiveAsIllumination: boolean;
  94408. private _linkEmissiveWithDiffuse;
  94409. /**
  94410. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94411. * the emissive level when the final color is close to one.
  94412. */
  94413. linkEmissiveWithDiffuse: boolean;
  94414. private _useSpecularOverAlpha;
  94415. /**
  94416. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94417. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94418. */
  94419. useSpecularOverAlpha: boolean;
  94420. private _useReflectionOverAlpha;
  94421. /**
  94422. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94423. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94424. */
  94425. useReflectionOverAlpha: boolean;
  94426. private _disableLighting;
  94427. /**
  94428. * Does lights from the scene impacts this material.
  94429. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94430. */
  94431. disableLighting: boolean;
  94432. private _useObjectSpaceNormalMap;
  94433. /**
  94434. * Allows using an object space normal map (instead of tangent space).
  94435. */
  94436. useObjectSpaceNormalMap: boolean;
  94437. private _useParallax;
  94438. /**
  94439. * Is parallax enabled or not.
  94440. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94441. */
  94442. useParallax: boolean;
  94443. private _useParallaxOcclusion;
  94444. /**
  94445. * Is parallax occlusion enabled or not.
  94446. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  94447. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94448. */
  94449. useParallaxOcclusion: boolean;
  94450. /**
  94451. * 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.
  94452. */
  94453. parallaxScaleBias: number;
  94454. private _roughness;
  94455. /**
  94456. * Helps to define how blurry the reflections should appears in the material.
  94457. */
  94458. roughness: number;
  94459. /**
  94460. * In case of refraction, define the value of the indice of refraction.
  94461. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94462. */
  94463. indexOfRefraction: number;
  94464. /**
  94465. * Invert the refraction texture alongside the y axis.
  94466. * It can be useful with procedural textures or probe for instance.
  94467. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94468. */
  94469. invertRefractionY: boolean;
  94470. /**
  94471. * Defines the alpha limits in alpha test mode.
  94472. */
  94473. alphaCutOff: number;
  94474. private _useLightmapAsShadowmap;
  94475. /**
  94476. * In case of light mapping, define whether the map contains light or shadow informations.
  94477. */
  94478. useLightmapAsShadowmap: boolean;
  94479. private _diffuseFresnelParameters;
  94480. /**
  94481. * Define the diffuse fresnel parameters of the material.
  94482. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94483. */
  94484. diffuseFresnelParameters: FresnelParameters;
  94485. private _opacityFresnelParameters;
  94486. /**
  94487. * Define the opacity fresnel parameters of the material.
  94488. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94489. */
  94490. opacityFresnelParameters: FresnelParameters;
  94491. private _reflectionFresnelParameters;
  94492. /**
  94493. * Define the reflection fresnel parameters of the material.
  94494. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94495. */
  94496. reflectionFresnelParameters: FresnelParameters;
  94497. private _refractionFresnelParameters;
  94498. /**
  94499. * Define the refraction fresnel parameters of the material.
  94500. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94501. */
  94502. refractionFresnelParameters: FresnelParameters;
  94503. private _emissiveFresnelParameters;
  94504. /**
  94505. * Define the emissive fresnel parameters of the material.
  94506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94507. */
  94508. emissiveFresnelParameters: FresnelParameters;
  94509. private _useReflectionFresnelFromSpecular;
  94510. /**
  94511. * If true automatically deducts the fresnels values from the material specularity.
  94512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94513. */
  94514. useReflectionFresnelFromSpecular: boolean;
  94515. private _useGlossinessFromSpecularMapAlpha;
  94516. /**
  94517. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94518. */
  94519. useGlossinessFromSpecularMapAlpha: boolean;
  94520. private _maxSimultaneousLights;
  94521. /**
  94522. * Defines the maximum number of lights that can be used in the material
  94523. */
  94524. maxSimultaneousLights: number;
  94525. private _invertNormalMapX;
  94526. /**
  94527. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94528. */
  94529. invertNormalMapX: boolean;
  94530. private _invertNormalMapY;
  94531. /**
  94532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94533. */
  94534. invertNormalMapY: boolean;
  94535. private _twoSidedLighting;
  94536. /**
  94537. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94538. */
  94539. twoSidedLighting: boolean;
  94540. /**
  94541. * Default configuration related to image processing available in the standard Material.
  94542. */
  94543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94544. /**
  94545. * Gets the image processing configuration used either in this material.
  94546. */
  94547. /**
  94548. * Sets the Default image processing configuration used either in the this material.
  94549. *
  94550. * If sets to null, the scene one is in use.
  94551. */
  94552. imageProcessingConfiguration: ImageProcessingConfiguration;
  94553. /**
  94554. * Keep track of the image processing observer to allow dispose and replace.
  94555. */
  94556. private _imageProcessingObserver;
  94557. /**
  94558. * Attaches a new image processing configuration to the Standard Material.
  94559. * @param configuration
  94560. */
  94561. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94562. /**
  94563. * Gets wether the color curves effect is enabled.
  94564. */
  94565. /**
  94566. * Sets wether the color curves effect is enabled.
  94567. */
  94568. cameraColorCurvesEnabled: boolean;
  94569. /**
  94570. * Gets wether the color grading effect is enabled.
  94571. */
  94572. /**
  94573. * Gets wether the color grading effect is enabled.
  94574. */
  94575. cameraColorGradingEnabled: boolean;
  94576. /**
  94577. * Gets wether tonemapping is enabled or not.
  94578. */
  94579. /**
  94580. * Sets wether tonemapping is enabled or not
  94581. */
  94582. cameraToneMappingEnabled: boolean;
  94583. /**
  94584. * The camera exposure used on this material.
  94585. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94586. * This corresponds to a photographic exposure.
  94587. */
  94588. /**
  94589. * The camera exposure used on this material.
  94590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94591. * This corresponds to a photographic exposure.
  94592. */
  94593. cameraExposure: number;
  94594. /**
  94595. * Gets The camera contrast used on this material.
  94596. */
  94597. /**
  94598. * Sets The camera contrast used on this material.
  94599. */
  94600. cameraContrast: number;
  94601. /**
  94602. * Gets the Color Grading 2D Lookup Texture.
  94603. */
  94604. /**
  94605. * Sets the Color Grading 2D Lookup Texture.
  94606. */
  94607. cameraColorGradingTexture: Nullable<BaseTexture>;
  94608. /**
  94609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94611. * 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;
  94612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94613. */
  94614. /**
  94615. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94616. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94617. * 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;
  94618. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94619. */
  94620. cameraColorCurves: Nullable<ColorCurves>;
  94621. /**
  94622. * Custom callback helping to override the default shader used in the material.
  94623. */
  94624. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94625. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94626. protected _worldViewProjectionMatrix: Matrix;
  94627. protected _globalAmbientColor: Color3;
  94628. protected _useLogarithmicDepth: boolean;
  94629. /**
  94630. * Instantiates a new standard material.
  94631. * This is the default material used in Babylon. It is the best trade off between quality
  94632. * and performances.
  94633. * @see http://doc.babylonjs.com/babylon101/materials
  94634. * @param name Define the name of the material in the scene
  94635. * @param scene Define the scene the material belong to
  94636. */
  94637. constructor(name: string, scene: Scene);
  94638. /**
  94639. * Gets a boolean indicating that current material needs to register RTT
  94640. */
  94641. readonly hasRenderTargetTextures: boolean;
  94642. /**
  94643. * Gets the current class name of the material e.g. "StandardMaterial"
  94644. * Mainly use in serialization.
  94645. * @returns the class name
  94646. */
  94647. getClassName(): string;
  94648. /**
  94649. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94650. * You can try switching to logarithmic depth.
  94651. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94652. */
  94653. useLogarithmicDepth: boolean;
  94654. /**
  94655. * Specifies if the material will require alpha blending
  94656. * @returns a boolean specifying if alpha blending is needed
  94657. */
  94658. needAlphaBlending(): boolean;
  94659. /**
  94660. * Specifies if this material should be rendered in alpha test mode
  94661. * @returns a boolean specifying if an alpha test is needed.
  94662. */
  94663. needAlphaTesting(): boolean;
  94664. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94665. /**
  94666. * Get the texture used for alpha test purpose.
  94667. * @returns the diffuse texture in case of the standard material.
  94668. */
  94669. getAlphaTestTexture(): Nullable<BaseTexture>;
  94670. /**
  94671. * Get if the submesh is ready to be used and all its information available.
  94672. * Child classes can use it to update shaders
  94673. * @param mesh defines the mesh to check
  94674. * @param subMesh defines which submesh to check
  94675. * @param useInstances specifies that instances should be used
  94676. * @returns a boolean indicating that the submesh is ready or not
  94677. */
  94678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94679. /**
  94680. * Builds the material UBO layouts.
  94681. * Used internally during the effect preparation.
  94682. */
  94683. buildUniformLayout(): void;
  94684. /**
  94685. * Unbinds the material from the mesh
  94686. */
  94687. unbind(): void;
  94688. /**
  94689. * Binds the submesh to this material by preparing the effect and shader to draw
  94690. * @param world defines the world transformation matrix
  94691. * @param mesh defines the mesh containing the submesh
  94692. * @param subMesh defines the submesh to bind the material to
  94693. */
  94694. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94695. /**
  94696. * Get the list of animatables in the material.
  94697. * @returns the list of animatables object used in the material
  94698. */
  94699. getAnimatables(): IAnimatable[];
  94700. /**
  94701. * Gets the active textures from the material
  94702. * @returns an array of textures
  94703. */
  94704. getActiveTextures(): BaseTexture[];
  94705. /**
  94706. * Specifies if the material uses a texture
  94707. * @param texture defines the texture to check against the material
  94708. * @returns a boolean specifying if the material uses the texture
  94709. */
  94710. hasTexture(texture: BaseTexture): boolean;
  94711. /**
  94712. * Disposes the material
  94713. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94714. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94715. */
  94716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94717. /**
  94718. * Makes a duplicate of the material, and gives it a new name
  94719. * @param name defines the new name for the duplicated material
  94720. * @returns the cloned material
  94721. */
  94722. clone(name: string): StandardMaterial;
  94723. /**
  94724. * Serializes this material in a JSON representation
  94725. * @returns the serialized material object
  94726. */
  94727. serialize(): any;
  94728. /**
  94729. * Creates a standard material from parsed material data
  94730. * @param source defines the JSON representation of the material
  94731. * @param scene defines the hosting scene
  94732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94733. * @returns a new standard material
  94734. */
  94735. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94736. /**
  94737. * Are diffuse textures enabled in the application.
  94738. */
  94739. static DiffuseTextureEnabled: boolean;
  94740. /**
  94741. * Are ambient textures enabled in the application.
  94742. */
  94743. static AmbientTextureEnabled: boolean;
  94744. /**
  94745. * Are opacity textures enabled in the application.
  94746. */
  94747. static OpacityTextureEnabled: boolean;
  94748. /**
  94749. * Are reflection textures enabled in the application.
  94750. */
  94751. static ReflectionTextureEnabled: boolean;
  94752. /**
  94753. * Are emissive textures enabled in the application.
  94754. */
  94755. static EmissiveTextureEnabled: boolean;
  94756. /**
  94757. * Are specular textures enabled in the application.
  94758. */
  94759. static SpecularTextureEnabled: boolean;
  94760. /**
  94761. * Are bump textures enabled in the application.
  94762. */
  94763. static BumpTextureEnabled: boolean;
  94764. /**
  94765. * Are lightmap textures enabled in the application.
  94766. */
  94767. static LightmapTextureEnabled: boolean;
  94768. /**
  94769. * Are refraction textures enabled in the application.
  94770. */
  94771. static RefractionTextureEnabled: boolean;
  94772. /**
  94773. * Are color grading textures enabled in the application.
  94774. */
  94775. static ColorGradingTextureEnabled: boolean;
  94776. /**
  94777. * Are fresnels enabled in the application.
  94778. */
  94779. static FresnelEnabled: boolean;
  94780. }
  94781. }
  94782. declare module BABYLON {
  94783. /**
  94784. * A class extending Texture allowing drawing on a texture
  94785. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94786. */
  94787. export class DynamicTexture extends Texture {
  94788. private _generateMipMaps;
  94789. private _canvas;
  94790. private _context;
  94791. private _engine;
  94792. /**
  94793. * Creates a DynamicTexture
  94794. * @param name defines the name of the texture
  94795. * @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
  94796. * @param scene defines the scene where you want the texture
  94797. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94798. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94799. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94800. */
  94801. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94802. /**
  94803. * Get the current class name of the texture useful for serialization or dynamic coding.
  94804. * @returns "DynamicTexture"
  94805. */
  94806. getClassName(): string;
  94807. /**
  94808. * Gets the current state of canRescale
  94809. */
  94810. readonly canRescale: boolean;
  94811. private _recreate;
  94812. /**
  94813. * Scales the texture
  94814. * @param ratio the scale factor to apply to both width and height
  94815. */
  94816. scale(ratio: number): void;
  94817. /**
  94818. * Resizes the texture
  94819. * @param width the new width
  94820. * @param height the new height
  94821. */
  94822. scaleTo(width: number, height: number): void;
  94823. /**
  94824. * Gets the context of the canvas used by the texture
  94825. * @returns the canvas context of the dynamic texture
  94826. */
  94827. getContext(): CanvasRenderingContext2D;
  94828. /**
  94829. * Clears the texture
  94830. */
  94831. clear(): void;
  94832. /**
  94833. * Updates the texture
  94834. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94835. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94836. */
  94837. update(invertY?: boolean, premulAlpha?: boolean): void;
  94838. /**
  94839. * Draws text onto the texture
  94840. * @param text defines the text to be drawn
  94841. * @param x defines the placement of the text from the left
  94842. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94843. * @param font defines the font to be used with font-style, font-size, font-name
  94844. * @param color defines the color used for the text
  94845. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94846. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94847. * @param update defines whether texture is immediately update (default is true)
  94848. */
  94849. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94850. /**
  94851. * Clones the texture
  94852. * @returns the clone of the texture.
  94853. */
  94854. clone(): DynamicTexture;
  94855. /**
  94856. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94857. * @returns a serialized dynamic texture object
  94858. */
  94859. serialize(): any;
  94860. /** @hidden */
  94861. _rebuild(): void;
  94862. }
  94863. }
  94864. declare module BABYLON {
  94865. /** @hidden */
  94866. export var imageProcessingPixelShader: {
  94867. name: string;
  94868. shader: string;
  94869. };
  94870. }
  94871. declare module BABYLON {
  94872. /**
  94873. * ImageProcessingPostProcess
  94874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94875. */
  94876. export class ImageProcessingPostProcess extends PostProcess {
  94877. /**
  94878. * Default configuration related to image processing available in the PBR Material.
  94879. */
  94880. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94881. /**
  94882. * Gets the image processing configuration used either in this material.
  94883. */
  94884. /**
  94885. * Sets the Default image processing configuration used either in the this material.
  94886. *
  94887. * If sets to null, the scene one is in use.
  94888. */
  94889. imageProcessingConfiguration: ImageProcessingConfiguration;
  94890. /**
  94891. * Keep track of the image processing observer to allow dispose and replace.
  94892. */
  94893. private _imageProcessingObserver;
  94894. /**
  94895. * Attaches a new image processing configuration to the PBR Material.
  94896. * @param configuration
  94897. */
  94898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94899. /**
  94900. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94901. */
  94902. /**
  94903. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94904. */
  94905. colorCurves: Nullable<ColorCurves>;
  94906. /**
  94907. * Gets wether the color curves effect is enabled.
  94908. */
  94909. /**
  94910. * Sets wether the color curves effect is enabled.
  94911. */
  94912. colorCurvesEnabled: boolean;
  94913. /**
  94914. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94915. */
  94916. /**
  94917. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94918. */
  94919. colorGradingTexture: Nullable<BaseTexture>;
  94920. /**
  94921. * Gets wether the color grading effect is enabled.
  94922. */
  94923. /**
  94924. * Gets wether the color grading effect is enabled.
  94925. */
  94926. colorGradingEnabled: boolean;
  94927. /**
  94928. * Gets exposure used in the effect.
  94929. */
  94930. /**
  94931. * Sets exposure used in the effect.
  94932. */
  94933. exposure: number;
  94934. /**
  94935. * Gets wether tonemapping is enabled or not.
  94936. */
  94937. /**
  94938. * Sets wether tonemapping is enabled or not
  94939. */
  94940. toneMappingEnabled: boolean;
  94941. /**
  94942. * Gets contrast used in the effect.
  94943. */
  94944. /**
  94945. * Sets contrast used in the effect.
  94946. */
  94947. contrast: number;
  94948. /**
  94949. * Gets Vignette stretch size.
  94950. */
  94951. /**
  94952. * Sets Vignette stretch size.
  94953. */
  94954. vignetteStretch: number;
  94955. /**
  94956. * Gets Vignette centre X Offset.
  94957. */
  94958. /**
  94959. * Sets Vignette centre X Offset.
  94960. */
  94961. vignetteCentreX: number;
  94962. /**
  94963. * Gets Vignette centre Y Offset.
  94964. */
  94965. /**
  94966. * Sets Vignette centre Y Offset.
  94967. */
  94968. vignetteCentreY: number;
  94969. /**
  94970. * Gets Vignette weight or intensity of the vignette effect.
  94971. */
  94972. /**
  94973. * Sets Vignette weight or intensity of the vignette effect.
  94974. */
  94975. vignetteWeight: number;
  94976. /**
  94977. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94978. * if vignetteEnabled is set to true.
  94979. */
  94980. /**
  94981. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94982. * if vignetteEnabled is set to true.
  94983. */
  94984. vignetteColor: Color4;
  94985. /**
  94986. * Gets Camera field of view used by the Vignette effect.
  94987. */
  94988. /**
  94989. * Sets Camera field of view used by the Vignette effect.
  94990. */
  94991. vignetteCameraFov: number;
  94992. /**
  94993. * Gets the vignette blend mode allowing different kind of effect.
  94994. */
  94995. /**
  94996. * Sets the vignette blend mode allowing different kind of effect.
  94997. */
  94998. vignetteBlendMode: number;
  94999. /**
  95000. * Gets wether the vignette effect is enabled.
  95001. */
  95002. /**
  95003. * Sets wether the vignette effect is enabled.
  95004. */
  95005. vignetteEnabled: boolean;
  95006. private _fromLinearSpace;
  95007. /**
  95008. * Gets wether the input of the processing is in Gamma or Linear Space.
  95009. */
  95010. /**
  95011. * Sets wether the input of the processing is in Gamma or Linear Space.
  95012. */
  95013. fromLinearSpace: boolean;
  95014. /**
  95015. * Defines cache preventing GC.
  95016. */
  95017. private _defines;
  95018. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95019. /**
  95020. * "ImageProcessingPostProcess"
  95021. * @returns "ImageProcessingPostProcess"
  95022. */
  95023. getClassName(): string;
  95024. protected _updateParameters(): void;
  95025. dispose(camera?: Camera): void;
  95026. }
  95027. }
  95028. declare module BABYLON {
  95029. /**
  95030. * Class containing static functions to help procedurally build meshes
  95031. */
  95032. export class GroundBuilder {
  95033. /**
  95034. * Creates a ground mesh
  95035. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95036. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95038. * @param name defines the name of the mesh
  95039. * @param options defines the options used to create the mesh
  95040. * @param scene defines the hosting scene
  95041. * @returns the ground mesh
  95042. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95043. */
  95044. static CreateGround(name: string, options: {
  95045. width?: number;
  95046. height?: number;
  95047. subdivisions?: number;
  95048. subdivisionsX?: number;
  95049. subdivisionsY?: number;
  95050. updatable?: boolean;
  95051. }, scene: any): Mesh;
  95052. /**
  95053. * Creates a tiled ground mesh
  95054. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95055. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95056. * * 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
  95057. * * 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
  95058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95059. * @param name defines the name of the mesh
  95060. * @param options defines the options used to create the mesh
  95061. * @param scene defines the hosting scene
  95062. * @returns the tiled ground mesh
  95063. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95064. */
  95065. static CreateTiledGround(name: string, options: {
  95066. xmin: number;
  95067. zmin: number;
  95068. xmax: number;
  95069. zmax: number;
  95070. subdivisions?: {
  95071. w: number;
  95072. h: number;
  95073. };
  95074. precision?: {
  95075. w: number;
  95076. h: number;
  95077. };
  95078. updatable?: boolean;
  95079. }, scene: Scene): Mesh;
  95080. /**
  95081. * Creates a ground mesh from a height map
  95082. * * The parameter `url` sets the URL of the height map image resource.
  95083. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95084. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95085. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95086. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95087. * * 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.
  95088. * * 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).
  95089. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95091. * @param name defines the name of the mesh
  95092. * @param url defines the url to the height map
  95093. * @param options defines the options used to create the mesh
  95094. * @param scene defines the hosting scene
  95095. * @returns the ground mesh
  95096. * @see https://doc.babylonjs.com/babylon101/height_map
  95097. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95098. */
  95099. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95100. width?: number;
  95101. height?: number;
  95102. subdivisions?: number;
  95103. minHeight?: number;
  95104. maxHeight?: number;
  95105. colorFilter?: Color3;
  95106. alphaFilter?: number;
  95107. updatable?: boolean;
  95108. onReady?: (mesh: GroundMesh) => void;
  95109. }, scene: Scene): GroundMesh;
  95110. }
  95111. }
  95112. declare module BABYLON {
  95113. /**
  95114. * Class containing static functions to help procedurally build meshes
  95115. */
  95116. export class TorusBuilder {
  95117. /**
  95118. * Creates a torus mesh
  95119. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95120. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95121. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95125. * @param name defines the name of the mesh
  95126. * @param options defines the options used to create the mesh
  95127. * @param scene defines the hosting scene
  95128. * @returns the torus mesh
  95129. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95130. */
  95131. static CreateTorus(name: string, options: {
  95132. diameter?: number;
  95133. thickness?: number;
  95134. tessellation?: number;
  95135. updatable?: boolean;
  95136. sideOrientation?: number;
  95137. frontUVs?: Vector4;
  95138. backUVs?: Vector4;
  95139. }, scene: any): Mesh;
  95140. }
  95141. }
  95142. declare module BABYLON {
  95143. /**
  95144. * Class containing static functions to help procedurally build meshes
  95145. */
  95146. export class CylinderBuilder {
  95147. /**
  95148. * Creates a cylinder or a cone mesh
  95149. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95150. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95151. * * 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.
  95152. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95153. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95154. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95155. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95156. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95157. * * 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).
  95158. * * 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
  95159. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95160. * * 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
  95161. * * 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.
  95162. * * If `enclose` is false, a ring surface is one element.
  95163. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95164. * * 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
  95165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95168. * @param name defines the name of the mesh
  95169. * @param options defines the options used to create the mesh
  95170. * @param scene defines the hosting scene
  95171. * @returns the cylinder mesh
  95172. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95173. */
  95174. static CreateCylinder(name: string, options: {
  95175. height?: number;
  95176. diameterTop?: number;
  95177. diameterBottom?: number;
  95178. diameter?: number;
  95179. tessellation?: number;
  95180. subdivisions?: number;
  95181. arc?: number;
  95182. faceColors?: Color4[];
  95183. faceUV?: Vector4[];
  95184. updatable?: boolean;
  95185. hasRings?: boolean;
  95186. enclose?: boolean;
  95187. sideOrientation?: number;
  95188. frontUVs?: Vector4;
  95189. backUVs?: Vector4;
  95190. }, scene: any): Mesh;
  95191. }
  95192. }
  95193. declare module BABYLON {
  95194. /**
  95195. * Manager for handling gamepads
  95196. */
  95197. export class GamepadManager {
  95198. private _scene?;
  95199. private _babylonGamepads;
  95200. private _oneGamepadConnected;
  95201. /** @hidden */
  95202. _isMonitoring: boolean;
  95203. private _gamepadEventSupported;
  95204. private _gamepadSupport;
  95205. /**
  95206. * observable to be triggered when the gamepad controller has been connected
  95207. */
  95208. onGamepadConnectedObservable: Observable<Gamepad>;
  95209. /**
  95210. * observable to be triggered when the gamepad controller has been disconnected
  95211. */
  95212. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95213. private _onGamepadConnectedEvent;
  95214. private _onGamepadDisconnectedEvent;
  95215. /**
  95216. * Initializes the gamepad manager
  95217. * @param _scene BabylonJS scene
  95218. */
  95219. constructor(_scene?: Scene | undefined);
  95220. /**
  95221. * The gamepads in the game pad manager
  95222. */
  95223. readonly gamepads: Gamepad[];
  95224. /**
  95225. * Get the gamepad controllers based on type
  95226. * @param type The type of gamepad controller
  95227. * @returns Nullable gamepad
  95228. */
  95229. getGamepadByType(type?: number): Nullable<Gamepad>;
  95230. /**
  95231. * Disposes the gamepad manager
  95232. */
  95233. dispose(): void;
  95234. private _addNewGamepad;
  95235. private _startMonitoringGamepads;
  95236. private _stopMonitoringGamepads;
  95237. /** @hidden */
  95238. _checkGamepadsStatus(): void;
  95239. private _updateGamepadObjects;
  95240. }
  95241. }
  95242. declare module BABYLON {
  95243. interface Scene {
  95244. /** @hidden */
  95245. _gamepadManager: Nullable<GamepadManager>;
  95246. /**
  95247. * Gets the gamepad manager associated with the scene
  95248. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  95249. */
  95250. gamepadManager: GamepadManager;
  95251. }
  95252. /**
  95253. * Interface representing a free camera inputs manager
  95254. */
  95255. interface FreeCameraInputsManager {
  95256. /**
  95257. * Adds gamepad input support to the FreeCameraInputsManager.
  95258. * @returns the FreeCameraInputsManager
  95259. */
  95260. addGamepad(): FreeCameraInputsManager;
  95261. }
  95262. /**
  95263. * Interface representing an arc rotate camera inputs manager
  95264. */
  95265. interface ArcRotateCameraInputsManager {
  95266. /**
  95267. * Adds gamepad input support to the ArcRotateCamera InputManager.
  95268. * @returns the camera inputs manager
  95269. */
  95270. addGamepad(): ArcRotateCameraInputsManager;
  95271. }
  95272. /**
  95273. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  95274. */
  95275. export class GamepadSystemSceneComponent implements ISceneComponent {
  95276. /**
  95277. * The component name helpfull to identify the component in the list of scene components.
  95278. */
  95279. readonly name: string;
  95280. /**
  95281. * The scene the component belongs to.
  95282. */
  95283. scene: Scene;
  95284. /**
  95285. * Creates a new instance of the component for the given scene
  95286. * @param scene Defines the scene to register the component in
  95287. */
  95288. constructor(scene: Scene);
  95289. /**
  95290. * Registers the component in a given scene
  95291. */
  95292. register(): void;
  95293. /**
  95294. * Rebuilds the elements related to this component in case of
  95295. * context lost for instance.
  95296. */
  95297. rebuild(): void;
  95298. /**
  95299. * Disposes the component and the associated ressources
  95300. */
  95301. dispose(): void;
  95302. private _beforeCameraUpdate;
  95303. }
  95304. }
  95305. declare module BABYLON {
  95306. /**
  95307. * Options to modify the vr teleportation behavior.
  95308. */
  95309. export interface VRTeleportationOptions {
  95310. /**
  95311. * The name of the mesh which should be used as the teleportation floor. (default: null)
  95312. */
  95313. floorMeshName?: string;
  95314. /**
  95315. * A list of meshes to be used as the teleportation floor. (default: empty)
  95316. */
  95317. floorMeshes?: Mesh[];
  95318. }
  95319. /**
  95320. * Options to modify the vr experience helper's behavior.
  95321. */
  95322. export interface VRExperienceHelperOptions extends WebVROptions {
  95323. /**
  95324. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  95325. */
  95326. createDeviceOrientationCamera?: boolean;
  95327. /**
  95328. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  95329. */
  95330. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  95331. /**
  95332. * Uses the main button on the controller to toggle the laser casted. (default: true)
  95333. */
  95334. laserToggle?: boolean;
  95335. /**
  95336. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  95337. */
  95338. floorMeshes?: Mesh[];
  95339. /**
  95340. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  95341. */
  95342. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  95343. }
  95344. /**
  95345. * Helps to quickly add VR support to an existing scene.
  95346. * See http://doc.babylonjs.com/how_to/webvr_helper
  95347. */
  95348. export class VRExperienceHelper {
  95349. /** Options to modify the vr experience helper's behavior. */
  95350. webVROptions: VRExperienceHelperOptions;
  95351. private _scene;
  95352. private _position;
  95353. private _btnVR;
  95354. private _btnVRDisplayed;
  95355. private _webVRsupported;
  95356. private _webVRready;
  95357. private _webVRrequesting;
  95358. private _webVRpresenting;
  95359. private _hasEnteredVR;
  95360. private _fullscreenVRpresenting;
  95361. private _canvas;
  95362. private _webVRCamera;
  95363. private _vrDeviceOrientationCamera;
  95364. private _deviceOrientationCamera;
  95365. private _existingCamera;
  95366. private _onKeyDown;
  95367. private _onVrDisplayPresentChange;
  95368. private _onVRDisplayChanged;
  95369. private _onVRRequestPresentStart;
  95370. private _onVRRequestPresentComplete;
  95371. /**
  95372. * Observable raised when entering VR.
  95373. */
  95374. onEnteringVRObservable: Observable<VRExperienceHelper>;
  95375. /**
  95376. * Observable raised when exiting VR.
  95377. */
  95378. onExitingVRObservable: Observable<VRExperienceHelper>;
  95379. /**
  95380. * Observable raised when controller mesh is loaded.
  95381. */
  95382. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95383. /** Return this.onEnteringVRObservable
  95384. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  95385. */
  95386. readonly onEnteringVR: Observable<VRExperienceHelper>;
  95387. /** Return this.onExitingVRObservable
  95388. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  95389. */
  95390. readonly onExitingVR: Observable<VRExperienceHelper>;
  95391. /** Return this.onControllerMeshLoadedObservable
  95392. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  95393. */
  95394. readonly onControllerMeshLoaded: Observable<WebVRController>;
  95395. private _rayLength;
  95396. private _useCustomVRButton;
  95397. private _teleportationRequested;
  95398. private _teleportActive;
  95399. private _floorMeshName;
  95400. private _floorMeshesCollection;
  95401. private _rotationAllowed;
  95402. private _teleportBackwardsVector;
  95403. private _teleportationTarget;
  95404. private _isDefaultTeleportationTarget;
  95405. private _postProcessMove;
  95406. private _teleportationFillColor;
  95407. private _teleportationBorderColor;
  95408. private _rotationAngle;
  95409. private _haloCenter;
  95410. private _cameraGazer;
  95411. private _padSensibilityUp;
  95412. private _padSensibilityDown;
  95413. private _leftController;
  95414. private _rightController;
  95415. /**
  95416. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  95417. */
  95418. onNewMeshSelected: Observable<AbstractMesh>;
  95419. /**
  95420. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  95421. */
  95422. onNewMeshPicked: Observable<PickingInfo>;
  95423. private _circleEase;
  95424. /**
  95425. * Observable raised before camera teleportation
  95426. */
  95427. onBeforeCameraTeleport: Observable<Vector3>;
  95428. /**
  95429. * Observable raised after camera teleportation
  95430. */
  95431. onAfterCameraTeleport: Observable<Vector3>;
  95432. /**
  95433. * Observable raised when current selected mesh gets unselected
  95434. */
  95435. onSelectedMeshUnselected: Observable<AbstractMesh>;
  95436. private _raySelectionPredicate;
  95437. /**
  95438. * To be optionaly changed by user to define custom ray selection
  95439. */
  95440. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  95441. /**
  95442. * To be optionaly changed by user to define custom selection logic (after ray selection)
  95443. */
  95444. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  95445. /**
  95446. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  95447. */
  95448. teleportationEnabled: boolean;
  95449. private _defaultHeight;
  95450. private _teleportationInitialized;
  95451. private _interactionsEnabled;
  95452. private _interactionsRequested;
  95453. private _displayGaze;
  95454. private _displayLaserPointer;
  95455. /**
  95456. * The mesh used to display where the user is going to teleport.
  95457. */
  95458. /**
  95459. * Sets the mesh to be used to display where the user is going to teleport.
  95460. */
  95461. teleportationTarget: Mesh;
  95462. /**
  95463. * 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
  95464. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  95465. * See http://doc.babylonjs.com/resources/baking_transformations
  95466. */
  95467. gazeTrackerMesh: Mesh;
  95468. /**
  95469. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  95470. */
  95471. updateGazeTrackerScale: boolean;
  95472. /**
  95473. * If the gaze trackers color should be updated when selecting meshes
  95474. */
  95475. updateGazeTrackerColor: boolean;
  95476. /**
  95477. * The gaze tracking mesh corresponding to the left controller
  95478. */
  95479. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  95480. /**
  95481. * The gaze tracking mesh corresponding to the right controller
  95482. */
  95483. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  95484. /**
  95485. * If the ray of the gaze should be displayed.
  95486. */
  95487. /**
  95488. * Sets if the ray of the gaze should be displayed.
  95489. */
  95490. displayGaze: boolean;
  95491. /**
  95492. * If the ray of the LaserPointer should be displayed.
  95493. */
  95494. /**
  95495. * Sets if the ray of the LaserPointer should be displayed.
  95496. */
  95497. displayLaserPointer: boolean;
  95498. /**
  95499. * The deviceOrientationCamera used as the camera when not in VR.
  95500. */
  95501. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95502. /**
  95503. * Based on the current WebVR support, returns the current VR camera used.
  95504. */
  95505. readonly currentVRCamera: Nullable<Camera>;
  95506. /**
  95507. * The webVRCamera which is used when in VR.
  95508. */
  95509. readonly webVRCamera: WebVRFreeCamera;
  95510. /**
  95511. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95512. */
  95513. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95514. private readonly _teleportationRequestInitiated;
  95515. /**
  95516. * Defines wether or not Pointer lock should be requested when switching to
  95517. * full screen.
  95518. */
  95519. requestPointerLockOnFullScreen: boolean;
  95520. /**
  95521. * Instantiates a VRExperienceHelper.
  95522. * Helps to quickly add VR support to an existing scene.
  95523. * @param scene The scene the VRExperienceHelper belongs to.
  95524. * @param webVROptions Options to modify the vr experience helper's behavior.
  95525. */
  95526. constructor(scene: Scene,
  95527. /** Options to modify the vr experience helper's behavior. */
  95528. webVROptions?: VRExperienceHelperOptions);
  95529. private _onDefaultMeshLoaded;
  95530. private _onResize;
  95531. private _onFullscreenChange;
  95532. /**
  95533. * Gets a value indicating if we are currently in VR mode.
  95534. */
  95535. readonly isInVRMode: boolean;
  95536. private onVrDisplayPresentChange;
  95537. private onVRDisplayChanged;
  95538. private moveButtonToBottomRight;
  95539. private displayVRButton;
  95540. private updateButtonVisibility;
  95541. private _cachedAngularSensibility;
  95542. /**
  95543. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95544. * Otherwise, will use the fullscreen API.
  95545. */
  95546. enterVR(): void;
  95547. /**
  95548. * Attempt to exit VR, or fullscreen.
  95549. */
  95550. exitVR(): void;
  95551. /**
  95552. * The position of the vr experience helper.
  95553. */
  95554. /**
  95555. * Sets the position of the vr experience helper.
  95556. */
  95557. position: Vector3;
  95558. /**
  95559. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95560. */
  95561. enableInteractions(): void;
  95562. private readonly _noControllerIsActive;
  95563. private beforeRender;
  95564. private _isTeleportationFloor;
  95565. /**
  95566. * Adds a floor mesh to be used for teleportation.
  95567. * @param floorMesh the mesh to be used for teleportation.
  95568. */
  95569. addFloorMesh(floorMesh: Mesh): void;
  95570. /**
  95571. * Removes a floor mesh from being used for teleportation.
  95572. * @param floorMesh the mesh to be removed.
  95573. */
  95574. removeFloorMesh(floorMesh: Mesh): void;
  95575. /**
  95576. * Enables interactions and teleportation using the VR controllers and gaze.
  95577. * @param vrTeleportationOptions options to modify teleportation behavior.
  95578. */
  95579. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95580. private _onNewGamepadConnected;
  95581. private _tryEnableInteractionOnController;
  95582. private _onNewGamepadDisconnected;
  95583. private _enableInteractionOnController;
  95584. private _checkTeleportWithRay;
  95585. private _checkRotate;
  95586. private _checkTeleportBackwards;
  95587. private _enableTeleportationOnController;
  95588. private _createTeleportationCircles;
  95589. private _displayTeleportationTarget;
  95590. private _hideTeleportationTarget;
  95591. private _rotateCamera;
  95592. private _moveTeleportationSelectorTo;
  95593. private _workingVector;
  95594. private _workingQuaternion;
  95595. private _workingMatrix;
  95596. /**
  95597. * Teleports the users feet to the desired location
  95598. * @param location The location where the user's feet should be placed
  95599. */
  95600. teleportCamera(location: Vector3): void;
  95601. private _convertNormalToDirectionOfRay;
  95602. private _castRayAndSelectObject;
  95603. private _notifySelectedMeshUnselected;
  95604. /**
  95605. * Sets the color of the laser ray from the vr controllers.
  95606. * @param color new color for the ray.
  95607. */
  95608. changeLaserColor(color: Color3): void;
  95609. /**
  95610. * Sets the color of the ray from the vr headsets gaze.
  95611. * @param color new color for the ray.
  95612. */
  95613. changeGazeColor(color: Color3): void;
  95614. /**
  95615. * Exits VR and disposes of the vr experience helper
  95616. */
  95617. dispose(): void;
  95618. /**
  95619. * Gets the name of the VRExperienceHelper class
  95620. * @returns "VRExperienceHelper"
  95621. */
  95622. getClassName(): string;
  95623. }
  95624. }
  95625. declare module BABYLON {
  95626. /**
  95627. * Manages an XRSession
  95628. * @see https://doc.babylonjs.com/how_to/webxr
  95629. */
  95630. export class WebXRSessionManager implements IDisposable {
  95631. private scene;
  95632. /**
  95633. * Fires every time a new xrFrame arrives which can be used to update the camera
  95634. */
  95635. onXRFrameObservable: Observable<any>;
  95636. /**
  95637. * Fires when the xr session is ended either by the device or manually done
  95638. */
  95639. onXRSessionEnded: Observable<any>;
  95640. /** @hidden */
  95641. _xrSession: XRSession;
  95642. /** @hidden */
  95643. _frameOfReference: XRFrameOfReference;
  95644. /** @hidden */
  95645. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95646. /** @hidden */
  95647. _currentXRFrame: Nullable<XRFrame>;
  95648. private _xrNavigator;
  95649. private _xrDevice;
  95650. private _tmpMatrix;
  95651. /**
  95652. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95653. * @param scene The scene which the session should be created for
  95654. */
  95655. constructor(scene: Scene);
  95656. /**
  95657. * Initializes the manager
  95658. * After initialization enterXR can be called to start an XR session
  95659. * @returns Promise which resolves after it is initialized
  95660. */
  95661. initializeAsync(): Promise<void>;
  95662. /**
  95663. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95664. * @param sessionCreationOptions xr options to create the session with
  95665. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95666. * @returns Promise which resolves after it enters XR
  95667. */
  95668. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95669. /**
  95670. * Stops the xrSession and restores the renderloop
  95671. * @returns Promise which resolves after it exits XR
  95672. */
  95673. exitXRAsync(): Promise<void>;
  95674. /**
  95675. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95676. * @param ray ray to cast into the environment
  95677. * @returns Promise which resolves with a collision point in the environment if it exists
  95678. */
  95679. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95680. /**
  95681. * Checks if a session would be supported for the creation options specified
  95682. * @param options creation options to check if they are supported
  95683. * @returns true if supported
  95684. */
  95685. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95686. /**
  95687. * @hidden
  95688. * Converts the render layer of xrSession to a render target
  95689. * @param session session to create render target for
  95690. * @param scene scene the new render target should be created for
  95691. */
  95692. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95693. /**
  95694. * Disposes of the session manager
  95695. */
  95696. dispose(): void;
  95697. }
  95698. }
  95699. declare module BABYLON {
  95700. /**
  95701. * WebXR Camera which holds the views for the xrSession
  95702. * @see https://doc.babylonjs.com/how_to/webxr
  95703. */
  95704. export class WebXRCamera extends FreeCamera {
  95705. private static _TmpMatrix;
  95706. /**
  95707. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95708. * @param name the name of the camera
  95709. * @param scene the scene to add the camera to
  95710. */
  95711. constructor(name: string, scene: Scene);
  95712. private _updateNumberOfRigCameras;
  95713. /** @hidden */
  95714. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95715. /**
  95716. * Updates the cameras position from the current pose information of the XR session
  95717. * @param xrSessionManager the session containing pose information
  95718. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95719. */
  95720. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95721. }
  95722. }
  95723. declare module BABYLON {
  95724. /**
  95725. * States of the webXR experience
  95726. */
  95727. export enum WebXRState {
  95728. /**
  95729. * Transitioning to being in XR mode
  95730. */
  95731. ENTERING_XR = 0,
  95732. /**
  95733. * Transitioning to non XR mode
  95734. */
  95735. EXITING_XR = 1,
  95736. /**
  95737. * In XR mode and presenting
  95738. */
  95739. IN_XR = 2,
  95740. /**
  95741. * Not entered XR mode
  95742. */
  95743. NOT_IN_XR = 3
  95744. }
  95745. /**
  95746. * Helper class used to enable XR
  95747. * @see https://doc.babylonjs.com/how_to/webxr
  95748. */
  95749. export class WebXRExperienceHelper implements IDisposable {
  95750. private scene;
  95751. /**
  95752. * 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
  95753. */
  95754. container: AbstractMesh;
  95755. /**
  95756. * Camera used to render xr content
  95757. */
  95758. camera: WebXRCamera;
  95759. /**
  95760. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95761. */
  95762. state: WebXRState;
  95763. private _setState;
  95764. private static _TmpVector;
  95765. /**
  95766. * Fires when the state of the experience helper has changed
  95767. */
  95768. onStateChangedObservable: Observable<WebXRState>;
  95769. /** @hidden */
  95770. _sessionManager: WebXRSessionManager;
  95771. private _nonVRCamera;
  95772. private _originalSceneAutoClear;
  95773. private _supported;
  95774. /**
  95775. * Creates the experience helper
  95776. * @param scene the scene to attach the experience helper to
  95777. * @returns a promise for the experience helper
  95778. */
  95779. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95780. /**
  95781. * Creates a WebXRExperienceHelper
  95782. * @param scene The scene the helper should be created in
  95783. */
  95784. private constructor();
  95785. /**
  95786. * Exits XR mode and returns the scene to its original state
  95787. * @returns promise that resolves after xr mode has exited
  95788. */
  95789. exitXRAsync(): Promise<void>;
  95790. /**
  95791. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95792. * @param sessionCreationOptions options for the XR session
  95793. * @param frameOfReference frame of reference of the XR session
  95794. * @returns promise that resolves after xr mode has entered
  95795. */
  95796. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95797. /**
  95798. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95799. * @param ray ray to cast into the environment
  95800. * @returns Promise which resolves with a collision point in the environment if it exists
  95801. */
  95802. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95803. /**
  95804. * Updates the global position of the camera by moving the camera's container
  95805. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95806. * @param position The desired global position of the camera
  95807. */
  95808. setPositionOfCameraUsingContainer(position: Vector3): void;
  95809. /**
  95810. * Rotates the xr camera by rotating the camera's container around the camera's position
  95811. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95812. * @param rotation the desired quaternion rotation to apply to the camera
  95813. */
  95814. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95815. /**
  95816. * Checks if the creation options are supported by the xr session
  95817. * @param options creation options
  95818. * @returns true if supported
  95819. */
  95820. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95821. /**
  95822. * Disposes of the experience helper
  95823. */
  95824. dispose(): void;
  95825. }
  95826. }
  95827. declare module BABYLON {
  95828. /**
  95829. * Button which can be used to enter a different mode of XR
  95830. */
  95831. export class WebXREnterExitUIButton {
  95832. /** button element */
  95833. element: HTMLElement;
  95834. /** XR initialization options for the button */
  95835. initializationOptions: XRSessionCreationOptions;
  95836. /**
  95837. * Creates a WebXREnterExitUIButton
  95838. * @param element button element
  95839. * @param initializationOptions XR initialization options for the button
  95840. */
  95841. constructor(
  95842. /** button element */
  95843. element: HTMLElement,
  95844. /** XR initialization options for the button */
  95845. initializationOptions: XRSessionCreationOptions);
  95846. /**
  95847. * Overwritable function which can be used to update the button's visuals when the state changes
  95848. * @param activeButton the current active button in the UI
  95849. */
  95850. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95851. }
  95852. /**
  95853. * Options to create the webXR UI
  95854. */
  95855. export class WebXREnterExitUIOptions {
  95856. /**
  95857. * Context to enter xr with
  95858. */
  95859. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95860. /**
  95861. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95862. */
  95863. customButtons?: Array<WebXREnterExitUIButton>;
  95864. }
  95865. /**
  95866. * UI to allow the user to enter/exit XR mode
  95867. */
  95868. export class WebXREnterExitUI implements IDisposable {
  95869. private scene;
  95870. private _overlay;
  95871. private _buttons;
  95872. private _activeButton;
  95873. /**
  95874. * Fired every time the active button is changed.
  95875. *
  95876. * When xr is entered via a button that launches xr that button will be the callback parameter
  95877. *
  95878. * When exiting xr the callback parameter will be null)
  95879. */
  95880. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95881. /**
  95882. * Creates UI to allow the user to enter/exit XR mode
  95883. * @param scene the scene to add the ui to
  95884. * @param helper the xr experience helper to enter/exit xr with
  95885. * @param options options to configure the UI
  95886. * @returns the created ui
  95887. */
  95888. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95889. private constructor();
  95890. private _updateButtons;
  95891. /**
  95892. * Disposes of the object
  95893. */
  95894. dispose(): void;
  95895. }
  95896. }
  95897. declare module BABYLON {
  95898. /**
  95899. * Represents an XR input
  95900. */
  95901. export class WebXRController {
  95902. /**
  95903. * 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
  95904. */
  95905. grip?: AbstractMesh;
  95906. /**
  95907. * Pointer which can be used to select objects or attach a visible laser to
  95908. */
  95909. pointer: AbstractMesh;
  95910. /**
  95911. * Creates the controller
  95912. * @see https://doc.babylonjs.com/how_to/webxr
  95913. * @param scene the scene which the controller should be associated to
  95914. */
  95915. constructor(scene: Scene);
  95916. /**
  95917. * Disposes of the object
  95918. */
  95919. dispose(): void;
  95920. }
  95921. /**
  95922. * XR input used to track XR inputs such as controllers/rays
  95923. */
  95924. export class WebXRInput implements IDisposable {
  95925. private helper;
  95926. /**
  95927. * XR controllers being tracked
  95928. */
  95929. controllers: Array<WebXRController>;
  95930. private _tmpMatrix;
  95931. private _frameObserver;
  95932. /**
  95933. * Initializes the WebXRInput
  95934. * @param helper experience helper which the input should be created for
  95935. */
  95936. constructor(helper: WebXRExperienceHelper);
  95937. /**
  95938. * Disposes of the object
  95939. */
  95940. dispose(): void;
  95941. }
  95942. }
  95943. declare module BABYLON {
  95944. /**
  95945. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95946. */
  95947. export class WebXRManagedOutputCanvas implements IDisposable {
  95948. private _canvas;
  95949. /**
  95950. * xrpresent context of the canvas which can be used to display/mirror xr content
  95951. */
  95952. canvasContext: Nullable<WebGLRenderingContext>;
  95953. /**
  95954. * Initializes the canvas to be added/removed upon entering/exiting xr
  95955. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95956. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95957. */
  95958. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95959. /**
  95960. * Disposes of the object
  95961. */
  95962. dispose(): void;
  95963. private _setManagedOutputCanvas;
  95964. private _addCanvas;
  95965. private _removeCanvas;
  95966. }
  95967. }
  95968. declare module BABYLON {
  95969. /**
  95970. * Contains an array of blocks representing the octree
  95971. */
  95972. export interface IOctreeContainer<T> {
  95973. /**
  95974. * Blocks within the octree
  95975. */
  95976. blocks: Array<OctreeBlock<T>>;
  95977. }
  95978. /**
  95979. * Class used to store a cell in an octree
  95980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95981. */
  95982. export class OctreeBlock<T> {
  95983. /**
  95984. * Gets the content of the current block
  95985. */
  95986. entries: T[];
  95987. /**
  95988. * Gets the list of block children
  95989. */
  95990. blocks: Array<OctreeBlock<T>>;
  95991. private _depth;
  95992. private _maxDepth;
  95993. private _capacity;
  95994. private _minPoint;
  95995. private _maxPoint;
  95996. private _boundingVectors;
  95997. private _creationFunc;
  95998. /**
  95999. * Creates a new block
  96000. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96001. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96002. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96003. * @param depth defines the current depth of this block in the octree
  96004. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96005. * @param creationFunc defines a callback to call when an element is added to the block
  96006. */
  96007. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96008. /**
  96009. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96010. */
  96011. readonly capacity: number;
  96012. /**
  96013. * Gets the minimum vector (in world space) of the block's bounding box
  96014. */
  96015. readonly minPoint: Vector3;
  96016. /**
  96017. * Gets the maximum vector (in world space) of the block's bounding box
  96018. */
  96019. readonly maxPoint: Vector3;
  96020. /**
  96021. * Add a new element to this block
  96022. * @param entry defines the element to add
  96023. */
  96024. addEntry(entry: T): void;
  96025. /**
  96026. * Remove an element from this block
  96027. * @param entry defines the element to remove
  96028. */
  96029. removeEntry(entry: T): void;
  96030. /**
  96031. * Add an array of elements to this block
  96032. * @param entries defines the array of elements to add
  96033. */
  96034. addEntries(entries: T[]): void;
  96035. /**
  96036. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96037. * @param frustumPlanes defines the frustum planes to test
  96038. * @param selection defines the array to store current content if selection is positive
  96039. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96040. */
  96041. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96042. /**
  96043. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96044. * @param sphereCenter defines the bounding sphere center
  96045. * @param sphereRadius defines the bounding sphere radius
  96046. * @param selection defines the array to store current content if selection is positive
  96047. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96048. */
  96049. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96050. /**
  96051. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96052. * @param ray defines the ray to test with
  96053. * @param selection defines the array to store current content if selection is positive
  96054. */
  96055. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96056. /**
  96057. * Subdivide the content into child blocks (this block will then be empty)
  96058. */
  96059. createInnerBlocks(): void;
  96060. /**
  96061. * @hidden
  96062. */
  96063. 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;
  96064. }
  96065. }
  96066. declare module BABYLON {
  96067. /**
  96068. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96069. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96070. */
  96071. export class Octree<T> {
  96072. /** 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.) */
  96073. maxDepth: number;
  96074. /**
  96075. * Blocks within the octree containing objects
  96076. */
  96077. blocks: Array<OctreeBlock<T>>;
  96078. /**
  96079. * Content stored in the octree
  96080. */
  96081. dynamicContent: T[];
  96082. private _maxBlockCapacity;
  96083. private _selectionContent;
  96084. private _creationFunc;
  96085. /**
  96086. * Creates a octree
  96087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96088. * @param creationFunc function to be used to instatiate the octree
  96089. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96090. * @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.)
  96091. */
  96092. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96093. /** 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.) */
  96094. maxDepth?: number);
  96095. /**
  96096. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96097. * @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);
  96098. * @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);
  96099. * @param entries meshes to be added to the octree blocks
  96100. */
  96101. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96102. /**
  96103. * Adds a mesh to the octree
  96104. * @param entry Mesh to add to the octree
  96105. */
  96106. addMesh(entry: T): void;
  96107. /**
  96108. * Remove an element from the octree
  96109. * @param entry defines the element to remove
  96110. */
  96111. removeMesh(entry: T): void;
  96112. /**
  96113. * Selects an array of meshes within the frustum
  96114. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96115. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96116. * @returns array of meshes within the frustum
  96117. */
  96118. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96119. /**
  96120. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96121. * @param sphereCenter defines the bounding sphere center
  96122. * @param sphereRadius defines the bounding sphere radius
  96123. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96124. * @returns an array of objects that intersect the sphere
  96125. */
  96126. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96127. /**
  96128. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96129. * @param ray defines the ray to test with
  96130. * @returns array of intersected objects
  96131. */
  96132. intersectsRay(ray: Ray): SmartArray<T>;
  96133. /**
  96134. * Adds a mesh into the octree block if it intersects the block
  96135. */
  96136. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96137. /**
  96138. * Adds a submesh into the octree block if it intersects the block
  96139. */
  96140. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96141. }
  96142. }
  96143. declare module BABYLON {
  96144. interface Scene {
  96145. /**
  96146. * @hidden
  96147. * Backing Filed
  96148. */
  96149. _selectionOctree: Octree<AbstractMesh>;
  96150. /**
  96151. * Gets the octree used to boost mesh selection (picking)
  96152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96153. */
  96154. selectionOctree: Octree<AbstractMesh>;
  96155. /**
  96156. * Creates or updates the octree used to boost selection (picking)
  96157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96158. * @param maxCapacity defines the maximum capacity per leaf
  96159. * @param maxDepth defines the maximum depth of the octree
  96160. * @returns an octree of AbstractMesh
  96161. */
  96162. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96163. }
  96164. interface AbstractMesh {
  96165. /**
  96166. * @hidden
  96167. * Backing Field
  96168. */
  96169. _submeshesOctree: Octree<SubMesh>;
  96170. /**
  96171. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96172. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96173. * @param maxCapacity defines the maximum size of each block (64 by default)
  96174. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96175. * @returns the new octree
  96176. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96178. */
  96179. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96180. }
  96181. /**
  96182. * Defines the octree scene component responsible to manage any octrees
  96183. * in a given scene.
  96184. */
  96185. export class OctreeSceneComponent {
  96186. /**
  96187. * The component name helpfull to identify the component in the list of scene components.
  96188. */
  96189. readonly name: string;
  96190. /**
  96191. * The scene the component belongs to.
  96192. */
  96193. scene: Scene;
  96194. /**
  96195. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96196. */
  96197. readonly checksIsEnabled: boolean;
  96198. /**
  96199. * Creates a new instance of the component for the given scene
  96200. * @param scene Defines the scene to register the component in
  96201. */
  96202. constructor(scene: Scene);
  96203. /**
  96204. * Registers the component in a given scene
  96205. */
  96206. register(): void;
  96207. /**
  96208. * Return the list of active meshes
  96209. * @returns the list of active meshes
  96210. */
  96211. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96212. /**
  96213. * Return the list of active sub meshes
  96214. * @param mesh The mesh to get the candidates sub meshes from
  96215. * @returns the list of active sub meshes
  96216. */
  96217. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96218. private _tempRay;
  96219. /**
  96220. * Return the list of sub meshes intersecting with a given local ray
  96221. * @param mesh defines the mesh to find the submesh for
  96222. * @param localRay defines the ray in local space
  96223. * @returns the list of intersecting sub meshes
  96224. */
  96225. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96226. /**
  96227. * Return the list of sub meshes colliding with a collider
  96228. * @param mesh defines the mesh to find the submesh for
  96229. * @param collider defines the collider to evaluate the collision against
  96230. * @returns the list of colliding sub meshes
  96231. */
  96232. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96233. /**
  96234. * Rebuilds the elements related to this component in case of
  96235. * context lost for instance.
  96236. */
  96237. rebuild(): void;
  96238. /**
  96239. * Disposes the component and the associated ressources.
  96240. */
  96241. dispose(): void;
  96242. }
  96243. }
  96244. declare module BABYLON {
  96245. /**
  96246. * Class containing static functions to help procedurally build meshes
  96247. */
  96248. export class LinesBuilder {
  96249. /**
  96250. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  96251. * * 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
  96252. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  96253. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  96254. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  96255. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  96256. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  96257. * * 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
  96258. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  96259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  96261. * @param name defines the name of the new line system
  96262. * @param options defines the options used to create the line system
  96263. * @param scene defines the hosting scene
  96264. * @returns a new line system mesh
  96265. */
  96266. static CreateLineSystem(name: string, options: {
  96267. lines: Vector3[][];
  96268. updatable?: boolean;
  96269. instance?: Nullable<LinesMesh>;
  96270. colors?: Nullable<Color4[][]>;
  96271. useVertexAlpha?: boolean;
  96272. }, scene: Nullable<Scene>): LinesMesh;
  96273. /**
  96274. * Creates a line mesh
  96275. * 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
  96276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96277. * * The parameter `points` is an array successive Vector3
  96278. * * 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
  96279. * * The optional parameter `colors` is an array of successive Color4, one per line point
  96280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  96281. * * When updating an instance, remember that only point positions can change, not the number of points
  96282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  96284. * @param name defines the name of the new line system
  96285. * @param options defines the options used to create the line system
  96286. * @param scene defines the hosting scene
  96287. * @returns a new line mesh
  96288. */
  96289. static CreateLines(name: string, options: {
  96290. points: Vector3[];
  96291. updatable?: boolean;
  96292. instance?: Nullable<LinesMesh>;
  96293. colors?: Color4[];
  96294. useVertexAlpha?: boolean;
  96295. }, scene?: Nullable<Scene>): LinesMesh;
  96296. /**
  96297. * Creates a dashed line mesh
  96298. * * 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
  96299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96300. * * The parameter `points` is an array successive Vector3
  96301. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  96302. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  96303. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96304. * * 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
  96305. * * When updating an instance, remember that only point positions can change, not the number of points
  96306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96307. * @param name defines the name of the mesh
  96308. * @param options defines the options used to create the mesh
  96309. * @param scene defines the hosting scene
  96310. * @returns the dashed line mesh
  96311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  96312. */
  96313. static CreateDashedLines(name: string, options: {
  96314. points: Vector3[];
  96315. dashSize?: number;
  96316. gapSize?: number;
  96317. dashNb?: number;
  96318. updatable?: boolean;
  96319. instance?: LinesMesh;
  96320. }, scene?: Nullable<Scene>): LinesMesh;
  96321. }
  96322. }
  96323. declare module BABYLON {
  96324. /**
  96325. * Renders a layer on top of an existing scene
  96326. */
  96327. export class UtilityLayerRenderer implements IDisposable {
  96328. /** the original scene that will be rendered on top of */
  96329. originalScene: Scene;
  96330. private _pointerCaptures;
  96331. private _lastPointerEvents;
  96332. private static _DefaultUtilityLayer;
  96333. private static _DefaultKeepDepthUtilityLayer;
  96334. /**
  96335. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  96336. */
  96337. pickUtilitySceneFirst: boolean;
  96338. /**
  96339. * 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)
  96340. */
  96341. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  96342. /**
  96343. * 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)
  96344. */
  96345. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  96346. /**
  96347. * The scene that is rendered on top of the original scene
  96348. */
  96349. utilityLayerScene: Scene;
  96350. /**
  96351. * If the utility layer should automatically be rendered on top of existing scene
  96352. */
  96353. shouldRender: boolean;
  96354. /**
  96355. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  96356. */
  96357. onlyCheckPointerDownEvents: boolean;
  96358. /**
  96359. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  96360. */
  96361. processAllEvents: boolean;
  96362. /**
  96363. * Observable raised when the pointer move from the utility layer scene to the main scene
  96364. */
  96365. onPointerOutObservable: Observable<number>;
  96366. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  96367. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  96368. private _afterRenderObserver;
  96369. private _sceneDisposeObserver;
  96370. private _originalPointerObserver;
  96371. /**
  96372. * Instantiates a UtilityLayerRenderer
  96373. * @param originalScene the original scene that will be rendered on top of
  96374. * @param handleEvents boolean indicating if the utility layer should handle events
  96375. */
  96376. constructor(
  96377. /** the original scene that will be rendered on top of */
  96378. originalScene: Scene, handleEvents?: boolean);
  96379. private _notifyObservers;
  96380. /**
  96381. * Renders the utility layers scene on top of the original scene
  96382. */
  96383. render(): void;
  96384. /**
  96385. * Disposes of the renderer
  96386. */
  96387. dispose(): void;
  96388. private _updateCamera;
  96389. }
  96390. }
  96391. declare module BABYLON {
  96392. /**
  96393. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  96394. */
  96395. export class Gizmo implements IDisposable {
  96396. /** The utility layer the gizmo will be added to */
  96397. gizmoLayer: UtilityLayerRenderer;
  96398. /**
  96399. * The root mesh of the gizmo
  96400. */
  96401. _rootMesh: Mesh;
  96402. private _attachedMesh;
  96403. /**
  96404. * Ratio for the scale of the gizmo (Default: 1)
  96405. */
  96406. scaleRatio: number;
  96407. private _tmpMatrix;
  96408. /**
  96409. * If a custom mesh has been set (Default: false)
  96410. */
  96411. protected _customMeshSet: boolean;
  96412. /**
  96413. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  96414. * * When set, interactions will be enabled
  96415. */
  96416. attachedMesh: Nullable<AbstractMesh>;
  96417. /**
  96418. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  96419. * @param mesh The mesh to replace the default mesh of the gizmo
  96420. */
  96421. setCustomMesh(mesh: Mesh): void;
  96422. /**
  96423. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  96424. */
  96425. updateGizmoRotationToMatchAttachedMesh: boolean;
  96426. /**
  96427. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  96428. */
  96429. updateGizmoPositionToMatchAttachedMesh: boolean;
  96430. /**
  96431. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  96432. */
  96433. protected _updateScale: boolean;
  96434. protected _interactionsEnabled: boolean;
  96435. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96436. private _beforeRenderObserver;
  96437. /**
  96438. * Creates a gizmo
  96439. * @param gizmoLayer The utility layer the gizmo will be added to
  96440. */
  96441. constructor(
  96442. /** The utility layer the gizmo will be added to */
  96443. gizmoLayer?: UtilityLayerRenderer);
  96444. private _tempVector;
  96445. /**
  96446. * @hidden
  96447. * Updates the gizmo to match the attached mesh's position/rotation
  96448. */
  96449. protected _update(): void;
  96450. /**
  96451. * Disposes of the gizmo
  96452. */
  96453. dispose(): void;
  96454. }
  96455. }
  96456. declare module BABYLON {
  96457. /**
  96458. * Single axis drag gizmo
  96459. */
  96460. export class AxisDragGizmo extends Gizmo {
  96461. /**
  96462. * Drag behavior responsible for the gizmos dragging interactions
  96463. */
  96464. dragBehavior: PointerDragBehavior;
  96465. private _pointerObserver;
  96466. /**
  96467. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  96468. */
  96469. snapDistance: number;
  96470. /**
  96471. * Event that fires each time the gizmo snaps to a new location.
  96472. * * snapDistance is the the change in distance
  96473. */
  96474. onSnapObservable: Observable<{
  96475. snapDistance: number;
  96476. }>;
  96477. /** @hidden */
  96478. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  96479. /** @hidden */
  96480. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  96481. /**
  96482. * Creates an AxisDragGizmo
  96483. * @param gizmoLayer The utility layer the gizmo will be added to
  96484. * @param dragAxis The axis which the gizmo will be able to drag on
  96485. * @param color The color of the gizmo
  96486. */
  96487. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96488. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96489. /**
  96490. * Disposes of the gizmo
  96491. */
  96492. dispose(): void;
  96493. }
  96494. }
  96495. declare module BABYLON.Debug {
  96496. /**
  96497. * The Axes viewer will show 3 axes in a specific point in space
  96498. */
  96499. export class AxesViewer {
  96500. private _xAxis;
  96501. private _yAxis;
  96502. private _zAxis;
  96503. private _scaleLinesFactor;
  96504. private _instanced;
  96505. /**
  96506. * Gets the hosting scene
  96507. */
  96508. scene: Scene;
  96509. /**
  96510. * Gets or sets a number used to scale line length
  96511. */
  96512. scaleLines: number;
  96513. /** Gets the node hierarchy used to render x-axis */
  96514. readonly xAxis: TransformNode;
  96515. /** Gets the node hierarchy used to render y-axis */
  96516. readonly yAxis: TransformNode;
  96517. /** Gets the node hierarchy used to render z-axis */
  96518. readonly zAxis: TransformNode;
  96519. /**
  96520. * Creates a new AxesViewer
  96521. * @param scene defines the hosting scene
  96522. * @param scaleLines defines a number used to scale line length (1 by default)
  96523. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96524. * @param xAxis defines the node hierarchy used to render the x-axis
  96525. * @param yAxis defines the node hierarchy used to render the y-axis
  96526. * @param zAxis defines the node hierarchy used to render the z-axis
  96527. */
  96528. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96529. /**
  96530. * Force the viewer to update
  96531. * @param position defines the position of the viewer
  96532. * @param xaxis defines the x axis of the viewer
  96533. * @param yaxis defines the y axis of the viewer
  96534. * @param zaxis defines the z axis of the viewer
  96535. */
  96536. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96537. /**
  96538. * Creates an instance of this axes viewer.
  96539. * @returns a new axes viewer with instanced meshes
  96540. */
  96541. createInstance(): AxesViewer;
  96542. /** Releases resources */
  96543. dispose(): void;
  96544. private static _SetRenderingGroupId;
  96545. }
  96546. }
  96547. declare module BABYLON.Debug {
  96548. /**
  96549. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96550. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96551. */
  96552. export class BoneAxesViewer extends AxesViewer {
  96553. /**
  96554. * Gets or sets the target mesh where to display the axes viewer
  96555. */
  96556. mesh: Nullable<Mesh>;
  96557. /**
  96558. * Gets or sets the target bone where to display the axes viewer
  96559. */
  96560. bone: Nullable<Bone>;
  96561. /** Gets current position */
  96562. pos: Vector3;
  96563. /** Gets direction of X axis */
  96564. xaxis: Vector3;
  96565. /** Gets direction of Y axis */
  96566. yaxis: Vector3;
  96567. /** Gets direction of Z axis */
  96568. zaxis: Vector3;
  96569. /**
  96570. * Creates a new BoneAxesViewer
  96571. * @param scene defines the hosting scene
  96572. * @param bone defines the target bone
  96573. * @param mesh defines the target mesh
  96574. * @param scaleLines defines a scaling factor for line length (1 by default)
  96575. */
  96576. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96577. /**
  96578. * Force the viewer to update
  96579. */
  96580. update(): void;
  96581. /** Releases resources */
  96582. dispose(): void;
  96583. }
  96584. }
  96585. declare module BABYLON {
  96586. /**
  96587. * Interface used to define scene explorer extensibility option
  96588. */
  96589. export interface IExplorerExtensibilityOption {
  96590. /**
  96591. * Define the option label
  96592. */
  96593. label: string;
  96594. /**
  96595. * Defines the action to execute on click
  96596. */
  96597. action: (entity: any) => void;
  96598. }
  96599. /**
  96600. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96601. */
  96602. export interface IExplorerExtensibilityGroup {
  96603. /**
  96604. * Defines a predicate to test if a given type mut be extended
  96605. */
  96606. predicate: (entity: any) => boolean;
  96607. /**
  96608. * Gets the list of options added to a type
  96609. */
  96610. entries: IExplorerExtensibilityOption[];
  96611. }
  96612. /**
  96613. * Interface used to define the options to use to create the Inspector
  96614. */
  96615. export interface IInspectorOptions {
  96616. /**
  96617. * Display in overlay mode (default: false)
  96618. */
  96619. overlay?: boolean;
  96620. /**
  96621. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96622. */
  96623. globalRoot?: HTMLElement;
  96624. /**
  96625. * Display the Scene explorer
  96626. */
  96627. showExplorer?: boolean;
  96628. /**
  96629. * Display the property inspector
  96630. */
  96631. showInspector?: boolean;
  96632. /**
  96633. * Display in embed mode (both panes on the right)
  96634. */
  96635. embedMode?: boolean;
  96636. /**
  96637. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96638. */
  96639. handleResize?: boolean;
  96640. /**
  96641. * Allow the panes to popup (default: true)
  96642. */
  96643. enablePopup?: boolean;
  96644. /**
  96645. * Allow the panes to be closed by users (default: true)
  96646. */
  96647. enableClose?: boolean;
  96648. /**
  96649. * Optional list of extensibility entries
  96650. */
  96651. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96652. /**
  96653. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  96654. */
  96655. inspectorURL?: string;
  96656. }
  96657. interface Scene {
  96658. /**
  96659. * @hidden
  96660. * Backing field
  96661. */
  96662. _debugLayer: DebugLayer;
  96663. /**
  96664. * Gets the debug layer (aka Inspector) associated with the scene
  96665. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96666. */
  96667. debugLayer: DebugLayer;
  96668. }
  96669. /**
  96670. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96671. * what is happening in your scene
  96672. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96673. */
  96674. export class DebugLayer {
  96675. /**
  96676. * Define the url to get the inspector script from.
  96677. * By default it uses the babylonjs CDN.
  96678. * @ignoreNaming
  96679. */
  96680. static InspectorURL: string;
  96681. private _scene;
  96682. private BJSINSPECTOR;
  96683. /**
  96684. * Observable triggered when a property is changed through the inspector.
  96685. */
  96686. onPropertyChangedObservable: Observable<{
  96687. object: any;
  96688. property: string;
  96689. value: any;
  96690. initialValue: any;
  96691. }>;
  96692. /**
  96693. * Instantiates a new debug layer.
  96694. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96695. * what is happening in your scene
  96696. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96697. * @param scene Defines the scene to inspect
  96698. */
  96699. constructor(scene: Scene);
  96700. /** Creates the inspector window. */
  96701. private _createInspector;
  96702. /**
  96703. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  96704. * @param entity defines the entity to select
  96705. * @param lineContainerTitle defines the specific block to highlight
  96706. */
  96707. select(entity: any, lineContainerTitle?: string): void;
  96708. /** Get the inspector from bundle or global */
  96709. private _getGlobalInspector;
  96710. /**
  96711. * Get if the inspector is visible or not.
  96712. * @returns true if visible otherwise, false
  96713. */
  96714. isVisible(): boolean;
  96715. /**
  96716. * Hide the inspector and close its window.
  96717. */
  96718. hide(): void;
  96719. /**
  96720. * Launch the debugLayer.
  96721. * @param config Define the configuration of the inspector
  96722. * @return a promise fulfilled when the debug layer is visible
  96723. */
  96724. show(config?: IInspectorOptions): Promise<DebugLayer>;
  96725. }
  96726. }
  96727. declare module BABYLON {
  96728. /**
  96729. * Class containing static functions to help procedurally build meshes
  96730. */
  96731. export class BoxBuilder {
  96732. /**
  96733. * Creates a box mesh
  96734. * * The parameter `size` sets the size (float) of each box side (default 1)
  96735. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96736. * * 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)
  96737. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96741. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96742. * @param name defines the name of the mesh
  96743. * @param options defines the options used to create the mesh
  96744. * @param scene defines the hosting scene
  96745. * @returns the box mesh
  96746. */
  96747. static CreateBox(name: string, options: {
  96748. size?: number;
  96749. width?: number;
  96750. height?: number;
  96751. depth?: number;
  96752. faceUV?: Vector4[];
  96753. faceColors?: Color4[];
  96754. sideOrientation?: number;
  96755. frontUVs?: Vector4;
  96756. backUVs?: Vector4;
  96757. updatable?: boolean;
  96758. }, scene?: Nullable<Scene>): Mesh;
  96759. }
  96760. }
  96761. declare module BABYLON {
  96762. /**
  96763. * Class containing static functions to help procedurally build meshes
  96764. */
  96765. export class SphereBuilder {
  96766. /**
  96767. * Creates a sphere mesh
  96768. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96769. * * 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`)
  96770. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96771. * * 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
  96772. * * 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)
  96773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96776. * @param name defines the name of the mesh
  96777. * @param options defines the options used to create the mesh
  96778. * @param scene defines the hosting scene
  96779. * @returns the sphere mesh
  96780. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96781. */
  96782. static CreateSphere(name: string, options: {
  96783. segments?: number;
  96784. diameter?: number;
  96785. diameterX?: number;
  96786. diameterY?: number;
  96787. diameterZ?: number;
  96788. arc?: number;
  96789. slice?: number;
  96790. sideOrientation?: number;
  96791. frontUVs?: Vector4;
  96792. backUVs?: Vector4;
  96793. updatable?: boolean;
  96794. }, scene: any): Mesh;
  96795. }
  96796. }
  96797. declare module BABYLON.Debug {
  96798. /**
  96799. * Used to show the physics impostor around the specific mesh
  96800. */
  96801. export class PhysicsViewer {
  96802. /** @hidden */
  96803. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96804. /** @hidden */
  96805. protected _meshes: Array<Nullable<AbstractMesh>>;
  96806. /** @hidden */
  96807. protected _scene: Nullable<Scene>;
  96808. /** @hidden */
  96809. protected _numMeshes: number;
  96810. /** @hidden */
  96811. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96812. private _renderFunction;
  96813. private _utilityLayer;
  96814. private _debugBoxMesh;
  96815. private _debugSphereMesh;
  96816. private _debugMaterial;
  96817. /**
  96818. * Creates a new PhysicsViewer
  96819. * @param scene defines the hosting scene
  96820. */
  96821. constructor(scene: Scene);
  96822. /** @hidden */
  96823. protected _updateDebugMeshes(): void;
  96824. /**
  96825. * Renders a specified physic impostor
  96826. * @param impostor defines the impostor to render
  96827. * @returns the new debug mesh used to render the impostor
  96828. */
  96829. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96830. /**
  96831. * Hides a specified physic impostor
  96832. * @param impostor defines the impostor to hide
  96833. */
  96834. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96835. private _getDebugMaterial;
  96836. private _getDebugBoxMesh;
  96837. private _getDebugSphereMesh;
  96838. private _getDebugMesh;
  96839. /** Releases all resources */
  96840. dispose(): void;
  96841. }
  96842. }
  96843. declare module BABYLON {
  96844. /**
  96845. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96846. * in order to better appreciate the issue one might have.
  96847. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96848. */
  96849. export class RayHelper {
  96850. /**
  96851. * Defines the ray we are currently tryin to visualize.
  96852. */
  96853. ray: Nullable<Ray>;
  96854. private _renderPoints;
  96855. private _renderLine;
  96856. private _renderFunction;
  96857. private _scene;
  96858. private _updateToMeshFunction;
  96859. private _attachedToMesh;
  96860. private _meshSpaceDirection;
  96861. private _meshSpaceOrigin;
  96862. /**
  96863. * Helper function to create a colored helper in a scene in one line.
  96864. * @param ray Defines the ray we are currently tryin to visualize
  96865. * @param scene Defines the scene the ray is used in
  96866. * @param color Defines the color we want to see the ray in
  96867. * @returns The newly created ray helper.
  96868. */
  96869. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96870. /**
  96871. * Instantiate a new ray helper.
  96872. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96873. * in order to better appreciate the issue one might have.
  96874. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96875. * @param ray Defines the ray we are currently tryin to visualize
  96876. */
  96877. constructor(ray: Ray);
  96878. /**
  96879. * Shows the ray we are willing to debug.
  96880. * @param scene Defines the scene the ray needs to be rendered in
  96881. * @param color Defines the color the ray needs to be rendered in
  96882. */
  96883. show(scene: Scene, color?: Color3): void;
  96884. /**
  96885. * Hides the ray we are debugging.
  96886. */
  96887. hide(): void;
  96888. private _render;
  96889. /**
  96890. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96891. * @param mesh Defines the mesh we want the helper attached to
  96892. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96893. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96894. * @param length Defines the length of the ray
  96895. */
  96896. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96897. /**
  96898. * Detach the ray helper from the mesh it has previously been attached to.
  96899. */
  96900. detachFromMesh(): void;
  96901. private _updateToMesh;
  96902. /**
  96903. * Dispose the helper and release its associated resources.
  96904. */
  96905. dispose(): void;
  96906. }
  96907. }
  96908. declare module BABYLON.Debug {
  96909. /**
  96910. * Class used to render a debug view of a given skeleton
  96911. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96912. */
  96913. export class SkeletonViewer {
  96914. /** defines the skeleton to render */
  96915. skeleton: Skeleton;
  96916. /** defines the mesh attached to the skeleton */
  96917. mesh: AbstractMesh;
  96918. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96919. autoUpdateBonesMatrices: boolean;
  96920. /** defines the rendering group id to use with the viewer */
  96921. renderingGroupId: number;
  96922. /** Gets or sets the color used to render the skeleton */
  96923. color: Color3;
  96924. private _scene;
  96925. private _debugLines;
  96926. private _debugMesh;
  96927. private _isEnabled;
  96928. private _renderFunction;
  96929. private _utilityLayer;
  96930. /**
  96931. * Returns the mesh used to render the bones
  96932. */
  96933. readonly debugMesh: Nullable<LinesMesh>;
  96934. /**
  96935. * Creates a new SkeletonViewer
  96936. * @param skeleton defines the skeleton to render
  96937. * @param mesh defines the mesh attached to the skeleton
  96938. * @param scene defines the hosting scene
  96939. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96940. * @param renderingGroupId defines the rendering group id to use with the viewer
  96941. */
  96942. constructor(
  96943. /** defines the skeleton to render */
  96944. skeleton: Skeleton,
  96945. /** defines the mesh attached to the skeleton */
  96946. mesh: AbstractMesh, scene: Scene,
  96947. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96948. autoUpdateBonesMatrices?: boolean,
  96949. /** defines the rendering group id to use with the viewer */
  96950. renderingGroupId?: number);
  96951. /** Gets or sets a boolean indicating if the viewer is enabled */
  96952. isEnabled: boolean;
  96953. private _getBonePosition;
  96954. private _getLinesForBonesWithLength;
  96955. private _getLinesForBonesNoLength;
  96956. /** Update the viewer to sync with current skeleton state */
  96957. update(): void;
  96958. /** Release associated resources */
  96959. dispose(): void;
  96960. }
  96961. }
  96962. declare module BABYLON {
  96963. /**
  96964. * Options to create the null engine
  96965. */
  96966. export class NullEngineOptions {
  96967. /**
  96968. * Render width (Default: 512)
  96969. */
  96970. renderWidth: number;
  96971. /**
  96972. * Render height (Default: 256)
  96973. */
  96974. renderHeight: number;
  96975. /**
  96976. * Texture size (Default: 512)
  96977. */
  96978. textureSize: number;
  96979. /**
  96980. * If delta time between frames should be constant
  96981. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96982. */
  96983. deterministicLockstep: boolean;
  96984. /**
  96985. * Maximum about of steps between frames (Default: 4)
  96986. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96987. */
  96988. lockstepMaxSteps: number;
  96989. }
  96990. /**
  96991. * The null engine class provides support for headless version of babylon.js.
  96992. * This can be used in server side scenario or for testing purposes
  96993. */
  96994. export class NullEngine extends Engine {
  96995. private _options;
  96996. /**
  96997. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96998. */
  96999. isDeterministicLockStep(): boolean;
  97000. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97001. getLockstepMaxSteps(): number;
  97002. /**
  97003. * Sets hardware scaling, used to save performance if needed
  97004. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97005. */
  97006. getHardwareScalingLevel(): number;
  97007. constructor(options?: NullEngineOptions);
  97008. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97009. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97010. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97011. getRenderWidth(useScreen?: boolean): number;
  97012. getRenderHeight(useScreen?: boolean): number;
  97013. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97014. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97015. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97016. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97017. bindSamplers(effect: Effect): void;
  97018. enableEffect(effect: Effect): void;
  97019. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97020. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97021. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97022. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97023. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97024. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97025. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97026. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97027. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97028. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97029. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97030. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97031. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97032. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97033. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97034. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97035. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97036. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97037. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97038. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97039. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97040. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97041. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97042. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97043. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97044. bindBuffers(vertexBuffers: {
  97045. [key: string]: VertexBuffer;
  97046. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97047. wipeCaches(bruteForce?: boolean): void;
  97048. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97049. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97050. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97051. /** @hidden */
  97052. _createTexture(): WebGLTexture;
  97053. /** @hidden */
  97054. _releaseTexture(texture: InternalTexture): void;
  97055. 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;
  97056. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97057. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97058. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97059. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97060. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97061. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97062. areAllEffectsReady(): boolean;
  97063. /**
  97064. * @hidden
  97065. * Get the current error code of the webGL context
  97066. * @returns the error code
  97067. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97068. */
  97069. getError(): number;
  97070. /** @hidden */
  97071. _getUnpackAlignement(): number;
  97072. /** @hidden */
  97073. _unpackFlipY(value: boolean): void;
  97074. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97075. /**
  97076. * Updates a dynamic vertex buffer.
  97077. * @param vertexBuffer the vertex buffer to update
  97078. * @param data the data used to update the vertex buffer
  97079. * @param byteOffset the byte offset of the data (optional)
  97080. * @param byteLength the byte length of the data (optional)
  97081. */
  97082. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97083. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97084. /** @hidden */
  97085. _bindTexture(channel: number, texture: InternalTexture): void;
  97086. /** @hidden */
  97087. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97088. releaseEffects(): void;
  97089. displayLoadingUI(): void;
  97090. hideLoadingUI(): void;
  97091. /** @hidden */
  97092. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97093. /** @hidden */
  97094. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97095. /** @hidden */
  97096. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97097. /** @hidden */
  97098. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97099. }
  97100. }
  97101. declare module BABYLON {
  97102. /** @hidden */
  97103. export class _OcclusionDataStorage {
  97104. /** @hidden */
  97105. occlusionInternalRetryCounter: number;
  97106. /** @hidden */
  97107. isOcclusionQueryInProgress: boolean;
  97108. /** @hidden */
  97109. isOccluded: boolean;
  97110. /** @hidden */
  97111. occlusionRetryCount: number;
  97112. /** @hidden */
  97113. occlusionType: number;
  97114. /** @hidden */
  97115. occlusionQueryAlgorithmType: number;
  97116. }
  97117. interface Engine {
  97118. /**
  97119. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97120. * @return the new query
  97121. */
  97122. createQuery(): WebGLQuery;
  97123. /**
  97124. * Delete and release a webGL query
  97125. * @param query defines the query to delete
  97126. * @return the current engine
  97127. */
  97128. deleteQuery(query: WebGLQuery): Engine;
  97129. /**
  97130. * Check if a given query has resolved and got its value
  97131. * @param query defines the query to check
  97132. * @returns true if the query got its value
  97133. */
  97134. isQueryResultAvailable(query: WebGLQuery): boolean;
  97135. /**
  97136. * Gets the value of a given query
  97137. * @param query defines the query to check
  97138. * @returns the value of the query
  97139. */
  97140. getQueryResult(query: WebGLQuery): number;
  97141. /**
  97142. * Initiates an occlusion query
  97143. * @param algorithmType defines the algorithm to use
  97144. * @param query defines the query to use
  97145. * @returns the current engine
  97146. * @see http://doc.babylonjs.com/features/occlusionquery
  97147. */
  97148. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97149. /**
  97150. * Ends an occlusion query
  97151. * @see http://doc.babylonjs.com/features/occlusionquery
  97152. * @param algorithmType defines the algorithm to use
  97153. * @returns the current engine
  97154. */
  97155. endOcclusionQuery(algorithmType: number): Engine;
  97156. /**
  97157. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97158. * Please note that only one query can be issued at a time
  97159. * @returns a time token used to track the time span
  97160. */
  97161. startTimeQuery(): Nullable<_TimeToken>;
  97162. /**
  97163. * Ends a time query
  97164. * @param token defines the token used to measure the time span
  97165. * @returns the time spent (in ns)
  97166. */
  97167. endTimeQuery(token: _TimeToken): int;
  97168. /** @hidden */
  97169. _currentNonTimestampToken: Nullable<_TimeToken>;
  97170. /** @hidden */
  97171. _createTimeQuery(): WebGLQuery;
  97172. /** @hidden */
  97173. _deleteTimeQuery(query: WebGLQuery): void;
  97174. /** @hidden */
  97175. _getGlAlgorithmType(algorithmType: number): number;
  97176. /** @hidden */
  97177. _getTimeQueryResult(query: WebGLQuery): any;
  97178. /** @hidden */
  97179. _getTimeQueryAvailability(query: WebGLQuery): any;
  97180. }
  97181. interface AbstractMesh {
  97182. /**
  97183. * Backing filed
  97184. * @hidden
  97185. */
  97186. __occlusionDataStorage: _OcclusionDataStorage;
  97187. /**
  97188. * Access property
  97189. * @hidden
  97190. */
  97191. _occlusionDataStorage: _OcclusionDataStorage;
  97192. /**
  97193. * 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.
  97194. * The default value is -1 which means don't break the query and wait till the result
  97195. * @see http://doc.babylonjs.com/features/occlusionquery
  97196. */
  97197. occlusionRetryCount: number;
  97198. /**
  97199. * 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:
  97200. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97201. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97202. * * 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.
  97203. * @see http://doc.babylonjs.com/features/occlusionquery
  97204. */
  97205. occlusionType: number;
  97206. /**
  97207. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97208. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97209. * * 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.
  97210. * @see http://doc.babylonjs.com/features/occlusionquery
  97211. */
  97212. occlusionQueryAlgorithmType: number;
  97213. /**
  97214. * 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
  97215. * @see http://doc.babylonjs.com/features/occlusionquery
  97216. */
  97217. isOccluded: boolean;
  97218. /**
  97219. * Flag to check the progress status of the query
  97220. * @see http://doc.babylonjs.com/features/occlusionquery
  97221. */
  97222. isOcclusionQueryInProgress: boolean;
  97223. }
  97224. }
  97225. declare module BABYLON {
  97226. /** @hidden */
  97227. export var _forceTransformFeedbackToBundle: boolean;
  97228. interface Engine {
  97229. /**
  97230. * Creates a webGL transform feedback object
  97231. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  97232. * @returns the webGL transform feedback object
  97233. */
  97234. createTransformFeedback(): WebGLTransformFeedback;
  97235. /**
  97236. * Delete a webGL transform feedback object
  97237. * @param value defines the webGL transform feedback object to delete
  97238. */
  97239. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  97240. /**
  97241. * Bind a webGL transform feedback object to the webgl context
  97242. * @param value defines the webGL transform feedback object to bind
  97243. */
  97244. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  97245. /**
  97246. * Begins a transform feedback operation
  97247. * @param usePoints defines if points or triangles must be used
  97248. */
  97249. beginTransformFeedback(usePoints: boolean): void;
  97250. /**
  97251. * Ends a transform feedback operation
  97252. */
  97253. endTransformFeedback(): void;
  97254. /**
  97255. * Specify the varyings to use with transform feedback
  97256. * @param program defines the associated webGL program
  97257. * @param value defines the list of strings representing the varying names
  97258. */
  97259. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  97260. /**
  97261. * Bind a webGL buffer for a transform feedback operation
  97262. * @param value defines the webGL buffer to bind
  97263. */
  97264. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  97265. }
  97266. }
  97267. declare module BABYLON {
  97268. /**
  97269. * Gather the list of clipboard event types as constants.
  97270. */
  97271. export class ClipboardEventTypes {
  97272. /**
  97273. * The clipboard event is fired when a copy command is active (pressed).
  97274. */
  97275. static readonly COPY: number;
  97276. /**
  97277. * The clipboard event is fired when a cut command is active (pressed).
  97278. */
  97279. static readonly CUT: number;
  97280. /**
  97281. * The clipboard event is fired when a paste command is active (pressed).
  97282. */
  97283. static readonly PASTE: number;
  97284. }
  97285. /**
  97286. * This class is used to store clipboard related info for the onClipboardObservable event.
  97287. */
  97288. export class ClipboardInfo {
  97289. /**
  97290. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97291. */
  97292. type: number;
  97293. /**
  97294. * Defines the related dom event
  97295. */
  97296. event: ClipboardEvent;
  97297. /**
  97298. *Creates an instance of ClipboardInfo.
  97299. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  97300. * @param event Defines the related dom event
  97301. */
  97302. constructor(
  97303. /**
  97304. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97305. */
  97306. type: number,
  97307. /**
  97308. * Defines the related dom event
  97309. */
  97310. event: ClipboardEvent);
  97311. /**
  97312. * Get the clipboard event's type from the keycode.
  97313. * @param keyCode Defines the keyCode for the current keyboard event.
  97314. * @return {number}
  97315. */
  97316. static GetTypeFromCharacter(keyCode: number): number;
  97317. }
  97318. }
  97319. declare module BABYLON {
  97320. /**
  97321. * Class used to represent data loading progression
  97322. */
  97323. export class SceneLoaderProgressEvent {
  97324. /** defines if data length to load can be evaluated */
  97325. readonly lengthComputable: boolean;
  97326. /** defines the loaded data length */
  97327. readonly loaded: number;
  97328. /** defines the data length to load */
  97329. readonly total: number;
  97330. /**
  97331. * Create a new progress event
  97332. * @param lengthComputable defines if data length to load can be evaluated
  97333. * @param loaded defines the loaded data length
  97334. * @param total defines the data length to load
  97335. */
  97336. constructor(
  97337. /** defines if data length to load can be evaluated */
  97338. lengthComputable: boolean,
  97339. /** defines the loaded data length */
  97340. loaded: number,
  97341. /** defines the data length to load */
  97342. total: number);
  97343. /**
  97344. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  97345. * @param event defines the source event
  97346. * @returns a new SceneLoaderProgressEvent
  97347. */
  97348. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  97349. }
  97350. /**
  97351. * Interface used by SceneLoader plugins to define supported file extensions
  97352. */
  97353. export interface ISceneLoaderPluginExtensions {
  97354. /**
  97355. * Defines the list of supported extensions
  97356. */
  97357. [extension: string]: {
  97358. isBinary: boolean;
  97359. };
  97360. }
  97361. /**
  97362. * Interface used by SceneLoader plugin factory
  97363. */
  97364. export interface ISceneLoaderPluginFactory {
  97365. /**
  97366. * Defines the name of the factory
  97367. */
  97368. name: string;
  97369. /**
  97370. * Function called to create a new plugin
  97371. * @return the new plugin
  97372. */
  97373. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  97374. /**
  97375. * Boolean indicating if the plugin can direct load specific data
  97376. */
  97377. canDirectLoad?: (data: string) => boolean;
  97378. }
  97379. /**
  97380. * Interface used to define a SceneLoader plugin
  97381. */
  97382. export interface ISceneLoaderPlugin {
  97383. /**
  97384. * The friendly name of this plugin.
  97385. */
  97386. name: string;
  97387. /**
  97388. * The file extensions supported by this plugin.
  97389. */
  97390. extensions: string | ISceneLoaderPluginExtensions;
  97391. /**
  97392. * Import meshes into a scene.
  97393. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97394. * @param scene The scene to import into
  97395. * @param data The data to import
  97396. * @param rootUrl The root url for scene and resources
  97397. * @param meshes The meshes array to import into
  97398. * @param particleSystems The particle systems array to import into
  97399. * @param skeletons The skeletons array to import into
  97400. * @param onError The callback when import fails
  97401. * @returns True if successful or false otherwise
  97402. */
  97403. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  97404. /**
  97405. * Load into a scene.
  97406. * @param scene The scene to load into
  97407. * @param data The data to import
  97408. * @param rootUrl The root url for scene and resources
  97409. * @param onError The callback when import fails
  97410. * @returns true if successful or false otherwise
  97411. */
  97412. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  97413. /**
  97414. * The callback that returns true if the data can be directly loaded.
  97415. */
  97416. canDirectLoad?: (data: string) => boolean;
  97417. /**
  97418. * The callback that allows custom handling of the root url based on the response url.
  97419. */
  97420. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97421. /**
  97422. * Load into an asset container.
  97423. * @param scene The scene to load into
  97424. * @param data The data to import
  97425. * @param rootUrl The root url for scene and resources
  97426. * @param onError The callback when import fails
  97427. * @returns The loaded asset container
  97428. */
  97429. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  97430. }
  97431. /**
  97432. * Interface used to define an async SceneLoader plugin
  97433. */
  97434. export interface ISceneLoaderPluginAsync {
  97435. /**
  97436. * The friendly name of this plugin.
  97437. */
  97438. name: string;
  97439. /**
  97440. * The file extensions supported by this plugin.
  97441. */
  97442. extensions: string | ISceneLoaderPluginExtensions;
  97443. /**
  97444. * Import meshes into a scene.
  97445. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97446. * @param scene The scene to import into
  97447. * @param data The data to import
  97448. * @param rootUrl The root url for scene and resources
  97449. * @param onProgress The callback when the load progresses
  97450. * @param fileName Defines the name of the file to load
  97451. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  97452. */
  97453. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  97454. meshes: AbstractMesh[];
  97455. particleSystems: IParticleSystem[];
  97456. skeletons: Skeleton[];
  97457. animationGroups: AnimationGroup[];
  97458. }>;
  97459. /**
  97460. * Load into a scene.
  97461. * @param scene The scene to load into
  97462. * @param data The data to import
  97463. * @param rootUrl The root url for scene and resources
  97464. * @param onProgress The callback when the load progresses
  97465. * @param fileName Defines the name of the file to load
  97466. * @returns Nothing
  97467. */
  97468. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  97469. /**
  97470. * The callback that returns true if the data can be directly loaded.
  97471. */
  97472. canDirectLoad?: (data: string) => boolean;
  97473. /**
  97474. * The callback that allows custom handling of the root url based on the response url.
  97475. */
  97476. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97477. /**
  97478. * Load into an asset container.
  97479. * @param scene The scene to load into
  97480. * @param data The data to import
  97481. * @param rootUrl The root url for scene and resources
  97482. * @param onProgress The callback when the load progresses
  97483. * @param fileName Defines the name of the file to load
  97484. * @returns The loaded asset container
  97485. */
  97486. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  97487. }
  97488. /**
  97489. * Class used to load scene from various file formats using registered plugins
  97490. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  97491. */
  97492. export class SceneLoader {
  97493. /**
  97494. * No logging while loading
  97495. */
  97496. static readonly NO_LOGGING: number;
  97497. /**
  97498. * Minimal logging while loading
  97499. */
  97500. static readonly MINIMAL_LOGGING: number;
  97501. /**
  97502. * Summary logging while loading
  97503. */
  97504. static readonly SUMMARY_LOGGING: number;
  97505. /**
  97506. * Detailled logging while loading
  97507. */
  97508. static readonly DETAILED_LOGGING: number;
  97509. /**
  97510. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97511. */
  97512. static ForceFullSceneLoadingForIncremental: boolean;
  97513. /**
  97514. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97515. */
  97516. static ShowLoadingScreen: boolean;
  97517. /**
  97518. * Defines the current logging level (while loading the scene)
  97519. * @ignorenaming
  97520. */
  97521. static loggingLevel: number;
  97522. /**
  97523. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97524. */
  97525. static CleanBoneMatrixWeights: boolean;
  97526. /**
  97527. * Event raised when a plugin is used to load a scene
  97528. */
  97529. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97530. private static _registeredPlugins;
  97531. private static _getDefaultPlugin;
  97532. private static _getPluginForExtension;
  97533. private static _getPluginForDirectLoad;
  97534. private static _getPluginForFilename;
  97535. private static _getDirectLoad;
  97536. private static _loadData;
  97537. private static _getFileInfo;
  97538. /**
  97539. * Gets a plugin that can load the given extension
  97540. * @param extension defines the extension to load
  97541. * @returns a plugin or null if none works
  97542. */
  97543. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97544. /**
  97545. * Gets a boolean indicating that the given extension can be loaded
  97546. * @param extension defines the extension to load
  97547. * @returns true if the extension is supported
  97548. */
  97549. static IsPluginForExtensionAvailable(extension: string): boolean;
  97550. /**
  97551. * Adds a new plugin to the list of registered plugins
  97552. * @param plugin defines the plugin to add
  97553. */
  97554. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97555. /**
  97556. * Import meshes into a scene
  97557. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97558. * @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)
  97559. * @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)
  97560. * @param scene the instance of BABYLON.Scene to append to
  97561. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97562. * @param onProgress a callback with a progress event for each file being loaded
  97563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97564. * @param pluginExtension the extension used to determine the plugin
  97565. * @returns The loaded plugin
  97566. */
  97567. 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>;
  97568. /**
  97569. * Import meshes into a scene
  97570. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97571. * @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)
  97572. * @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)
  97573. * @param scene the instance of BABYLON.Scene to append to
  97574. * @param onProgress a callback with a progress event for each file being loaded
  97575. * @param pluginExtension the extension used to determine the plugin
  97576. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97577. */
  97578. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97579. meshes: AbstractMesh[];
  97580. particleSystems: IParticleSystem[];
  97581. skeletons: Skeleton[];
  97582. animationGroups: AnimationGroup[];
  97583. }>;
  97584. /**
  97585. * Load a scene
  97586. * @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)
  97587. * @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)
  97588. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97589. * @param onSuccess a callback with the scene when import succeeds
  97590. * @param onProgress a callback with a progress event for each file being loaded
  97591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97592. * @param pluginExtension the extension used to determine the plugin
  97593. * @returns The loaded plugin
  97594. */
  97595. 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>;
  97596. /**
  97597. * Load a scene
  97598. * @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)
  97599. * @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)
  97600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97601. * @param onProgress a callback with a progress event for each file being loaded
  97602. * @param pluginExtension the extension used to determine the plugin
  97603. * @returns The loaded scene
  97604. */
  97605. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97606. /**
  97607. * Append a scene
  97608. * @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)
  97609. * @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)
  97610. * @param scene is the instance of BABYLON.Scene to append to
  97611. * @param onSuccess a callback with the scene when import succeeds
  97612. * @param onProgress a callback with a progress event for each file being loaded
  97613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97614. * @param pluginExtension the extension used to determine the plugin
  97615. * @returns The loaded plugin
  97616. */
  97617. 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>;
  97618. /**
  97619. * Append a scene
  97620. * @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)
  97621. * @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)
  97622. * @param scene is the instance of BABYLON.Scene to append to
  97623. * @param onProgress a callback with a progress event for each file being loaded
  97624. * @param pluginExtension the extension used to determine the plugin
  97625. * @returns The given scene
  97626. */
  97627. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97628. /**
  97629. * Load a scene into an asset container
  97630. * @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)
  97631. * @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)
  97632. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97633. * @param onSuccess a callback with the scene when import succeeds
  97634. * @param onProgress a callback with a progress event for each file being loaded
  97635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97636. * @param pluginExtension the extension used to determine the plugin
  97637. * @returns The loaded plugin
  97638. */
  97639. 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>;
  97640. /**
  97641. * Load a scene into an asset container
  97642. * @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)
  97643. * @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)
  97644. * @param scene is the instance of Scene to append to
  97645. * @param onProgress a callback with a progress event for each file being loaded
  97646. * @param pluginExtension the extension used to determine the plugin
  97647. * @returns The loaded asset container
  97648. */
  97649. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97650. }
  97651. }
  97652. declare module BABYLON {
  97653. /**
  97654. * Google Daydream controller
  97655. */
  97656. export class DaydreamController extends WebVRController {
  97657. /**
  97658. * Base Url for the controller model.
  97659. */
  97660. static MODEL_BASE_URL: string;
  97661. /**
  97662. * File name for the controller model.
  97663. */
  97664. static MODEL_FILENAME: string;
  97665. /**
  97666. * Gamepad Id prefix used to identify Daydream Controller.
  97667. */
  97668. static readonly GAMEPAD_ID_PREFIX: string;
  97669. /**
  97670. * Creates a new DaydreamController from a gamepad
  97671. * @param vrGamepad the gamepad that the controller should be created from
  97672. */
  97673. constructor(vrGamepad: any);
  97674. /**
  97675. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97676. * @param scene scene in which to add meshes
  97677. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97678. */
  97679. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97680. /**
  97681. * Called once for each button that changed state since the last frame
  97682. * @param buttonIdx Which button index changed
  97683. * @param state New state of the button
  97684. * @param changes Which properties on the state changed since last frame
  97685. */
  97686. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97687. }
  97688. }
  97689. declare module BABYLON {
  97690. /**
  97691. * Gear VR Controller
  97692. */
  97693. export class GearVRController extends WebVRController {
  97694. /**
  97695. * Base Url for the controller model.
  97696. */
  97697. static MODEL_BASE_URL: string;
  97698. /**
  97699. * File name for the controller model.
  97700. */
  97701. static MODEL_FILENAME: string;
  97702. /**
  97703. * Gamepad Id prefix used to identify this controller.
  97704. */
  97705. static readonly GAMEPAD_ID_PREFIX: string;
  97706. private readonly _buttonIndexToObservableNameMap;
  97707. /**
  97708. * Creates a new GearVRController from a gamepad
  97709. * @param vrGamepad the gamepad that the controller should be created from
  97710. */
  97711. constructor(vrGamepad: any);
  97712. /**
  97713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97714. * @param scene scene in which to add meshes
  97715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97716. */
  97717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97718. /**
  97719. * Called once for each button that changed state since the last frame
  97720. * @param buttonIdx Which button index changed
  97721. * @param state New state of the button
  97722. * @param changes Which properties on the state changed since last frame
  97723. */
  97724. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97725. }
  97726. }
  97727. declare module BABYLON {
  97728. /**
  97729. * Generic Controller
  97730. */
  97731. export class GenericController extends WebVRController {
  97732. /**
  97733. * Base Url for the controller model.
  97734. */
  97735. static readonly MODEL_BASE_URL: string;
  97736. /**
  97737. * File name for the controller model.
  97738. */
  97739. static readonly MODEL_FILENAME: string;
  97740. /**
  97741. * Creates a new GenericController from a gamepad
  97742. * @param vrGamepad the gamepad that the controller should be created from
  97743. */
  97744. constructor(vrGamepad: any);
  97745. /**
  97746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97747. * @param scene scene in which to add meshes
  97748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97749. */
  97750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97751. /**
  97752. * Called once for each button that changed state since the last frame
  97753. * @param buttonIdx Which button index changed
  97754. * @param state New state of the button
  97755. * @param changes Which properties on the state changed since last frame
  97756. */
  97757. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97758. }
  97759. }
  97760. declare module BABYLON {
  97761. /**
  97762. * Oculus Touch Controller
  97763. */
  97764. export class OculusTouchController extends WebVRController {
  97765. /**
  97766. * Base Url for the controller model.
  97767. */
  97768. static MODEL_BASE_URL: string;
  97769. /**
  97770. * File name for the left controller model.
  97771. */
  97772. static MODEL_LEFT_FILENAME: string;
  97773. /**
  97774. * File name for the right controller model.
  97775. */
  97776. static MODEL_RIGHT_FILENAME: string;
  97777. /**
  97778. * Fired when the secondary trigger on this controller is modified
  97779. */
  97780. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97781. /**
  97782. * Fired when the thumb rest on this controller is modified
  97783. */
  97784. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97785. /**
  97786. * Creates a new OculusTouchController from a gamepad
  97787. * @param vrGamepad the gamepad that the controller should be created from
  97788. */
  97789. constructor(vrGamepad: any);
  97790. /**
  97791. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97792. * @param scene scene in which to add meshes
  97793. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97794. */
  97795. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97796. /**
  97797. * Fired when the A button on this controller is modified
  97798. */
  97799. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97800. /**
  97801. * Fired when the B button on this controller is modified
  97802. */
  97803. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97804. /**
  97805. * Fired when the X button on this controller is modified
  97806. */
  97807. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97808. /**
  97809. * Fired when the Y button on this controller is modified
  97810. */
  97811. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97812. /**
  97813. * Called once for each button that changed state since the last frame
  97814. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97815. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97816. * 2) secondary trigger (same)
  97817. * 3) A (right) X (left), touch, pressed = value
  97818. * 4) B / Y
  97819. * 5) thumb rest
  97820. * @param buttonIdx Which button index changed
  97821. * @param state New state of the button
  97822. * @param changes Which properties on the state changed since last frame
  97823. */
  97824. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97825. }
  97826. }
  97827. declare module BABYLON {
  97828. /**
  97829. * Vive Controller
  97830. */
  97831. export class ViveController extends WebVRController {
  97832. /**
  97833. * Base Url for the controller model.
  97834. */
  97835. static MODEL_BASE_URL: string;
  97836. /**
  97837. * File name for the controller model.
  97838. */
  97839. static MODEL_FILENAME: string;
  97840. /**
  97841. * Creates a new ViveController from a gamepad
  97842. * @param vrGamepad the gamepad that the controller should be created from
  97843. */
  97844. constructor(vrGamepad: any);
  97845. /**
  97846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97847. * @param scene scene in which to add meshes
  97848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97849. */
  97850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97851. /**
  97852. * Fired when the left button on this controller is modified
  97853. */
  97854. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97855. /**
  97856. * Fired when the right button on this controller is modified
  97857. */
  97858. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97859. /**
  97860. * Fired when the menu button on this controller is modified
  97861. */
  97862. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97863. /**
  97864. * Called once for each button that changed state since the last frame
  97865. * Vive mapping:
  97866. * 0: touchpad
  97867. * 1: trigger
  97868. * 2: left AND right buttons
  97869. * 3: menu button
  97870. * @param buttonIdx Which button index changed
  97871. * @param state New state of the button
  97872. * @param changes Which properties on the state changed since last frame
  97873. */
  97874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97875. }
  97876. }
  97877. declare module BABYLON {
  97878. /**
  97879. * Defines the WindowsMotionController object that the state of the windows motion controller
  97880. */
  97881. export class WindowsMotionController extends WebVRController {
  97882. /**
  97883. * The base url used to load the left and right controller models
  97884. */
  97885. static MODEL_BASE_URL: string;
  97886. /**
  97887. * The name of the left controller model file
  97888. */
  97889. static MODEL_LEFT_FILENAME: string;
  97890. /**
  97891. * The name of the right controller model file
  97892. */
  97893. static MODEL_RIGHT_FILENAME: string;
  97894. /**
  97895. * The controller name prefix for this controller type
  97896. */
  97897. static readonly GAMEPAD_ID_PREFIX: string;
  97898. /**
  97899. * The controller id pattern for this controller type
  97900. */
  97901. private static readonly GAMEPAD_ID_PATTERN;
  97902. private _loadedMeshInfo;
  97903. private readonly _mapping;
  97904. /**
  97905. * Fired when the trackpad on this controller is clicked
  97906. */
  97907. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97908. /**
  97909. * Fired when the trackpad on this controller is modified
  97910. */
  97911. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97912. /**
  97913. * The current x and y values of this controller's trackpad
  97914. */
  97915. trackpad: StickValues;
  97916. /**
  97917. * Creates a new WindowsMotionController from a gamepad
  97918. * @param vrGamepad the gamepad that the controller should be created from
  97919. */
  97920. constructor(vrGamepad: any);
  97921. /**
  97922. * Fired when the trigger on this controller is modified
  97923. */
  97924. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97925. /**
  97926. * Fired when the menu button on this controller is modified
  97927. */
  97928. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97929. /**
  97930. * Fired when the grip button on this controller is modified
  97931. */
  97932. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97933. /**
  97934. * Fired when the thumbstick button on this controller is modified
  97935. */
  97936. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97937. /**
  97938. * Fired when the touchpad button on this controller is modified
  97939. */
  97940. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97941. /**
  97942. * Fired when the touchpad values on this controller are modified
  97943. */
  97944. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97945. private _updateTrackpad;
  97946. /**
  97947. * Called once per frame by the engine.
  97948. */
  97949. update(): void;
  97950. /**
  97951. * Called once for each button that changed state since the last frame
  97952. * @param buttonIdx Which button index changed
  97953. * @param state New state of the button
  97954. * @param changes Which properties on the state changed since last frame
  97955. */
  97956. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97957. /**
  97958. * Moves the buttons on the controller mesh based on their current state
  97959. * @param buttonName the name of the button to move
  97960. * @param buttonValue the value of the button which determines the buttons new position
  97961. */
  97962. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97963. /**
  97964. * Moves the axis on the controller mesh based on its current state
  97965. * @param axis the index of the axis
  97966. * @param axisValue the value of the axis which determines the meshes new position
  97967. * @hidden
  97968. */
  97969. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97970. /**
  97971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97972. * @param scene scene in which to add meshes
  97973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97974. */
  97975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97976. /**
  97977. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97978. * can be transformed by button presses and axes values, based on this._mapping.
  97979. *
  97980. * @param scene scene in which the meshes exist
  97981. * @param meshes list of meshes that make up the controller model to process
  97982. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97983. */
  97984. private processModel;
  97985. private createMeshInfo;
  97986. /**
  97987. * Gets the ray of the controller in the direction the controller is pointing
  97988. * @param length the length the resulting ray should be
  97989. * @returns a ray in the direction the controller is pointing
  97990. */
  97991. getForwardRay(length?: number): Ray;
  97992. /**
  97993. * Disposes of the controller
  97994. */
  97995. dispose(): void;
  97996. }
  97997. }
  97998. declare module BABYLON {
  97999. /**
  98000. * Single axis scale gizmo
  98001. */
  98002. export class AxisScaleGizmo extends Gizmo {
  98003. private _coloredMaterial;
  98004. /**
  98005. * Drag behavior responsible for the gizmos dragging interactions
  98006. */
  98007. dragBehavior: PointerDragBehavior;
  98008. private _pointerObserver;
  98009. /**
  98010. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98011. */
  98012. snapDistance: number;
  98013. /**
  98014. * Event that fires each time the gizmo snaps to a new location.
  98015. * * snapDistance is the the change in distance
  98016. */
  98017. onSnapObservable: Observable<{
  98018. snapDistance: number;
  98019. }>;
  98020. /**
  98021. * If the scaling operation should be done on all axis (default: false)
  98022. */
  98023. uniformScaling: boolean;
  98024. /**
  98025. * Creates an AxisScaleGizmo
  98026. * @param gizmoLayer The utility layer the gizmo will be added to
  98027. * @param dragAxis The axis which the gizmo will be able to scale on
  98028. * @param color The color of the gizmo
  98029. */
  98030. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98031. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98032. /**
  98033. * Disposes of the gizmo
  98034. */
  98035. dispose(): void;
  98036. /**
  98037. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98038. * @param mesh The mesh to replace the default mesh of the gizmo
  98039. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98040. */
  98041. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98042. }
  98043. }
  98044. declare module BABYLON {
  98045. /**
  98046. * Bounding box gizmo
  98047. */
  98048. export class BoundingBoxGizmo extends Gizmo {
  98049. private _lineBoundingBox;
  98050. private _rotateSpheresParent;
  98051. private _scaleBoxesParent;
  98052. private _boundingDimensions;
  98053. private _renderObserver;
  98054. private _pointerObserver;
  98055. private _scaleDragSpeed;
  98056. private _tmpQuaternion;
  98057. private _tmpVector;
  98058. private _tmpRotationMatrix;
  98059. /**
  98060. * 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)
  98061. */
  98062. ignoreChildren: boolean;
  98063. /**
  98064. * 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)
  98065. */
  98066. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98067. /**
  98068. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98069. */
  98070. rotationSphereSize: number;
  98071. /**
  98072. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98073. */
  98074. scaleBoxSize: number;
  98075. /**
  98076. * 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)
  98077. */
  98078. fixedDragMeshScreenSize: boolean;
  98079. /**
  98080. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98081. */
  98082. fixedDragMeshScreenSizeDistanceFactor: number;
  98083. /**
  98084. * Fired when a rotation sphere or scale box is dragged
  98085. */
  98086. onDragStartObservable: Observable<{}>;
  98087. /**
  98088. * Fired when a scale box is dragged
  98089. */
  98090. onScaleBoxDragObservable: Observable<{}>;
  98091. /**
  98092. * Fired when a scale box drag is ended
  98093. */
  98094. onScaleBoxDragEndObservable: Observable<{}>;
  98095. /**
  98096. * Fired when a rotation sphere is dragged
  98097. */
  98098. onRotationSphereDragObservable: Observable<{}>;
  98099. /**
  98100. * Fired when a rotation sphere drag is ended
  98101. */
  98102. onRotationSphereDragEndObservable: Observable<{}>;
  98103. /**
  98104. * 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)
  98105. */
  98106. scalePivot: Nullable<Vector3>;
  98107. private _anchorMesh;
  98108. private _existingMeshScale;
  98109. private _dragMesh;
  98110. private pointerDragBehavior;
  98111. private coloredMaterial;
  98112. private hoverColoredMaterial;
  98113. /**
  98114. * Sets the color of the bounding box gizmo
  98115. * @param color the color to set
  98116. */
  98117. setColor(color: Color3): void;
  98118. /**
  98119. * Creates an BoundingBoxGizmo
  98120. * @param gizmoLayer The utility layer the gizmo will be added to
  98121. * @param color The color of the gizmo
  98122. */
  98123. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98125. private _selectNode;
  98126. /**
  98127. * Updates the bounding box information for the Gizmo
  98128. */
  98129. updateBoundingBox(): void;
  98130. private _updateRotationSpheres;
  98131. private _updateScaleBoxes;
  98132. /**
  98133. * Enables rotation on the specified axis and disables rotation on the others
  98134. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98135. */
  98136. setEnabledRotationAxis(axis: string): void;
  98137. /**
  98138. * Enables/disables scaling
  98139. * @param enable if scaling should be enabled
  98140. */
  98141. setEnabledScaling(enable: boolean): void;
  98142. private _updateDummy;
  98143. /**
  98144. * Enables a pointer drag behavior on the bounding box of the gizmo
  98145. */
  98146. enableDragBehavior(): void;
  98147. /**
  98148. * Disposes of the gizmo
  98149. */
  98150. dispose(): void;
  98151. /**
  98152. * 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)
  98153. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98154. * @returns the bounding box mesh with the passed in mesh as a child
  98155. */
  98156. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98157. /**
  98158. * CustomMeshes are not supported by this gizmo
  98159. * @param mesh The mesh to replace the default mesh of the gizmo
  98160. */
  98161. setCustomMesh(mesh: Mesh): void;
  98162. }
  98163. }
  98164. declare module BABYLON {
  98165. /**
  98166. * Single plane rotation gizmo
  98167. */
  98168. export class PlaneRotationGizmo extends Gizmo {
  98169. /**
  98170. * Drag behavior responsible for the gizmos dragging interactions
  98171. */
  98172. dragBehavior: PointerDragBehavior;
  98173. private _pointerObserver;
  98174. /**
  98175. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98176. */
  98177. snapDistance: number;
  98178. /**
  98179. * Event that fires each time the gizmo snaps to a new location.
  98180. * * snapDistance is the the change in distance
  98181. */
  98182. onSnapObservable: Observable<{
  98183. snapDistance: number;
  98184. }>;
  98185. /**
  98186. * Creates a PlaneRotationGizmo
  98187. * @param gizmoLayer The utility layer the gizmo will be added to
  98188. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98189. * @param color The color of the gizmo
  98190. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98191. */
  98192. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98193. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98194. /**
  98195. * Disposes of the gizmo
  98196. */
  98197. dispose(): void;
  98198. }
  98199. }
  98200. declare module BABYLON {
  98201. /**
  98202. * Gizmo that enables rotating a mesh along 3 axis
  98203. */
  98204. export class RotationGizmo extends Gizmo {
  98205. /**
  98206. * Internal gizmo used for interactions on the x axis
  98207. */
  98208. xGizmo: PlaneRotationGizmo;
  98209. /**
  98210. * Internal gizmo used for interactions on the y axis
  98211. */
  98212. yGizmo: PlaneRotationGizmo;
  98213. /**
  98214. * Internal gizmo used for interactions on the z axis
  98215. */
  98216. zGizmo: PlaneRotationGizmo;
  98217. /** Fires an event when any of it's sub gizmos are dragged */
  98218. onDragStartObservable: Observable<{}>;
  98219. /** Fires an event when any of it's sub gizmos are released from dragging */
  98220. onDragEndObservable: Observable<{}>;
  98221. attachedMesh: Nullable<AbstractMesh>;
  98222. /**
  98223. * Creates a RotationGizmo
  98224. * @param gizmoLayer The utility layer the gizmo will be added to
  98225. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98226. */
  98227. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98228. updateGizmoRotationToMatchAttachedMesh: boolean;
  98229. /**
  98230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98231. */
  98232. snapDistance: number;
  98233. /**
  98234. * Ratio for the scale of the gizmo (Default: 1)
  98235. */
  98236. scaleRatio: number;
  98237. /**
  98238. * Disposes of the gizmo
  98239. */
  98240. dispose(): void;
  98241. /**
  98242. * CustomMeshes are not supported by this gizmo
  98243. * @param mesh The mesh to replace the default mesh of the gizmo
  98244. */
  98245. setCustomMesh(mesh: Mesh): void;
  98246. }
  98247. }
  98248. declare module BABYLON {
  98249. /**
  98250. * Gizmo that enables dragging a mesh along 3 axis
  98251. */
  98252. export class PositionGizmo extends Gizmo {
  98253. /**
  98254. * Internal gizmo used for interactions on the x axis
  98255. */
  98256. xGizmo: AxisDragGizmo;
  98257. /**
  98258. * Internal gizmo used for interactions on the y axis
  98259. */
  98260. yGizmo: AxisDragGizmo;
  98261. /**
  98262. * Internal gizmo used for interactions on the z axis
  98263. */
  98264. zGizmo: AxisDragGizmo;
  98265. /** Fires an event when any of it's sub gizmos are dragged */
  98266. onDragStartObservable: Observable<{}>;
  98267. /** Fires an event when any of it's sub gizmos are released from dragging */
  98268. onDragEndObservable: Observable<{}>;
  98269. attachedMesh: Nullable<AbstractMesh>;
  98270. /**
  98271. * Creates a PositionGizmo
  98272. * @param gizmoLayer The utility layer the gizmo will be added to
  98273. */
  98274. constructor(gizmoLayer?: UtilityLayerRenderer);
  98275. updateGizmoRotationToMatchAttachedMesh: boolean;
  98276. /**
  98277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98278. */
  98279. snapDistance: number;
  98280. /**
  98281. * Ratio for the scale of the gizmo (Default: 1)
  98282. */
  98283. scaleRatio: number;
  98284. /**
  98285. * Disposes of the gizmo
  98286. */
  98287. dispose(): void;
  98288. /**
  98289. * CustomMeshes are not supported by this gizmo
  98290. * @param mesh The mesh to replace the default mesh of the gizmo
  98291. */
  98292. setCustomMesh(mesh: Mesh): void;
  98293. }
  98294. }
  98295. declare module BABYLON {
  98296. /**
  98297. * Class containing static functions to help procedurally build meshes
  98298. */
  98299. export class PolyhedronBuilder {
  98300. /**
  98301. * Creates a polyhedron mesh
  98302. * * 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
  98303. * * The parameter `size` (positive float, default 1) sets the polygon size
  98304. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98305. * * 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`
  98306. * * 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
  98307. * * 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)`)
  98308. * * 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
  98309. * * 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
  98310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98313. * @param name defines the name of the mesh
  98314. * @param options defines the options used to create the mesh
  98315. * @param scene defines the hosting scene
  98316. * @returns the polyhedron mesh
  98317. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  98318. */
  98319. static CreatePolyhedron(name: string, options: {
  98320. type?: number;
  98321. size?: number;
  98322. sizeX?: number;
  98323. sizeY?: number;
  98324. sizeZ?: number;
  98325. custom?: any;
  98326. faceUV?: Vector4[];
  98327. faceColors?: Color4[];
  98328. flat?: boolean;
  98329. updatable?: boolean;
  98330. sideOrientation?: number;
  98331. frontUVs?: Vector4;
  98332. backUVs?: Vector4;
  98333. }, scene: Scene): Mesh;
  98334. }
  98335. }
  98336. declare module BABYLON {
  98337. /**
  98338. * Gizmo that enables scaling a mesh along 3 axis
  98339. */
  98340. export class ScaleGizmo extends Gizmo {
  98341. /**
  98342. * Internal gizmo used for interactions on the x axis
  98343. */
  98344. xGizmo: AxisScaleGizmo;
  98345. /**
  98346. * Internal gizmo used for interactions on the y axis
  98347. */
  98348. yGizmo: AxisScaleGizmo;
  98349. /**
  98350. * Internal gizmo used for interactions on the z axis
  98351. */
  98352. zGizmo: AxisScaleGizmo;
  98353. /**
  98354. * Internal gizmo used to scale all axis equally
  98355. */
  98356. uniformScaleGizmo: AxisScaleGizmo;
  98357. /** Fires an event when any of it's sub gizmos are dragged */
  98358. onDragStartObservable: Observable<{}>;
  98359. /** Fires an event when any of it's sub gizmos are released from dragging */
  98360. onDragEndObservable: Observable<{}>;
  98361. attachedMesh: Nullable<AbstractMesh>;
  98362. /**
  98363. * Creates a ScaleGizmo
  98364. * @param gizmoLayer The utility layer the gizmo will be added to
  98365. */
  98366. constructor(gizmoLayer?: UtilityLayerRenderer);
  98367. updateGizmoRotationToMatchAttachedMesh: boolean;
  98368. /**
  98369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98370. */
  98371. snapDistance: number;
  98372. /**
  98373. * Ratio for the scale of the gizmo (Default: 1)
  98374. */
  98375. scaleRatio: number;
  98376. /**
  98377. * Disposes of the gizmo
  98378. */
  98379. dispose(): void;
  98380. }
  98381. }
  98382. declare module BABYLON {
  98383. /**
  98384. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  98385. */
  98386. export class GizmoManager implements IDisposable {
  98387. private scene;
  98388. /**
  98389. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  98390. */
  98391. gizmos: {
  98392. positionGizmo: Nullable<PositionGizmo>;
  98393. rotationGizmo: Nullable<RotationGizmo>;
  98394. scaleGizmo: Nullable<ScaleGizmo>;
  98395. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  98396. };
  98397. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  98398. clearGizmoOnEmptyPointerEvent: boolean;
  98399. /** Fires an event when the manager is attached to a mesh */
  98400. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  98401. private _gizmosEnabled;
  98402. private _pointerObserver;
  98403. private _attachedMesh;
  98404. private _boundingBoxColor;
  98405. private _defaultUtilityLayer;
  98406. private _defaultKeepDepthUtilityLayer;
  98407. /**
  98408. * When bounding box gizmo is enabled, this can be used to track drag/end events
  98409. */
  98410. boundingBoxDragBehavior: SixDofDragBehavior;
  98411. /**
  98412. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  98413. */
  98414. attachableMeshes: Nullable<Array<AbstractMesh>>;
  98415. /**
  98416. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  98417. */
  98418. usePointerToAttachGizmos: boolean;
  98419. /**
  98420. * Instatiates a gizmo manager
  98421. * @param scene the scene to overlay the gizmos on top of
  98422. */
  98423. constructor(scene: Scene);
  98424. /**
  98425. * Attaches a set of gizmos to the specified mesh
  98426. * @param mesh The mesh the gizmo's should be attached to
  98427. */
  98428. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  98429. /**
  98430. * If the position gizmo is enabled
  98431. */
  98432. positionGizmoEnabled: boolean;
  98433. /**
  98434. * If the rotation gizmo is enabled
  98435. */
  98436. rotationGizmoEnabled: boolean;
  98437. /**
  98438. * If the scale gizmo is enabled
  98439. */
  98440. scaleGizmoEnabled: boolean;
  98441. /**
  98442. * If the boundingBox gizmo is enabled
  98443. */
  98444. boundingBoxGizmoEnabled: boolean;
  98445. /**
  98446. * Disposes of the gizmo manager
  98447. */
  98448. dispose(): void;
  98449. }
  98450. }
  98451. declare module BABYLON {
  98452. /**
  98453. * Gizmo that enables viewing a light
  98454. */
  98455. export class LightGizmo extends Gizmo {
  98456. private _box;
  98457. /**
  98458. * Creates a LightGizmo
  98459. * @param gizmoLayer The utility layer the gizmo will be added to
  98460. */
  98461. constructor(gizmoLayer?: UtilityLayerRenderer);
  98462. private _light;
  98463. /**
  98464. * The light that the gizmo is attached to
  98465. */
  98466. light: Nullable<Light>;
  98467. /**
  98468. * @hidden
  98469. * Updates the gizmo to match the attached mesh's position/rotation
  98470. */
  98471. protected _update(): void;
  98472. }
  98473. }
  98474. declare module BABYLON {
  98475. /** @hidden */
  98476. export var backgroundFragmentDeclaration: {
  98477. name: string;
  98478. shader: string;
  98479. };
  98480. }
  98481. declare module BABYLON {
  98482. /** @hidden */
  98483. export var backgroundUboDeclaration: {
  98484. name: string;
  98485. shader: string;
  98486. };
  98487. }
  98488. declare module BABYLON {
  98489. /** @hidden */
  98490. export var backgroundPixelShader: {
  98491. name: string;
  98492. shader: string;
  98493. };
  98494. }
  98495. declare module BABYLON {
  98496. /** @hidden */
  98497. export var backgroundVertexDeclaration: {
  98498. name: string;
  98499. shader: string;
  98500. };
  98501. }
  98502. declare module BABYLON {
  98503. /** @hidden */
  98504. export var backgroundVertexShader: {
  98505. name: string;
  98506. shader: string;
  98507. };
  98508. }
  98509. declare module BABYLON {
  98510. /**
  98511. * Background material used to create an efficient environement around your scene.
  98512. */
  98513. export class BackgroundMaterial extends PushMaterial {
  98514. /**
  98515. * Standard reflectance value at parallel view angle.
  98516. */
  98517. static StandardReflectance0: number;
  98518. /**
  98519. * Standard reflectance value at grazing angle.
  98520. */
  98521. static StandardReflectance90: number;
  98522. protected _primaryColor: Color3;
  98523. /**
  98524. * Key light Color (multiply against the environement texture)
  98525. */
  98526. primaryColor: Color3;
  98527. protected __perceptualColor: Nullable<Color3>;
  98528. /**
  98529. * Experimental Internal Use Only.
  98530. *
  98531. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98532. * This acts as a helper to set the primary color to a more "human friendly" value.
  98533. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98534. * output color as close as possible from the chosen value.
  98535. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98536. * part of lighting setup.)
  98537. */
  98538. _perceptualColor: Nullable<Color3>;
  98539. protected _primaryColorShadowLevel: float;
  98540. /**
  98541. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98542. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98543. */
  98544. primaryColorShadowLevel: float;
  98545. protected _primaryColorHighlightLevel: float;
  98546. /**
  98547. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98548. * The primary color is used at the level chosen to define what the white area would look.
  98549. */
  98550. primaryColorHighlightLevel: float;
  98551. protected _reflectionTexture: Nullable<BaseTexture>;
  98552. /**
  98553. * Reflection Texture used in the material.
  98554. * Should be author in a specific way for the best result (refer to the documentation).
  98555. */
  98556. reflectionTexture: Nullable<BaseTexture>;
  98557. protected _reflectionBlur: float;
  98558. /**
  98559. * Reflection Texture level of blur.
  98560. *
  98561. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98562. * texture twice.
  98563. */
  98564. reflectionBlur: float;
  98565. protected _diffuseTexture: Nullable<BaseTexture>;
  98566. /**
  98567. * Diffuse Texture used in the material.
  98568. * Should be author in a specific way for the best result (refer to the documentation).
  98569. */
  98570. diffuseTexture: Nullable<BaseTexture>;
  98571. protected _shadowLights: Nullable<IShadowLight[]>;
  98572. /**
  98573. * Specify the list of lights casting shadow on the material.
  98574. * All scene shadow lights will be included if null.
  98575. */
  98576. shadowLights: Nullable<IShadowLight[]>;
  98577. protected _shadowLevel: float;
  98578. /**
  98579. * Helps adjusting the shadow to a softer level if required.
  98580. * 0 means black shadows and 1 means no shadows.
  98581. */
  98582. shadowLevel: float;
  98583. protected _sceneCenter: Vector3;
  98584. /**
  98585. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98586. * It is usually zero but might be interesting to modify according to your setup.
  98587. */
  98588. sceneCenter: Vector3;
  98589. protected _opacityFresnel: boolean;
  98590. /**
  98591. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98592. * This helps ensuring a nice transition when the camera goes under the ground.
  98593. */
  98594. opacityFresnel: boolean;
  98595. protected _reflectionFresnel: boolean;
  98596. /**
  98597. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98598. * This helps adding a mirror texture on the ground.
  98599. */
  98600. reflectionFresnel: boolean;
  98601. protected _reflectionFalloffDistance: number;
  98602. /**
  98603. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98604. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98605. */
  98606. reflectionFalloffDistance: number;
  98607. protected _reflectionAmount: number;
  98608. /**
  98609. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98610. */
  98611. reflectionAmount: number;
  98612. protected _reflectionReflectance0: number;
  98613. /**
  98614. * This specifies the weight of the reflection at grazing angle.
  98615. */
  98616. reflectionReflectance0: number;
  98617. protected _reflectionReflectance90: number;
  98618. /**
  98619. * This specifies the weight of the reflection at a perpendicular point of view.
  98620. */
  98621. reflectionReflectance90: number;
  98622. /**
  98623. * Sets the reflection reflectance fresnel values according to the default standard
  98624. * empirically know to work well :-)
  98625. */
  98626. reflectionStandardFresnelWeight: number;
  98627. protected _useRGBColor: boolean;
  98628. /**
  98629. * Helps to directly use the maps channels instead of their level.
  98630. */
  98631. useRGBColor: boolean;
  98632. protected _enableNoise: boolean;
  98633. /**
  98634. * This helps reducing the banding effect that could occur on the background.
  98635. */
  98636. enableNoise: boolean;
  98637. /**
  98638. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98639. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98640. * Recommended to be keep at 1.0 except for special cases.
  98641. */
  98642. fovMultiplier: number;
  98643. private _fovMultiplier;
  98644. /**
  98645. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98646. */
  98647. useEquirectangularFOV: boolean;
  98648. private _maxSimultaneousLights;
  98649. /**
  98650. * Number of Simultaneous lights allowed on the material.
  98651. */
  98652. maxSimultaneousLights: int;
  98653. /**
  98654. * Default configuration related to image processing available in the Background Material.
  98655. */
  98656. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98657. /**
  98658. * Keep track of the image processing observer to allow dispose and replace.
  98659. */
  98660. private _imageProcessingObserver;
  98661. /**
  98662. * Attaches a new image processing configuration to the PBR Material.
  98663. * @param configuration (if null the scene configuration will be use)
  98664. */
  98665. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98666. /**
  98667. * Gets the image processing configuration used either in this material.
  98668. */
  98669. /**
  98670. * Sets the Default image processing configuration used either in the this material.
  98671. *
  98672. * If sets to null, the scene one is in use.
  98673. */
  98674. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98675. /**
  98676. * Gets wether the color curves effect is enabled.
  98677. */
  98678. /**
  98679. * Sets wether the color curves effect is enabled.
  98680. */
  98681. cameraColorCurvesEnabled: boolean;
  98682. /**
  98683. * Gets wether the color grading effect is enabled.
  98684. */
  98685. /**
  98686. * Gets wether the color grading effect is enabled.
  98687. */
  98688. cameraColorGradingEnabled: boolean;
  98689. /**
  98690. * Gets wether tonemapping is enabled or not.
  98691. */
  98692. /**
  98693. * Sets wether tonemapping is enabled or not
  98694. */
  98695. cameraToneMappingEnabled: boolean;
  98696. /**
  98697. * The camera exposure used on this material.
  98698. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98699. * This corresponds to a photographic exposure.
  98700. */
  98701. /**
  98702. * The camera exposure used on this material.
  98703. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98704. * This corresponds to a photographic exposure.
  98705. */
  98706. cameraExposure: float;
  98707. /**
  98708. * Gets The camera contrast used on this material.
  98709. */
  98710. /**
  98711. * Sets The camera contrast used on this material.
  98712. */
  98713. cameraContrast: float;
  98714. /**
  98715. * Gets the Color Grading 2D Lookup Texture.
  98716. */
  98717. /**
  98718. * Sets the Color Grading 2D Lookup Texture.
  98719. */
  98720. cameraColorGradingTexture: Nullable<BaseTexture>;
  98721. /**
  98722. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98724. * 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;
  98725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98726. */
  98727. /**
  98728. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98729. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98730. * 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;
  98731. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98732. */
  98733. cameraColorCurves: Nullable<ColorCurves>;
  98734. /**
  98735. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98736. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98737. */
  98738. switchToBGR: boolean;
  98739. private _renderTargets;
  98740. private _reflectionControls;
  98741. private _white;
  98742. private _primaryShadowColor;
  98743. private _primaryHighlightColor;
  98744. /**
  98745. * Instantiates a Background Material in the given scene
  98746. * @param name The friendly name of the material
  98747. * @param scene The scene to add the material to
  98748. */
  98749. constructor(name: string, scene: Scene);
  98750. /**
  98751. * Gets a boolean indicating that current material needs to register RTT
  98752. */
  98753. readonly hasRenderTargetTextures: boolean;
  98754. /**
  98755. * The entire material has been created in order to prevent overdraw.
  98756. * @returns false
  98757. */
  98758. needAlphaTesting(): boolean;
  98759. /**
  98760. * The entire material has been created in order to prevent overdraw.
  98761. * @returns true if blending is enable
  98762. */
  98763. needAlphaBlending(): boolean;
  98764. /**
  98765. * Checks wether the material is ready to be rendered for a given mesh.
  98766. * @param mesh The mesh to render
  98767. * @param subMesh The submesh to check against
  98768. * @param useInstances Specify wether or not the material is used with instances
  98769. * @returns true if all the dependencies are ready (Textures, Effects...)
  98770. */
  98771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98772. /**
  98773. * Compute the primary color according to the chosen perceptual color.
  98774. */
  98775. private _computePrimaryColorFromPerceptualColor;
  98776. /**
  98777. * Compute the highlights and shadow colors according to their chosen levels.
  98778. */
  98779. private _computePrimaryColors;
  98780. /**
  98781. * Build the uniform buffer used in the material.
  98782. */
  98783. buildUniformLayout(): void;
  98784. /**
  98785. * Unbind the material.
  98786. */
  98787. unbind(): void;
  98788. /**
  98789. * Bind only the world matrix to the material.
  98790. * @param world The world matrix to bind.
  98791. */
  98792. bindOnlyWorldMatrix(world: Matrix): void;
  98793. /**
  98794. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98795. * @param world The world matrix to bind.
  98796. * @param subMesh The submesh to bind for.
  98797. */
  98798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98799. /**
  98800. * Dispose the material.
  98801. * @param forceDisposeEffect Force disposal of the associated effect.
  98802. * @param forceDisposeTextures Force disposal of the associated textures.
  98803. */
  98804. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98805. /**
  98806. * Clones the material.
  98807. * @param name The cloned name.
  98808. * @returns The cloned material.
  98809. */
  98810. clone(name: string): BackgroundMaterial;
  98811. /**
  98812. * Serializes the current material to its JSON representation.
  98813. * @returns The JSON representation.
  98814. */
  98815. serialize(): any;
  98816. /**
  98817. * Gets the class name of the material
  98818. * @returns "BackgroundMaterial"
  98819. */
  98820. getClassName(): string;
  98821. /**
  98822. * Parse a JSON input to create back a background material.
  98823. * @param source The JSON data to parse
  98824. * @param scene The scene to create the parsed material in
  98825. * @param rootUrl The root url of the assets the material depends upon
  98826. * @returns the instantiated BackgroundMaterial.
  98827. */
  98828. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98829. }
  98830. }
  98831. declare module BABYLON {
  98832. /**
  98833. * Represents the different options available during the creation of
  98834. * a Environment helper.
  98835. *
  98836. * This can control the default ground, skybox and image processing setup of your scene.
  98837. */
  98838. export interface IEnvironmentHelperOptions {
  98839. /**
  98840. * Specifies wether or not to create a ground.
  98841. * True by default.
  98842. */
  98843. createGround: boolean;
  98844. /**
  98845. * Specifies the ground size.
  98846. * 15 by default.
  98847. */
  98848. groundSize: number;
  98849. /**
  98850. * The texture used on the ground for the main color.
  98851. * Comes from the BabylonJS CDN by default.
  98852. *
  98853. * Remarks: Can be either a texture or a url.
  98854. */
  98855. groundTexture: string | BaseTexture;
  98856. /**
  98857. * The color mixed in the ground texture by default.
  98858. * BabylonJS clearColor by default.
  98859. */
  98860. groundColor: Color3;
  98861. /**
  98862. * Specifies the ground opacity.
  98863. * 1 by default.
  98864. */
  98865. groundOpacity: number;
  98866. /**
  98867. * Enables the ground to receive shadows.
  98868. * True by default.
  98869. */
  98870. enableGroundShadow: boolean;
  98871. /**
  98872. * Helps preventing the shadow to be fully black on the ground.
  98873. * 0.5 by default.
  98874. */
  98875. groundShadowLevel: number;
  98876. /**
  98877. * Creates a mirror texture attach to the ground.
  98878. * false by default.
  98879. */
  98880. enableGroundMirror: boolean;
  98881. /**
  98882. * Specifies the ground mirror size ratio.
  98883. * 0.3 by default as the default kernel is 64.
  98884. */
  98885. groundMirrorSizeRatio: number;
  98886. /**
  98887. * Specifies the ground mirror blur kernel size.
  98888. * 64 by default.
  98889. */
  98890. groundMirrorBlurKernel: number;
  98891. /**
  98892. * Specifies the ground mirror visibility amount.
  98893. * 1 by default
  98894. */
  98895. groundMirrorAmount: number;
  98896. /**
  98897. * Specifies the ground mirror reflectance weight.
  98898. * This uses the standard weight of the background material to setup the fresnel effect
  98899. * of the mirror.
  98900. * 1 by default.
  98901. */
  98902. groundMirrorFresnelWeight: number;
  98903. /**
  98904. * Specifies the ground mirror Falloff distance.
  98905. * This can helps reducing the size of the reflection.
  98906. * 0 by Default.
  98907. */
  98908. groundMirrorFallOffDistance: number;
  98909. /**
  98910. * Specifies the ground mirror texture type.
  98911. * Unsigned Int by Default.
  98912. */
  98913. groundMirrorTextureType: number;
  98914. /**
  98915. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98916. * the shown objects.
  98917. */
  98918. groundYBias: number;
  98919. /**
  98920. * Specifies wether or not to create a skybox.
  98921. * True by default.
  98922. */
  98923. createSkybox: boolean;
  98924. /**
  98925. * Specifies the skybox size.
  98926. * 20 by default.
  98927. */
  98928. skyboxSize: number;
  98929. /**
  98930. * The texture used on the skybox for the main color.
  98931. * Comes from the BabylonJS CDN by default.
  98932. *
  98933. * Remarks: Can be either a texture or a url.
  98934. */
  98935. skyboxTexture: string | BaseTexture;
  98936. /**
  98937. * The color mixed in the skybox texture by default.
  98938. * BabylonJS clearColor by default.
  98939. */
  98940. skyboxColor: Color3;
  98941. /**
  98942. * The background rotation around the Y axis of the scene.
  98943. * This helps aligning the key lights of your scene with the background.
  98944. * 0 by default.
  98945. */
  98946. backgroundYRotation: number;
  98947. /**
  98948. * Compute automatically the size of the elements to best fit with the scene.
  98949. */
  98950. sizeAuto: boolean;
  98951. /**
  98952. * Default position of the rootMesh if autoSize is not true.
  98953. */
  98954. rootPosition: Vector3;
  98955. /**
  98956. * Sets up the image processing in the scene.
  98957. * true by default.
  98958. */
  98959. setupImageProcessing: boolean;
  98960. /**
  98961. * The texture used as your environment texture in the scene.
  98962. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98963. *
  98964. * Remarks: Can be either a texture or a url.
  98965. */
  98966. environmentTexture: string | BaseTexture;
  98967. /**
  98968. * The value of the exposure to apply to the scene.
  98969. * 0.6 by default if setupImageProcessing is true.
  98970. */
  98971. cameraExposure: number;
  98972. /**
  98973. * The value of the contrast to apply to the scene.
  98974. * 1.6 by default if setupImageProcessing is true.
  98975. */
  98976. cameraContrast: number;
  98977. /**
  98978. * Specifies wether or not tonemapping should be enabled in the scene.
  98979. * true by default if setupImageProcessing is true.
  98980. */
  98981. toneMappingEnabled: boolean;
  98982. }
  98983. /**
  98984. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98985. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98986. * It also helps with the default setup of your imageProcessing configuration.
  98987. */
  98988. export class EnvironmentHelper {
  98989. /**
  98990. * Default ground texture URL.
  98991. */
  98992. private static _groundTextureCDNUrl;
  98993. /**
  98994. * Default skybox texture URL.
  98995. */
  98996. private static _skyboxTextureCDNUrl;
  98997. /**
  98998. * Default environment texture URL.
  98999. */
  99000. private static _environmentTextureCDNUrl;
  99001. /**
  99002. * Creates the default options for the helper.
  99003. */
  99004. private static _getDefaultOptions;
  99005. private _rootMesh;
  99006. /**
  99007. * Gets the root mesh created by the helper.
  99008. */
  99009. readonly rootMesh: Mesh;
  99010. private _skybox;
  99011. /**
  99012. * Gets the skybox created by the helper.
  99013. */
  99014. readonly skybox: Nullable<Mesh>;
  99015. private _skyboxTexture;
  99016. /**
  99017. * Gets the skybox texture created by the helper.
  99018. */
  99019. readonly skyboxTexture: Nullable<BaseTexture>;
  99020. private _skyboxMaterial;
  99021. /**
  99022. * Gets the skybox material created by the helper.
  99023. */
  99024. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99025. private _ground;
  99026. /**
  99027. * Gets the ground mesh created by the helper.
  99028. */
  99029. readonly ground: Nullable<Mesh>;
  99030. private _groundTexture;
  99031. /**
  99032. * Gets the ground texture created by the helper.
  99033. */
  99034. readonly groundTexture: Nullable<BaseTexture>;
  99035. private _groundMirror;
  99036. /**
  99037. * Gets the ground mirror created by the helper.
  99038. */
  99039. readonly groundMirror: Nullable<MirrorTexture>;
  99040. /**
  99041. * Gets the ground mirror render list to helps pushing the meshes
  99042. * you wish in the ground reflection.
  99043. */
  99044. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99045. private _groundMaterial;
  99046. /**
  99047. * Gets the ground material created by the helper.
  99048. */
  99049. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99050. /**
  99051. * Stores the creation options.
  99052. */
  99053. private readonly _scene;
  99054. private _options;
  99055. /**
  99056. * This observable will be notified with any error during the creation of the environment,
  99057. * mainly texture creation errors.
  99058. */
  99059. onErrorObservable: Observable<{
  99060. message?: string;
  99061. exception?: any;
  99062. }>;
  99063. /**
  99064. * constructor
  99065. * @param options Defines the options we want to customize the helper
  99066. * @param scene The scene to add the material to
  99067. */
  99068. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99069. /**
  99070. * Updates the background according to the new options
  99071. * @param options
  99072. */
  99073. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99074. /**
  99075. * Sets the primary color of all the available elements.
  99076. * @param color the main color to affect to the ground and the background
  99077. */
  99078. setMainColor(color: Color3): void;
  99079. /**
  99080. * Setup the image processing according to the specified options.
  99081. */
  99082. private _setupImageProcessing;
  99083. /**
  99084. * Setup the environment texture according to the specified options.
  99085. */
  99086. private _setupEnvironmentTexture;
  99087. /**
  99088. * Setup the background according to the specified options.
  99089. */
  99090. private _setupBackground;
  99091. /**
  99092. * Get the scene sizes according to the setup.
  99093. */
  99094. private _getSceneSize;
  99095. /**
  99096. * Setup the ground according to the specified options.
  99097. */
  99098. private _setupGround;
  99099. /**
  99100. * Setup the ground material according to the specified options.
  99101. */
  99102. private _setupGroundMaterial;
  99103. /**
  99104. * Setup the ground diffuse texture according to the specified options.
  99105. */
  99106. private _setupGroundDiffuseTexture;
  99107. /**
  99108. * Setup the ground mirror texture according to the specified options.
  99109. */
  99110. private _setupGroundMirrorTexture;
  99111. /**
  99112. * Setup the ground to receive the mirror texture.
  99113. */
  99114. private _setupMirrorInGroundMaterial;
  99115. /**
  99116. * Setup the skybox according to the specified options.
  99117. */
  99118. private _setupSkybox;
  99119. /**
  99120. * Setup the skybox material according to the specified options.
  99121. */
  99122. private _setupSkyboxMaterial;
  99123. /**
  99124. * Setup the skybox reflection texture according to the specified options.
  99125. */
  99126. private _setupSkyboxReflectionTexture;
  99127. private _errorHandler;
  99128. /**
  99129. * Dispose all the elements created by the Helper.
  99130. */
  99131. dispose(): void;
  99132. }
  99133. }
  99134. declare module BABYLON {
  99135. /**
  99136. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99137. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99138. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99139. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99140. */
  99141. export class PhotoDome extends TransformNode {
  99142. private _useDirectMapping;
  99143. /**
  99144. * The texture being displayed on the sphere
  99145. */
  99146. protected _photoTexture: Texture;
  99147. /**
  99148. * Gets or sets the texture being displayed on the sphere
  99149. */
  99150. photoTexture: Texture;
  99151. /**
  99152. * Observable raised when an error occured while loading the 360 image
  99153. */
  99154. onLoadErrorObservable: Observable<string>;
  99155. /**
  99156. * The skybox material
  99157. */
  99158. protected _material: BackgroundMaterial;
  99159. /**
  99160. * The surface used for the skybox
  99161. */
  99162. protected _mesh: Mesh;
  99163. /**
  99164. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99165. * Also see the options.resolution property.
  99166. */
  99167. fovMultiplier: number;
  99168. /**
  99169. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99170. * @param name Element's name, child elements will append suffixes for their own names.
  99171. * @param urlsOfPhoto defines the url of the photo to display
  99172. * @param options defines an object containing optional or exposed sub element properties
  99173. * @param onError defines a callback called when an error occured while loading the texture
  99174. */
  99175. constructor(name: string, urlOfPhoto: string, options: {
  99176. resolution?: number;
  99177. size?: number;
  99178. useDirectMapping?: boolean;
  99179. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99180. /**
  99181. * Releases resources associated with this node.
  99182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99184. */
  99185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99186. }
  99187. }
  99188. declare module BABYLON {
  99189. /**
  99190. * Class used to host texture specific utilities
  99191. */
  99192. export class TextureTools {
  99193. /**
  99194. * Uses the GPU to create a copy texture rescaled at a given size
  99195. * @param texture Texture to copy from
  99196. * @param width defines the desired width
  99197. * @param height defines the desired height
  99198. * @param useBilinearMode defines if bilinear mode has to be used
  99199. * @return the generated texture
  99200. */
  99201. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99202. /**
  99203. * Gets an environment BRDF texture for a given scene
  99204. * @param scene defines the hosting scene
  99205. * @returns the environment BRDF texture
  99206. */
  99207. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99208. private static _environmentBRDFBase64Texture;
  99209. }
  99210. }
  99211. declare module BABYLON {
  99212. /**
  99213. * @hidden
  99214. */
  99215. export interface IMaterialClearCoatDefines {
  99216. CLEARCOAT: boolean;
  99217. CLEARCOAT_DEFAULTIOR: boolean;
  99218. CLEARCOAT_TEXTURE: boolean;
  99219. CLEARCOAT_TEXTUREDIRECTUV: number;
  99220. CLEARCOAT_BUMP: boolean;
  99221. CLEARCOAT_BUMPDIRECTUV: number;
  99222. CLEARCOAT_TINT: boolean;
  99223. CLEARCOAT_TINT_TEXTURE: boolean;
  99224. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  99225. /** @hidden */
  99226. _areTexturesDirty: boolean;
  99227. }
  99228. /**
  99229. * Define the code related to the clear coat parameters of the pbr material.
  99230. */
  99231. export class PBRClearCoatConfiguration {
  99232. /**
  99233. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99234. * The default fits with a polyurethane material.
  99235. */
  99236. private static readonly _DefaultIndiceOfRefraction;
  99237. private _isEnabled;
  99238. /**
  99239. * Defines if the clear coat is enabled in the material.
  99240. */
  99241. isEnabled: boolean;
  99242. /**
  99243. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  99244. */
  99245. intensity: number;
  99246. /**
  99247. * Defines the clear coat layer roughness.
  99248. */
  99249. roughness: number;
  99250. private _indiceOfRefraction;
  99251. /**
  99252. * Defines the indice of refraction of the clear coat.
  99253. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99254. * The default fits with a polyurethane material.
  99255. * Changing the default value is more performance intensive.
  99256. */
  99257. indiceOfRefraction: number;
  99258. private _texture;
  99259. /**
  99260. * Stores the clear coat values in a texture.
  99261. */
  99262. texture: Nullable<BaseTexture>;
  99263. private _bumpTexture;
  99264. /**
  99265. * Define the clear coat specific bump texture.
  99266. */
  99267. bumpTexture: Nullable<BaseTexture>;
  99268. private _isTintEnabled;
  99269. /**
  99270. * Defines if the clear coat tint is enabled in the material.
  99271. */
  99272. isTintEnabled: boolean;
  99273. /**
  99274. * Defines if the clear coat tint is enabled in the material.
  99275. * This is only use if tint is enabled
  99276. */
  99277. tintColor: Color3;
  99278. /**
  99279. * Defines if the distance at which the tint color should be found in the
  99280. * clear coat media.
  99281. * This is only use if tint is enabled
  99282. */
  99283. tintColorAtDistance: number;
  99284. /**
  99285. * Defines the clear coat layer thickness.
  99286. * This is only use if tint is enabled
  99287. */
  99288. tintThickness: number;
  99289. private _tintTexture;
  99290. /**
  99291. * Stores the clear tint values in a texture.
  99292. * rgb is tint
  99293. * a is a thickness factor
  99294. */
  99295. tintTexture: Nullable<BaseTexture>;
  99296. /** @hidden */
  99297. private _internalMarkAllSubMeshesAsTexturesDirty;
  99298. /** @hidden */
  99299. _markAllSubMeshesAsTexturesDirty(): void;
  99300. /**
  99301. * Instantiate a new istance of clear coat configuration.
  99302. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  99303. */
  99304. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  99305. /**
  99306. * Specifies that the submesh is ready to be used.
  99307. * @param defines the list of "defines" to update.
  99308. * @param scene defines the scene the material belongs to.
  99309. * @param engine defines the engine the material belongs to.
  99310. * @param disableBumpMap defines wether the material disables bump or not.
  99311. * @returns - boolean indicating that the submesh is ready or not.
  99312. */
  99313. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  99314. /**
  99315. * Checks to see if a texture is used in the material.
  99316. * @param defines the list of "defines" to update.
  99317. * @param scene defines the scene to the material belongs to.
  99318. */
  99319. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  99320. /**
  99321. * Binds the material data.
  99322. * @param uniformBuffer defines the Uniform buffer to fill in.
  99323. * @param scene defines the scene the material belongs to.
  99324. * @param engine defines the engine the material belongs to.
  99325. * @param disableBumpMap defines wether the material disables bump or not.
  99326. * @param isFrozen defines wether the material is frozen or not.
  99327. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99328. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99329. */
  99330. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  99331. /**
  99332. * Checks to see if a texture is used in the material.
  99333. * @param texture - Base texture to use.
  99334. * @returns - Boolean specifying if a texture is used in the material.
  99335. */
  99336. hasTexture(texture: BaseTexture): boolean;
  99337. /**
  99338. * Returns an array of the actively used textures.
  99339. * @param activeTextures Array of BaseTextures
  99340. */
  99341. getActiveTextures(activeTextures: BaseTexture[]): void;
  99342. /**
  99343. * Returns the animatable textures.
  99344. * @param animatables Array of animatable textures.
  99345. */
  99346. getAnimatables(animatables: IAnimatable[]): void;
  99347. /**
  99348. * Disposes the resources of the material.
  99349. * @param forceDisposeTextures - Forces the disposal of all textures.
  99350. */
  99351. dispose(forceDisposeTextures?: boolean): void;
  99352. /**
  99353. * Get the current class name of the texture useful for serialization or dynamic coding.
  99354. * @returns "PBRClearCoatConfiguration"
  99355. */
  99356. getClassName(): string;
  99357. /**
  99358. * Makes a duplicate of the current configuration into another one.
  99359. * @param clearCoatConfiguration define the config where to copy the info
  99360. */
  99361. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  99362. /**
  99363. * Serializes this clear coat configuration.
  99364. * @returns - An object with the serialized config.
  99365. */
  99366. serialize(): any;
  99367. /**
  99368. * Parses a Clear Coat Configuration from a serialized object.
  99369. * @param source - Serialized object.
  99370. */
  99371. parse(source: any): void;
  99372. /**
  99373. * Add fallbacks to the effect fallbacks list.
  99374. * @param defines defines the Base texture to use.
  99375. * @param fallbacks defines the current fallback list.
  99376. * @param currentRank defines the current fallback rank.
  99377. * @returns the new fallback rank.
  99378. */
  99379. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99380. /**
  99381. * Add the required uniforms to the current list.
  99382. * @param uniforms defines the current uniform list.
  99383. */
  99384. static AddUniforms(uniforms: string[]): void;
  99385. /**
  99386. * Add the required samplers to the current list.
  99387. * @param samplers defines the current sampler list.
  99388. */
  99389. static AddSamplers(samplers: string[]): void;
  99390. /**
  99391. * Add the required uniforms to the current buffer.
  99392. * @param uniformBuffer defines the current uniform buffer.
  99393. */
  99394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99395. }
  99396. }
  99397. declare module BABYLON {
  99398. /**
  99399. * @hidden
  99400. */
  99401. export interface IMaterialAnisotropicDefines {
  99402. ANISOTROPIC: boolean;
  99403. MAINUV1: boolean;
  99404. _areMiscDirty: boolean;
  99405. _needUVs: boolean;
  99406. }
  99407. /**
  99408. * Define the code related to the anisotropic parameters of the pbr material.
  99409. */
  99410. export class PBRAnisotropicConfiguration {
  99411. private _isEnabled;
  99412. /**
  99413. * Defines if the anisotropy is enabled in the material.
  99414. */
  99415. isEnabled: boolean;
  99416. /**
  99417. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  99418. */
  99419. intensity: number;
  99420. /**
  99421. * Defines if the effect is along the tangents or bitangents.
  99422. * By default, the effect is "strectching" the highlights along the tangents.
  99423. */
  99424. followTangents: boolean;
  99425. /** @hidden */
  99426. private _internalMarkAllSubMeshesAsMiscDirty;
  99427. /** @hidden */
  99428. _markAllSubMeshesAsMiscDirty(): void;
  99429. /**
  99430. * Instantiate a new istance of clear coat configuration.
  99431. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  99432. */
  99433. constructor(markAllSubMeshesAsMiscDirty: () => void);
  99434. /**
  99435. * Checks to see if a texture is used in the material.
  99436. * @param defines the list of "defines" to update.
  99437. * @param mesh the mesh we are preparing the defines for.
  99438. */
  99439. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  99440. /**
  99441. * Binds the material data.
  99442. * @param uniformBuffer defines the Uniform buffer to fill in.
  99443. * @param isFrozen defines wether the material is frozen or not.
  99444. */
  99445. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  99446. /**
  99447. * Get the current class name of the texture useful for serialization or dynamic coding.
  99448. * @returns "PBRAnisotropicConfiguration"
  99449. */
  99450. getClassName(): string;
  99451. /**
  99452. * Makes a duplicate of the current configuration into another one.
  99453. * @param anisotropicConfiguration define the config where to copy the info
  99454. */
  99455. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  99456. /**
  99457. * Serializes this clear coat configuration.
  99458. * @returns - An object with the serialized config.
  99459. */
  99460. serialize(): any;
  99461. /**
  99462. * Parses a Clear Coat Configuration from a serialized object.
  99463. * @param source - Serialized object.
  99464. */
  99465. parse(source: any): void;
  99466. /**
  99467. * Add fallbacks to the effect fallbacks list.
  99468. * @param defines defines the Base texture to use.
  99469. * @param fallbacks defines the current fallback list.
  99470. * @param currentRank defines the current fallback rank.
  99471. * @returns the new fallback rank.
  99472. */
  99473. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99474. /**
  99475. * Add the required uniforms to the current list.
  99476. * @param uniforms defines the current uniform list.
  99477. */
  99478. static AddUniforms(uniforms: string[]): void;
  99479. /**
  99480. * Add the required uniforms to the current buffer.
  99481. * @param uniformBuffer defines the current uniform buffer.
  99482. */
  99483. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99484. }
  99485. }
  99486. declare module BABYLON {
  99487. /** @hidden */
  99488. export var pbrFragmentDeclaration: {
  99489. name: string;
  99490. shader: string;
  99491. };
  99492. }
  99493. declare module BABYLON {
  99494. /** @hidden */
  99495. export var pbrUboDeclaration: {
  99496. name: string;
  99497. shader: string;
  99498. };
  99499. }
  99500. declare module BABYLON {
  99501. /** @hidden */
  99502. export var pbrFunctions: {
  99503. name: string;
  99504. shader: string;
  99505. };
  99506. }
  99507. declare module BABYLON {
  99508. /** @hidden */
  99509. export var harmonicsFunctions: {
  99510. name: string;
  99511. shader: string;
  99512. };
  99513. }
  99514. declare module BABYLON {
  99515. /** @hidden */
  99516. export var pbrPreLightingFunctions: {
  99517. name: string;
  99518. shader: string;
  99519. };
  99520. }
  99521. declare module BABYLON {
  99522. /** @hidden */
  99523. export var pbrFalloffLightingFunctions: {
  99524. name: string;
  99525. shader: string;
  99526. };
  99527. }
  99528. declare module BABYLON {
  99529. /** @hidden */
  99530. export var pbrLightingFunctions: {
  99531. name: string;
  99532. shader: string;
  99533. };
  99534. }
  99535. declare module BABYLON {
  99536. /** @hidden */
  99537. export var pbrPixelShader: {
  99538. name: string;
  99539. shader: string;
  99540. };
  99541. }
  99542. declare module BABYLON {
  99543. /** @hidden */
  99544. export var pbrVertexDeclaration: {
  99545. name: string;
  99546. shader: string;
  99547. };
  99548. }
  99549. declare module BABYLON {
  99550. /** @hidden */
  99551. export var pbrVertexShader: {
  99552. name: string;
  99553. shader: string;
  99554. };
  99555. }
  99556. declare module BABYLON {
  99557. /**
  99558. * The Physically based material base class of BJS.
  99559. *
  99560. * This offers the main features of a standard PBR material.
  99561. * For more information, please refer to the documentation :
  99562. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99563. */
  99564. export abstract class PBRBaseMaterial extends PushMaterial {
  99565. /**
  99566. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99567. */
  99568. static readonly PBRMATERIAL_OPAQUE: number;
  99569. /**
  99570. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99571. */
  99572. static readonly PBRMATERIAL_ALPHATEST: number;
  99573. /**
  99574. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99575. */
  99576. static readonly PBRMATERIAL_ALPHABLEND: number;
  99577. /**
  99578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99579. * They are also discarded below the alpha cutoff threshold to improve performances.
  99580. */
  99581. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99582. /**
  99583. * Defines the default value of how much AO map is occluding the analytical lights
  99584. * (point spot...).
  99585. */
  99586. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99587. /**
  99588. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  99589. */
  99590. static readonly LIGHTFALLOFF_PHYSICAL: number;
  99591. /**
  99592. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  99593. * to enhance interoperability with other engines.
  99594. */
  99595. static readonly LIGHTFALLOFF_GLTF: number;
  99596. /**
  99597. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  99598. * to enhance interoperability with other materials.
  99599. */
  99600. static readonly LIGHTFALLOFF_STANDARD: number;
  99601. /**
  99602. * Intensity of the direct lights e.g. the four lights available in your scene.
  99603. * This impacts both the direct diffuse and specular highlights.
  99604. */
  99605. protected _directIntensity: number;
  99606. /**
  99607. * Intensity of the emissive part of the material.
  99608. * This helps controlling the emissive effect without modifying the emissive color.
  99609. */
  99610. protected _emissiveIntensity: number;
  99611. /**
  99612. * Intensity of the environment e.g. how much the environment will light the object
  99613. * either through harmonics for rough material or through the refelction for shiny ones.
  99614. */
  99615. protected _environmentIntensity: number;
  99616. /**
  99617. * This is a special control allowing the reduction of the specular highlights coming from the
  99618. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99619. */
  99620. protected _specularIntensity: number;
  99621. /**
  99622. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  99623. */
  99624. private _lightingInfos;
  99625. /**
  99626. * Debug Control allowing disabling the bump map on this material.
  99627. */
  99628. protected _disableBumpMap: boolean;
  99629. /**
  99630. * AKA Diffuse Texture in standard nomenclature.
  99631. */
  99632. protected _albedoTexture: BaseTexture;
  99633. /**
  99634. * AKA Occlusion Texture in other nomenclature.
  99635. */
  99636. protected _ambientTexture: BaseTexture;
  99637. /**
  99638. * AKA Occlusion Texture Intensity in other nomenclature.
  99639. */
  99640. protected _ambientTextureStrength: number;
  99641. /**
  99642. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99643. * 1 means it completely occludes it
  99644. * 0 mean it has no impact
  99645. */
  99646. protected _ambientTextureImpactOnAnalyticalLights: number;
  99647. /**
  99648. * Stores the alpha values in a texture.
  99649. */
  99650. protected _opacityTexture: BaseTexture;
  99651. /**
  99652. * Stores the reflection values in a texture.
  99653. */
  99654. protected _reflectionTexture: BaseTexture;
  99655. /**
  99656. * Stores the refraction values in a texture.
  99657. */
  99658. protected _refractionTexture: BaseTexture;
  99659. /**
  99660. * Stores the emissive values in a texture.
  99661. */
  99662. protected _emissiveTexture: BaseTexture;
  99663. /**
  99664. * AKA Specular texture in other nomenclature.
  99665. */
  99666. protected _reflectivityTexture: BaseTexture;
  99667. /**
  99668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99669. */
  99670. protected _metallicTexture: BaseTexture;
  99671. /**
  99672. * Specifies the metallic scalar of the metallic/roughness workflow.
  99673. * Can also be used to scale the metalness values of the metallic texture.
  99674. */
  99675. protected _metallic: Nullable<number>;
  99676. /**
  99677. * Specifies the roughness scalar of the metallic/roughness workflow.
  99678. * Can also be used to scale the roughness values of the metallic texture.
  99679. */
  99680. protected _roughness: Nullable<number>;
  99681. /**
  99682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99684. */
  99685. protected _microSurfaceTexture: BaseTexture;
  99686. /**
  99687. * Stores surface normal data used to displace a mesh in a texture.
  99688. */
  99689. protected _bumpTexture: BaseTexture;
  99690. /**
  99691. * Stores the pre-calculated light information of a mesh in a texture.
  99692. */
  99693. protected _lightmapTexture: BaseTexture;
  99694. /**
  99695. * The color of a material in ambient lighting.
  99696. */
  99697. protected _ambientColor: Color3;
  99698. /**
  99699. * AKA Diffuse Color in other nomenclature.
  99700. */
  99701. protected _albedoColor: Color3;
  99702. /**
  99703. * AKA Specular Color in other nomenclature.
  99704. */
  99705. protected _reflectivityColor: Color3;
  99706. /**
  99707. * The color applied when light is reflected from a material.
  99708. */
  99709. protected _reflectionColor: Color3;
  99710. /**
  99711. * The color applied when light is emitted from a material.
  99712. */
  99713. protected _emissiveColor: Color3;
  99714. /**
  99715. * AKA Glossiness in other nomenclature.
  99716. */
  99717. protected _microSurface: number;
  99718. /**
  99719. * source material index of refraction (IOR)' / 'destination material IOR.
  99720. */
  99721. protected _indexOfRefraction: number;
  99722. /**
  99723. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99724. */
  99725. protected _invertRefractionY: boolean;
  99726. /**
  99727. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99728. * Materials half opaque for instance using refraction could benefit from this control.
  99729. */
  99730. protected _linkRefractionWithTransparency: boolean;
  99731. /**
  99732. * Specifies that the material will use the light map as a show map.
  99733. */
  99734. protected _useLightmapAsShadowmap: boolean;
  99735. /**
  99736. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99737. * makes the reflect vector face the model (under horizon).
  99738. */
  99739. protected _useHorizonOcclusion: boolean;
  99740. /**
  99741. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99742. * too much the area relying on ambient texture to define their ambient occlusion.
  99743. */
  99744. protected _useRadianceOcclusion: boolean;
  99745. /**
  99746. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99747. */
  99748. protected _useAlphaFromAlbedoTexture: boolean;
  99749. /**
  99750. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  99751. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99752. */
  99753. protected _useSpecularOverAlpha: boolean;
  99754. /**
  99755. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99756. */
  99757. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99758. /**
  99759. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99760. */
  99761. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  99762. /**
  99763. * Specifies if the metallic texture contains the roughness information in its green channel.
  99764. */
  99765. protected _useRoughnessFromMetallicTextureGreen: boolean;
  99766. /**
  99767. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99768. */
  99769. protected _useMetallnessFromMetallicTextureBlue: boolean;
  99770. /**
  99771. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99772. */
  99773. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  99774. /**
  99775. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99776. */
  99777. protected _useAmbientInGrayScale: boolean;
  99778. /**
  99779. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99780. * The material will try to infer what glossiness each pixel should be.
  99781. */
  99782. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  99783. /**
  99784. * Defines the falloff type used in this material.
  99785. * It by default is Physical.
  99786. */
  99787. protected _lightFalloff: number;
  99788. /**
  99789. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99790. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99791. */
  99792. protected _useRadianceOverAlpha: boolean;
  99793. /**
  99794. * Allows using an object space normal map (instead of tangent space).
  99795. */
  99796. protected _useObjectSpaceNormalMap: boolean;
  99797. /**
  99798. * Allows using the bump map in parallax mode.
  99799. */
  99800. protected _useParallax: boolean;
  99801. /**
  99802. * Allows using the bump map in parallax occlusion mode.
  99803. */
  99804. protected _useParallaxOcclusion: boolean;
  99805. /**
  99806. * Controls the scale bias of the parallax mode.
  99807. */
  99808. protected _parallaxScaleBias: number;
  99809. /**
  99810. * If sets to true, disables all the lights affecting the material.
  99811. */
  99812. protected _disableLighting: boolean;
  99813. /**
  99814. * Number of Simultaneous lights allowed on the material.
  99815. */
  99816. protected _maxSimultaneousLights: number;
  99817. /**
  99818. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99819. */
  99820. protected _invertNormalMapX: boolean;
  99821. /**
  99822. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99823. */
  99824. protected _invertNormalMapY: boolean;
  99825. /**
  99826. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99827. */
  99828. protected _twoSidedLighting: boolean;
  99829. /**
  99830. * Defines the alpha limits in alpha test mode.
  99831. */
  99832. protected _alphaCutOff: number;
  99833. /**
  99834. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99835. */
  99836. protected _forceAlphaTest: boolean;
  99837. /**
  99838. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99839. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99840. */
  99841. protected _useAlphaFresnel: boolean;
  99842. /**
  99843. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99844. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99845. */
  99846. protected _useLinearAlphaFresnel: boolean;
  99847. /**
  99848. * The transparency mode of the material.
  99849. */
  99850. protected _transparencyMode: Nullable<number>;
  99851. /**
  99852. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99853. * from cos thetav and roughness:
  99854. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99855. */
  99856. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99857. /**
  99858. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99859. */
  99860. protected _forceIrradianceInFragment: boolean;
  99861. /**
  99862. * Force normal to face away from face.
  99863. */
  99864. protected _forceNormalForward: boolean;
  99865. /**
  99866. * Enables specular anti aliasing in the PBR shader.
  99867. * It will both interacts on the Geometry for analytical and IBL lighting.
  99868. * It also prefilter the roughness map based on the bump values.
  99869. */
  99870. protected _enableSpecularAntiAliasing: boolean;
  99871. /**
  99872. * Default configuration related to image processing available in the PBR Material.
  99873. */
  99874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99875. /**
  99876. * Keep track of the image processing observer to allow dispose and replace.
  99877. */
  99878. private _imageProcessingObserver;
  99879. /**
  99880. * Attaches a new image processing configuration to the PBR Material.
  99881. * @param configuration
  99882. */
  99883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99884. /**
  99885. * Stores the available render targets.
  99886. */
  99887. private _renderTargets;
  99888. /**
  99889. * Sets the global ambient color for the material used in lighting calculations.
  99890. */
  99891. private _globalAmbientColor;
  99892. /**
  99893. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99894. */
  99895. private _useLogarithmicDepth;
  99896. /**
  99897. * If set to true, no lighting calculations will be applied.
  99898. */
  99899. private _unlit;
  99900. /**
  99901. * Defines the clear coat layer parameters for the material.
  99902. */
  99903. readonly clearCoat: PBRClearCoatConfiguration;
  99904. /**
  99905. * Defines the anisotropic parameters for the material.
  99906. */
  99907. readonly anisotropy: PBRAnisotropicConfiguration;
  99908. /**
  99909. * Instantiates a new PBRMaterial instance.
  99910. *
  99911. * @param name The material name
  99912. * @param scene The scene the material will be use in.
  99913. */
  99914. constructor(name: string, scene: Scene);
  99915. /**
  99916. * Gets a boolean indicating that current material needs to register RTT
  99917. */
  99918. readonly hasRenderTargetTextures: boolean;
  99919. /**
  99920. * Gets the name of the material class.
  99921. */
  99922. getClassName(): string;
  99923. /**
  99924. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99925. */
  99926. /**
  99927. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99928. */
  99929. useLogarithmicDepth: boolean;
  99930. /**
  99931. * Gets the current transparency mode.
  99932. */
  99933. /**
  99934. * Sets the transparency mode of the material.
  99935. *
  99936. * | Value | Type | Description |
  99937. * | ----- | ----------------------------------- | ----------- |
  99938. * | 0 | OPAQUE | |
  99939. * | 1 | ALPHATEST | |
  99940. * | 2 | ALPHABLEND | |
  99941. * | 3 | ALPHATESTANDBLEND | |
  99942. *
  99943. */
  99944. transparencyMode: Nullable<number>;
  99945. /**
  99946. * Returns true if alpha blending should be disabled.
  99947. */
  99948. private readonly _disableAlphaBlending;
  99949. /**
  99950. * Specifies whether or not this material should be rendered in alpha blend mode.
  99951. */
  99952. needAlphaBlending(): boolean;
  99953. /**
  99954. * Specifies if the mesh will require alpha blending.
  99955. * @param mesh - BJS mesh.
  99956. */
  99957. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99958. /**
  99959. * Specifies whether or not this material should be rendered in alpha test mode.
  99960. */
  99961. needAlphaTesting(): boolean;
  99962. /**
  99963. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99964. */
  99965. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99966. /**
  99967. * Gets the texture used for the alpha test.
  99968. */
  99969. getAlphaTestTexture(): BaseTexture;
  99970. /**
  99971. * Specifies that the submesh is ready to be used.
  99972. * @param mesh - BJS mesh.
  99973. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99974. * @param useInstances - Specifies that instances should be used.
  99975. * @returns - boolean indicating that the submesh is ready or not.
  99976. */
  99977. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99978. /**
  99979. * Specifies if the material uses metallic roughness workflow.
  99980. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99981. */
  99982. isMetallicWorkflow(): boolean;
  99983. private _prepareEffect;
  99984. private _prepareDefines;
  99985. /**
  99986. * Force shader compilation
  99987. */
  99988. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99989. clipPlane: boolean;
  99990. }>): void;
  99991. /**
  99992. * Initializes the uniform buffer layout for the shader.
  99993. */
  99994. buildUniformLayout(): void;
  99995. /**
  99996. * Unbinds the textures.
  99997. */
  99998. unbind(): void;
  99999. /**
  100000. * Binds the submesh data.
  100001. * @param world - The world matrix.
  100002. * @param mesh - The BJS mesh.
  100003. * @param subMesh - A submesh of the BJS mesh.
  100004. */
  100005. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100006. /**
  100007. * Returns the animatable textures.
  100008. * @returns - Array of animatable textures.
  100009. */
  100010. getAnimatables(): IAnimatable[];
  100011. /**
  100012. * Returns the texture used for reflections.
  100013. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100014. */
  100015. private _getReflectionTexture;
  100016. /**
  100017. * Returns the texture used for refraction or null if none is used.
  100018. * @returns - Refection texture if present. If no refraction texture and refraction
  100019. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100020. */
  100021. private _getRefractionTexture;
  100022. /**
  100023. * Returns an array of the actively used textures.
  100024. * @returns - Array of BaseTextures
  100025. */
  100026. getActiveTextures(): BaseTexture[];
  100027. /**
  100028. * Checks to see if a texture is used in the material.
  100029. * @param texture - Base texture to use.
  100030. * @returns - Boolean specifying if a texture is used in the material.
  100031. */
  100032. hasTexture(texture: BaseTexture): boolean;
  100033. /**
  100034. * Disposes the resources of the material.
  100035. * @param forceDisposeEffect - Forces the disposal of effects.
  100036. * @param forceDisposeTextures - Forces the disposal of all textures.
  100037. */
  100038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100039. }
  100040. }
  100041. declare module BABYLON {
  100042. /**
  100043. * The Physically based material of BJS.
  100044. *
  100045. * This offers the main features of a standard PBR material.
  100046. * For more information, please refer to the documentation :
  100047. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100048. */
  100049. export class PBRMaterial extends PBRBaseMaterial {
  100050. /**
  100051. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100052. */
  100053. static readonly PBRMATERIAL_OPAQUE: number;
  100054. /**
  100055. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100056. */
  100057. static readonly PBRMATERIAL_ALPHATEST: number;
  100058. /**
  100059. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100060. */
  100061. static readonly PBRMATERIAL_ALPHABLEND: number;
  100062. /**
  100063. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100064. * They are also discarded below the alpha cutoff threshold to improve performances.
  100065. */
  100066. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100067. /**
  100068. * Defines the default value of how much AO map is occluding the analytical lights
  100069. * (point spot...).
  100070. */
  100071. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100072. /**
  100073. * Intensity of the direct lights e.g. the four lights available in your scene.
  100074. * This impacts both the direct diffuse and specular highlights.
  100075. */
  100076. directIntensity: number;
  100077. /**
  100078. * Intensity of the emissive part of the material.
  100079. * This helps controlling the emissive effect without modifying the emissive color.
  100080. */
  100081. emissiveIntensity: number;
  100082. /**
  100083. * Intensity of the environment e.g. how much the environment will light the object
  100084. * either through harmonics for rough material or through the refelction for shiny ones.
  100085. */
  100086. environmentIntensity: number;
  100087. /**
  100088. * This is a special control allowing the reduction of the specular highlights coming from the
  100089. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100090. */
  100091. specularIntensity: number;
  100092. /**
  100093. * Debug Control allowing disabling the bump map on this material.
  100094. */
  100095. disableBumpMap: boolean;
  100096. /**
  100097. * AKA Diffuse Texture in standard nomenclature.
  100098. */
  100099. albedoTexture: BaseTexture;
  100100. /**
  100101. * AKA Occlusion Texture in other nomenclature.
  100102. */
  100103. ambientTexture: BaseTexture;
  100104. /**
  100105. * AKA Occlusion Texture Intensity in other nomenclature.
  100106. */
  100107. ambientTextureStrength: number;
  100108. /**
  100109. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100110. * 1 means it completely occludes it
  100111. * 0 mean it has no impact
  100112. */
  100113. ambientTextureImpactOnAnalyticalLights: number;
  100114. /**
  100115. * Stores the alpha values in a texture.
  100116. */
  100117. opacityTexture: BaseTexture;
  100118. /**
  100119. * Stores the reflection values in a texture.
  100120. */
  100121. reflectionTexture: Nullable<BaseTexture>;
  100122. /**
  100123. * Stores the emissive values in a texture.
  100124. */
  100125. emissiveTexture: BaseTexture;
  100126. /**
  100127. * AKA Specular texture in other nomenclature.
  100128. */
  100129. reflectivityTexture: BaseTexture;
  100130. /**
  100131. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100132. */
  100133. metallicTexture: BaseTexture;
  100134. /**
  100135. * Specifies the metallic scalar of the metallic/roughness workflow.
  100136. * Can also be used to scale the metalness values of the metallic texture.
  100137. */
  100138. metallic: Nullable<number>;
  100139. /**
  100140. * Specifies the roughness scalar of the metallic/roughness workflow.
  100141. * Can also be used to scale the roughness values of the metallic texture.
  100142. */
  100143. roughness: Nullable<number>;
  100144. /**
  100145. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100146. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100147. */
  100148. microSurfaceTexture: BaseTexture;
  100149. /**
  100150. * Stores surface normal data used to displace a mesh in a texture.
  100151. */
  100152. bumpTexture: BaseTexture;
  100153. /**
  100154. * Stores the pre-calculated light information of a mesh in a texture.
  100155. */
  100156. lightmapTexture: BaseTexture;
  100157. /**
  100158. * Stores the refracted light information in a texture.
  100159. */
  100160. refractionTexture: BaseTexture;
  100161. /**
  100162. * The color of a material in ambient lighting.
  100163. */
  100164. ambientColor: Color3;
  100165. /**
  100166. * AKA Diffuse Color in other nomenclature.
  100167. */
  100168. albedoColor: Color3;
  100169. /**
  100170. * AKA Specular Color in other nomenclature.
  100171. */
  100172. reflectivityColor: Color3;
  100173. /**
  100174. * The color reflected from the material.
  100175. */
  100176. reflectionColor: Color3;
  100177. /**
  100178. * The color emitted from the material.
  100179. */
  100180. emissiveColor: Color3;
  100181. /**
  100182. * AKA Glossiness in other nomenclature.
  100183. */
  100184. microSurface: number;
  100185. /**
  100186. * source material index of refraction (IOR)' / 'destination material IOR.
  100187. */
  100188. indexOfRefraction: number;
  100189. /**
  100190. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100191. */
  100192. invertRefractionY: boolean;
  100193. /**
  100194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100195. * Materials half opaque for instance using refraction could benefit from this control.
  100196. */
  100197. linkRefractionWithTransparency: boolean;
  100198. /**
  100199. * If true, the light map contains occlusion information instead of lighting info.
  100200. */
  100201. useLightmapAsShadowmap: boolean;
  100202. /**
  100203. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100204. */
  100205. useAlphaFromAlbedoTexture: boolean;
  100206. /**
  100207. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100208. */
  100209. forceAlphaTest: boolean;
  100210. /**
  100211. * Defines the alpha limits in alpha test mode.
  100212. */
  100213. alphaCutOff: number;
  100214. /**
  100215. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100216. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100217. */
  100218. useSpecularOverAlpha: boolean;
  100219. /**
  100220. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100221. */
  100222. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100223. /**
  100224. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100225. */
  100226. useRoughnessFromMetallicTextureAlpha: boolean;
  100227. /**
  100228. * Specifies if the metallic texture contains the roughness information in its green channel.
  100229. */
  100230. useRoughnessFromMetallicTextureGreen: boolean;
  100231. /**
  100232. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100233. */
  100234. useMetallnessFromMetallicTextureBlue: boolean;
  100235. /**
  100236. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100237. */
  100238. useAmbientOcclusionFromMetallicTextureRed: boolean;
  100239. /**
  100240. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100241. */
  100242. useAmbientInGrayScale: boolean;
  100243. /**
  100244. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100245. * The material will try to infer what glossiness each pixel should be.
  100246. */
  100247. useAutoMicroSurfaceFromReflectivityMap: boolean;
  100248. /**
  100249. * BJS is using an harcoded light falloff based on a manually sets up range.
  100250. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100251. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100252. */
  100253. /**
  100254. * BJS is using an harcoded light falloff based on a manually sets up range.
  100255. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100256. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100257. */
  100258. usePhysicalLightFalloff: boolean;
  100259. /**
  100260. * In order to support the falloff compatibility with gltf, a special mode has been added
  100261. * to reproduce the gltf light falloff.
  100262. */
  100263. /**
  100264. * In order to support the falloff compatibility with gltf, a special mode has been added
  100265. * to reproduce the gltf light falloff.
  100266. */
  100267. useGLTFLightFalloff: boolean;
  100268. /**
  100269. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100270. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100271. */
  100272. useRadianceOverAlpha: boolean;
  100273. /**
  100274. * Allows using an object space normal map (instead of tangent space).
  100275. */
  100276. useObjectSpaceNormalMap: boolean;
  100277. /**
  100278. * Allows using the bump map in parallax mode.
  100279. */
  100280. useParallax: boolean;
  100281. /**
  100282. * Allows using the bump map in parallax occlusion mode.
  100283. */
  100284. useParallaxOcclusion: boolean;
  100285. /**
  100286. * Controls the scale bias of the parallax mode.
  100287. */
  100288. parallaxScaleBias: number;
  100289. /**
  100290. * If sets to true, disables all the lights affecting the material.
  100291. */
  100292. disableLighting: boolean;
  100293. /**
  100294. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100295. */
  100296. forceIrradianceInFragment: boolean;
  100297. /**
  100298. * Number of Simultaneous lights allowed on the material.
  100299. */
  100300. maxSimultaneousLights: number;
  100301. /**
  100302. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100303. */
  100304. invertNormalMapX: boolean;
  100305. /**
  100306. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100307. */
  100308. invertNormalMapY: boolean;
  100309. /**
  100310. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100311. */
  100312. twoSidedLighting: boolean;
  100313. /**
  100314. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100315. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100316. */
  100317. useAlphaFresnel: boolean;
  100318. /**
  100319. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100320. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100321. */
  100322. useLinearAlphaFresnel: boolean;
  100323. /**
  100324. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100325. * And/Or occlude the blended part.
  100326. */
  100327. environmentBRDFTexture: Nullable<BaseTexture>;
  100328. /**
  100329. * Force normal to face away from face.
  100330. */
  100331. forceNormalForward: boolean;
  100332. /**
  100333. * Enables specular anti aliasing in the PBR shader.
  100334. * It will both interacts on the Geometry for analytical and IBL lighting.
  100335. * It also prefilter the roughness map based on the bump values.
  100336. */
  100337. enableSpecularAntiAliasing: boolean;
  100338. /**
  100339. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100340. * makes the reflect vector face the model (under horizon).
  100341. */
  100342. useHorizonOcclusion: boolean;
  100343. /**
  100344. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100345. * too much the area relying on ambient texture to define their ambient occlusion.
  100346. */
  100347. useRadianceOcclusion: boolean;
  100348. /**
  100349. * If set to true, no lighting calculations will be applied.
  100350. */
  100351. unlit: boolean;
  100352. /**
  100353. * Gets the image processing configuration used either in this material.
  100354. */
  100355. /**
  100356. * Sets the Default image processing configuration used either in the this material.
  100357. *
  100358. * If sets to null, the scene one is in use.
  100359. */
  100360. imageProcessingConfiguration: ImageProcessingConfiguration;
  100361. /**
  100362. * Gets wether the color curves effect is enabled.
  100363. */
  100364. /**
  100365. * Sets wether the color curves effect is enabled.
  100366. */
  100367. cameraColorCurvesEnabled: boolean;
  100368. /**
  100369. * Gets wether the color grading effect is enabled.
  100370. */
  100371. /**
  100372. * Gets wether the color grading effect is enabled.
  100373. */
  100374. cameraColorGradingEnabled: boolean;
  100375. /**
  100376. * Gets wether tonemapping is enabled or not.
  100377. */
  100378. /**
  100379. * Sets wether tonemapping is enabled or not
  100380. */
  100381. cameraToneMappingEnabled: boolean;
  100382. /**
  100383. * The camera exposure used on this material.
  100384. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100385. * This corresponds to a photographic exposure.
  100386. */
  100387. /**
  100388. * The camera exposure used on this material.
  100389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100390. * This corresponds to a photographic exposure.
  100391. */
  100392. cameraExposure: number;
  100393. /**
  100394. * Gets The camera contrast used on this material.
  100395. */
  100396. /**
  100397. * Sets The camera contrast used on this material.
  100398. */
  100399. cameraContrast: number;
  100400. /**
  100401. * Gets the Color Grading 2D Lookup Texture.
  100402. */
  100403. /**
  100404. * Sets the Color Grading 2D Lookup Texture.
  100405. */
  100406. cameraColorGradingTexture: Nullable<BaseTexture>;
  100407. /**
  100408. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100409. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100410. * 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;
  100411. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100412. */
  100413. /**
  100414. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100415. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100416. * 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;
  100417. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100418. */
  100419. cameraColorCurves: Nullable<ColorCurves>;
  100420. /**
  100421. * Instantiates a new PBRMaterial instance.
  100422. *
  100423. * @param name The material name
  100424. * @param scene The scene the material will be use in.
  100425. */
  100426. constructor(name: string, scene: Scene);
  100427. /**
  100428. * Returns the name of this material class.
  100429. */
  100430. getClassName(): string;
  100431. /**
  100432. * Makes a duplicate of the current material.
  100433. * @param name - name to use for the new material.
  100434. */
  100435. clone(name: string): PBRMaterial;
  100436. /**
  100437. * Serializes this PBR Material.
  100438. * @returns - An object with the serialized material.
  100439. */
  100440. serialize(): any;
  100441. /**
  100442. * Parses a PBR Material from a serialized object.
  100443. * @param source - Serialized object.
  100444. * @param scene - BJS scene instance.
  100445. * @param rootUrl - url for the scene object
  100446. * @returns - PBRMaterial
  100447. */
  100448. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  100449. }
  100450. }
  100451. declare module BABYLON {
  100452. /** @hidden */
  100453. export var _forceSceneHelpersToBundle: boolean;
  100454. interface Scene {
  100455. /**
  100456. * Creates a default light for the scene.
  100457. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  100458. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  100459. */
  100460. createDefaultLight(replace?: boolean): void;
  100461. /**
  100462. * Creates a default camera for the scene.
  100463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  100464. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100465. * @param replace has default false, when true replaces the active camera in the scene
  100466. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  100467. */
  100468. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100469. /**
  100470. * Creates a default camera and a default light.
  100471. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  100472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100473. * @param replace has the default false, when true replaces the active camera/light in the scene
  100474. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  100475. */
  100476. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100477. /**
  100478. * Creates a new sky box
  100479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  100480. * @param environmentTexture defines the texture to use as environment texture
  100481. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  100482. * @param scale defines the overall scale of the skybox
  100483. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  100484. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  100485. * @returns a new mesh holding the sky box
  100486. */
  100487. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  100488. /**
  100489. * Creates a new environment
  100490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  100491. * @param options defines the options you can use to configure the environment
  100492. * @returns the new EnvironmentHelper
  100493. */
  100494. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  100495. /**
  100496. * Creates a new VREXperienceHelper
  100497. * @see http://doc.babylonjs.com/how_to/webvr_helper
  100498. * @param webVROptions defines the options used to create the new VREXperienceHelper
  100499. * @returns a new VREXperienceHelper
  100500. */
  100501. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  100502. /**
  100503. * Creates a new XREXperienceHelper
  100504. * @see http://doc.babylonjs.com/how_to/webxr
  100505. * @returns a promise for a new XREXperienceHelper
  100506. */
  100507. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  100508. }
  100509. }
  100510. declare module BABYLON {
  100511. /**
  100512. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  100513. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  100514. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  100515. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100516. */
  100517. export class VideoDome extends TransformNode {
  100518. private _useDirectMapping;
  100519. /**
  100520. * The video texture being displayed on the sphere
  100521. */
  100522. protected _videoTexture: VideoTexture;
  100523. /**
  100524. * Gets the video texture being displayed on the sphere
  100525. */
  100526. readonly videoTexture: VideoTexture;
  100527. /**
  100528. * The skybox material
  100529. */
  100530. protected _material: BackgroundMaterial;
  100531. /**
  100532. * The surface used for the skybox
  100533. */
  100534. protected _mesh: Mesh;
  100535. /**
  100536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100537. * Also see the options.resolution property.
  100538. */
  100539. fovMultiplier: number;
  100540. /**
  100541. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  100542. * @param name Element's name, child elements will append suffixes for their own names.
  100543. * @param urlsOrVideo defines the url(s) or the video element to use
  100544. * @param options An object containing optional or exposed sub element properties
  100545. */
  100546. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  100547. resolution?: number;
  100548. clickToPlay?: boolean;
  100549. autoPlay?: boolean;
  100550. loop?: boolean;
  100551. size?: number;
  100552. poster?: string;
  100553. useDirectMapping?: boolean;
  100554. }, scene: Scene);
  100555. /**
  100556. * Releases resources associated with this node.
  100557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100559. */
  100560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100561. }
  100562. }
  100563. declare module BABYLON {
  100564. /**
  100565. * This class can be used to get instrumentation data from a Babylon engine
  100566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100567. */
  100568. export class EngineInstrumentation implements IDisposable {
  100569. /**
  100570. * Define the instrumented engine.
  100571. */
  100572. engine: Engine;
  100573. private _captureGPUFrameTime;
  100574. private _gpuFrameTimeToken;
  100575. private _gpuFrameTime;
  100576. private _captureShaderCompilationTime;
  100577. private _shaderCompilationTime;
  100578. private _onBeginFrameObserver;
  100579. private _onEndFrameObserver;
  100580. private _onBeforeShaderCompilationObserver;
  100581. private _onAfterShaderCompilationObserver;
  100582. /**
  100583. * Gets the perf counter used for GPU frame time
  100584. */
  100585. readonly gpuFrameTimeCounter: PerfCounter;
  100586. /**
  100587. * Gets the GPU frame time capture status
  100588. */
  100589. /**
  100590. * Enable or disable the GPU frame time capture
  100591. */
  100592. captureGPUFrameTime: boolean;
  100593. /**
  100594. * Gets the perf counter used for shader compilation time
  100595. */
  100596. readonly shaderCompilationTimeCounter: PerfCounter;
  100597. /**
  100598. * Gets the shader compilation time capture status
  100599. */
  100600. /**
  100601. * Enable or disable the shader compilation time capture
  100602. */
  100603. captureShaderCompilationTime: boolean;
  100604. /**
  100605. * Instantiates a new engine instrumentation.
  100606. * This class can be used to get instrumentation data from a Babylon engine
  100607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100608. * @param engine Defines the engine to instrument
  100609. */
  100610. constructor(
  100611. /**
  100612. * Define the instrumented engine.
  100613. */
  100614. engine: Engine);
  100615. /**
  100616. * Dispose and release associated resources.
  100617. */
  100618. dispose(): void;
  100619. }
  100620. }
  100621. declare module BABYLON {
  100622. /**
  100623. * This class can be used to get instrumentation data from a Babylon engine
  100624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100625. */
  100626. export class SceneInstrumentation implements IDisposable {
  100627. /**
  100628. * Defines the scene to instrument
  100629. */
  100630. scene: Scene;
  100631. private _captureActiveMeshesEvaluationTime;
  100632. private _activeMeshesEvaluationTime;
  100633. private _captureRenderTargetsRenderTime;
  100634. private _renderTargetsRenderTime;
  100635. private _captureFrameTime;
  100636. private _frameTime;
  100637. private _captureRenderTime;
  100638. private _renderTime;
  100639. private _captureInterFrameTime;
  100640. private _interFrameTime;
  100641. private _captureParticlesRenderTime;
  100642. private _particlesRenderTime;
  100643. private _captureSpritesRenderTime;
  100644. private _spritesRenderTime;
  100645. private _capturePhysicsTime;
  100646. private _physicsTime;
  100647. private _captureAnimationsTime;
  100648. private _animationsTime;
  100649. private _captureCameraRenderTime;
  100650. private _cameraRenderTime;
  100651. private _onBeforeActiveMeshesEvaluationObserver;
  100652. private _onAfterActiveMeshesEvaluationObserver;
  100653. private _onBeforeRenderTargetsRenderObserver;
  100654. private _onAfterRenderTargetsRenderObserver;
  100655. private _onAfterRenderObserver;
  100656. private _onBeforeDrawPhaseObserver;
  100657. private _onAfterDrawPhaseObserver;
  100658. private _onBeforeAnimationsObserver;
  100659. private _onBeforeParticlesRenderingObserver;
  100660. private _onAfterParticlesRenderingObserver;
  100661. private _onBeforeSpritesRenderingObserver;
  100662. private _onAfterSpritesRenderingObserver;
  100663. private _onBeforePhysicsObserver;
  100664. private _onAfterPhysicsObserver;
  100665. private _onAfterAnimationsObserver;
  100666. private _onBeforeCameraRenderObserver;
  100667. private _onAfterCameraRenderObserver;
  100668. /**
  100669. * Gets the perf counter used for active meshes evaluation time
  100670. */
  100671. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  100672. /**
  100673. * Gets the active meshes evaluation time capture status
  100674. */
  100675. /**
  100676. * Enable or disable the active meshes evaluation time capture
  100677. */
  100678. captureActiveMeshesEvaluationTime: boolean;
  100679. /**
  100680. * Gets the perf counter used for render targets render time
  100681. */
  100682. readonly renderTargetsRenderTimeCounter: PerfCounter;
  100683. /**
  100684. * Gets the render targets render time capture status
  100685. */
  100686. /**
  100687. * Enable or disable the render targets render time capture
  100688. */
  100689. captureRenderTargetsRenderTime: boolean;
  100690. /**
  100691. * Gets the perf counter used for particles render time
  100692. */
  100693. readonly particlesRenderTimeCounter: PerfCounter;
  100694. /**
  100695. * Gets the particles render time capture status
  100696. */
  100697. /**
  100698. * Enable or disable the particles render time capture
  100699. */
  100700. captureParticlesRenderTime: boolean;
  100701. /**
  100702. * Gets the perf counter used for sprites render time
  100703. */
  100704. readonly spritesRenderTimeCounter: PerfCounter;
  100705. /**
  100706. * Gets the sprites render time capture status
  100707. */
  100708. /**
  100709. * Enable or disable the sprites render time capture
  100710. */
  100711. captureSpritesRenderTime: boolean;
  100712. /**
  100713. * Gets the perf counter used for physics time
  100714. */
  100715. readonly physicsTimeCounter: PerfCounter;
  100716. /**
  100717. * Gets the physics time capture status
  100718. */
  100719. /**
  100720. * Enable or disable the physics time capture
  100721. */
  100722. capturePhysicsTime: boolean;
  100723. /**
  100724. * Gets the perf counter used for animations time
  100725. */
  100726. readonly animationsTimeCounter: PerfCounter;
  100727. /**
  100728. * Gets the animations time capture status
  100729. */
  100730. /**
  100731. * Enable or disable the animations time capture
  100732. */
  100733. captureAnimationsTime: boolean;
  100734. /**
  100735. * Gets the perf counter used for frame time capture
  100736. */
  100737. readonly frameTimeCounter: PerfCounter;
  100738. /**
  100739. * Gets the frame time capture status
  100740. */
  100741. /**
  100742. * Enable or disable the frame time capture
  100743. */
  100744. captureFrameTime: boolean;
  100745. /**
  100746. * Gets the perf counter used for inter-frames time capture
  100747. */
  100748. readonly interFrameTimeCounter: PerfCounter;
  100749. /**
  100750. * Gets the inter-frames time capture status
  100751. */
  100752. /**
  100753. * Enable or disable the inter-frames time capture
  100754. */
  100755. captureInterFrameTime: boolean;
  100756. /**
  100757. * Gets the perf counter used for render time capture
  100758. */
  100759. readonly renderTimeCounter: PerfCounter;
  100760. /**
  100761. * Gets the render time capture status
  100762. */
  100763. /**
  100764. * Enable or disable the render time capture
  100765. */
  100766. captureRenderTime: boolean;
  100767. /**
  100768. * Gets the perf counter used for camera render time capture
  100769. */
  100770. readonly cameraRenderTimeCounter: PerfCounter;
  100771. /**
  100772. * Gets the camera render time capture status
  100773. */
  100774. /**
  100775. * Enable or disable the camera render time capture
  100776. */
  100777. captureCameraRenderTime: boolean;
  100778. /**
  100779. * Gets the perf counter used for draw calls
  100780. */
  100781. readonly drawCallsCounter: PerfCounter;
  100782. /**
  100783. * Gets the perf counter used for texture collisions
  100784. */
  100785. readonly textureCollisionsCounter: PerfCounter;
  100786. /**
  100787. * Instantiates a new scene instrumentation.
  100788. * This class can be used to get instrumentation data from a Babylon engine
  100789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100790. * @param scene Defines the scene to instrument
  100791. */
  100792. constructor(
  100793. /**
  100794. * Defines the scene to instrument
  100795. */
  100796. scene: Scene);
  100797. /**
  100798. * Dispose and release associated resources.
  100799. */
  100800. dispose(): void;
  100801. }
  100802. }
  100803. declare module BABYLON {
  100804. /** @hidden */
  100805. export var glowMapGenerationPixelShader: {
  100806. name: string;
  100807. shader: string;
  100808. };
  100809. }
  100810. declare module BABYLON {
  100811. /** @hidden */
  100812. export var glowMapGenerationVertexShader: {
  100813. name: string;
  100814. shader: string;
  100815. };
  100816. }
  100817. declare module BABYLON {
  100818. /**
  100819. * Effect layer options. This helps customizing the behaviour
  100820. * of the effect layer.
  100821. */
  100822. export interface IEffectLayerOptions {
  100823. /**
  100824. * Multiplication factor apply to the canvas size to compute the render target size
  100825. * used to generated the objects (the smaller the faster).
  100826. */
  100827. mainTextureRatio: number;
  100828. /**
  100829. * Enforces a fixed size texture to ensure effect stability across devices.
  100830. */
  100831. mainTextureFixedSize?: number;
  100832. /**
  100833. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100834. */
  100835. alphaBlendingMode: number;
  100836. /**
  100837. * The camera attached to the layer.
  100838. */
  100839. camera: Nullable<Camera>;
  100840. /**
  100841. * The rendering group to draw the layer in.
  100842. */
  100843. renderingGroupId: number;
  100844. }
  100845. /**
  100846. * The effect layer Helps adding post process effect blended with the main pass.
  100847. *
  100848. * This can be for instance use to generate glow or higlight effects on the scene.
  100849. *
  100850. * The effect layer class can not be used directly and is intented to inherited from to be
  100851. * customized per effects.
  100852. */
  100853. export abstract class EffectLayer {
  100854. private _vertexBuffers;
  100855. private _indexBuffer;
  100856. private _cachedDefines;
  100857. private _effectLayerMapGenerationEffect;
  100858. private _effectLayerOptions;
  100859. private _mergeEffect;
  100860. protected _scene: Scene;
  100861. protected _engine: Engine;
  100862. protected _maxSize: number;
  100863. protected _mainTextureDesiredSize: ISize;
  100864. protected _mainTexture: RenderTargetTexture;
  100865. protected _shouldRender: boolean;
  100866. protected _postProcesses: PostProcess[];
  100867. protected _textures: BaseTexture[];
  100868. protected _emissiveTextureAndColor: {
  100869. texture: Nullable<BaseTexture>;
  100870. color: Color4;
  100871. };
  100872. /**
  100873. * The name of the layer
  100874. */
  100875. name: string;
  100876. /**
  100877. * The clear color of the texture used to generate the glow map.
  100878. */
  100879. neutralColor: Color4;
  100880. /**
  100881. * Specifies wether the highlight layer is enabled or not.
  100882. */
  100883. isEnabled: boolean;
  100884. /**
  100885. * Gets the camera attached to the layer.
  100886. */
  100887. readonly camera: Nullable<Camera>;
  100888. /**
  100889. * Gets the rendering group id the layer should render in.
  100890. */
  100891. readonly renderingGroupId: number;
  100892. /**
  100893. * An event triggered when the effect layer has been disposed.
  100894. */
  100895. onDisposeObservable: Observable<EffectLayer>;
  100896. /**
  100897. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100898. */
  100899. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100900. /**
  100901. * An event triggered when the generated texture is being merged in the scene.
  100902. */
  100903. onBeforeComposeObservable: Observable<EffectLayer>;
  100904. /**
  100905. * An event triggered when the generated texture has been merged in the scene.
  100906. */
  100907. onAfterComposeObservable: Observable<EffectLayer>;
  100908. /**
  100909. * An event triggered when the efffect layer changes its size.
  100910. */
  100911. onSizeChangedObservable: Observable<EffectLayer>;
  100912. /** @hidden */
  100913. static _SceneComponentInitialization: (scene: Scene) => void;
  100914. /**
  100915. * Instantiates a new effect Layer and references it in the scene.
  100916. * @param name The name of the layer
  100917. * @param scene The scene to use the layer in
  100918. */
  100919. constructor(
  100920. /** The Friendly of the effect in the scene */
  100921. name: string, scene: Scene);
  100922. /**
  100923. * Get the effect name of the layer.
  100924. * @return The effect name
  100925. */
  100926. abstract getEffectName(): string;
  100927. /**
  100928. * Checks for the readiness of the element composing the layer.
  100929. * @param subMesh the mesh to check for
  100930. * @param useInstances specify wether or not to use instances to render the mesh
  100931. * @return true if ready otherwise, false
  100932. */
  100933. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100934. /**
  100935. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100936. * @returns true if the effect requires stencil during the main canvas render pass.
  100937. */
  100938. abstract needStencil(): boolean;
  100939. /**
  100940. * Create the merge effect. This is the shader use to blit the information back
  100941. * to the main canvas at the end of the scene rendering.
  100942. * @returns The effect containing the shader used to merge the effect on the main canvas
  100943. */
  100944. protected abstract _createMergeEffect(): Effect;
  100945. /**
  100946. * Creates the render target textures and post processes used in the effect layer.
  100947. */
  100948. protected abstract _createTextureAndPostProcesses(): void;
  100949. /**
  100950. * Implementation specific of rendering the generating effect on the main canvas.
  100951. * @param effect The effect used to render through
  100952. */
  100953. protected abstract _internalRender(effect: Effect): void;
  100954. /**
  100955. * Sets the required values for both the emissive texture and and the main color.
  100956. */
  100957. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100958. /**
  100959. * Free any resources and references associated to a mesh.
  100960. * Internal use
  100961. * @param mesh The mesh to free.
  100962. */
  100963. abstract _disposeMesh(mesh: Mesh): void;
  100964. /**
  100965. * Serializes this layer (Glow or Highlight for example)
  100966. * @returns a serialized layer object
  100967. */
  100968. abstract serialize?(): any;
  100969. /**
  100970. * Initializes the effect layer with the required options.
  100971. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100972. */
  100973. protected _init(options: Partial<IEffectLayerOptions>): void;
  100974. /**
  100975. * Generates the index buffer of the full screen quad blending to the main canvas.
  100976. */
  100977. private _generateIndexBuffer;
  100978. /**
  100979. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100980. */
  100981. private _genrateVertexBuffer;
  100982. /**
  100983. * Sets the main texture desired size which is the closest power of two
  100984. * of the engine canvas size.
  100985. */
  100986. private _setMainTextureSize;
  100987. /**
  100988. * Creates the main texture for the effect layer.
  100989. */
  100990. protected _createMainTexture(): void;
  100991. /**
  100992. * Adds specific effects defines.
  100993. * @param defines The defines to add specifics to.
  100994. */
  100995. protected _addCustomEffectDefines(defines: string[]): void;
  100996. /**
  100997. * Checks for the readiness of the element composing the layer.
  100998. * @param subMesh the mesh to check for
  100999. * @param useInstances specify wether or not to use instances to render the mesh
  101000. * @param emissiveTexture the associated emissive texture used to generate the glow
  101001. * @return true if ready otherwise, false
  101002. */
  101003. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101004. /**
  101005. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101006. */
  101007. render(): void;
  101008. /**
  101009. * Determine if a given mesh will be used in the current effect.
  101010. * @param mesh mesh to test
  101011. * @returns true if the mesh will be used
  101012. */
  101013. hasMesh(mesh: AbstractMesh): boolean;
  101014. /**
  101015. * Returns true if the layer contains information to display, otherwise false.
  101016. * @returns true if the glow layer should be rendered
  101017. */
  101018. shouldRender(): boolean;
  101019. /**
  101020. * Returns true if the mesh should render, otherwise false.
  101021. * @param mesh The mesh to render
  101022. * @returns true if it should render otherwise false
  101023. */
  101024. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101025. /**
  101026. * Returns true if the mesh can be rendered, otherwise false.
  101027. * @param mesh The mesh to render
  101028. * @param material The material used on the mesh
  101029. * @returns true if it can be rendered otherwise false
  101030. */
  101031. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101032. /**
  101033. * Returns true if the mesh should render, otherwise false.
  101034. * @param mesh The mesh to render
  101035. * @returns true if it should render otherwise false
  101036. */
  101037. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101038. /**
  101039. * Renders the submesh passed in parameter to the generation map.
  101040. */
  101041. protected _renderSubMesh(subMesh: SubMesh): void;
  101042. /**
  101043. * Rebuild the required buffers.
  101044. * @hidden Internal use only.
  101045. */
  101046. _rebuild(): void;
  101047. /**
  101048. * Dispose only the render target textures and post process.
  101049. */
  101050. private _disposeTextureAndPostProcesses;
  101051. /**
  101052. * Dispose the highlight layer and free resources.
  101053. */
  101054. dispose(): void;
  101055. /**
  101056. * Gets the class name of the effect layer
  101057. * @returns the string with the class name of the effect layer
  101058. */
  101059. getClassName(): string;
  101060. /**
  101061. * Creates an effect layer from parsed effect layer data
  101062. * @param parsedEffectLayer defines effect layer data
  101063. * @param scene defines the current scene
  101064. * @param rootUrl defines the root URL containing the effect layer information
  101065. * @returns a parsed effect Layer
  101066. */
  101067. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  101068. }
  101069. }
  101070. declare module BABYLON {
  101071. interface AbstractScene {
  101072. /**
  101073. * The list of effect layers (highlights/glow) added to the scene
  101074. * @see http://doc.babylonjs.com/how_to/highlight_layer
  101075. * @see http://doc.babylonjs.com/how_to/glow_layer
  101076. */
  101077. effectLayers: Array<EffectLayer>;
  101078. /**
  101079. * Removes the given effect layer from this scene.
  101080. * @param toRemove defines the effect layer to remove
  101081. * @returns the index of the removed effect layer
  101082. */
  101083. removeEffectLayer(toRemove: EffectLayer): number;
  101084. /**
  101085. * Adds the given effect layer to this scene
  101086. * @param newEffectLayer defines the effect layer to add
  101087. */
  101088. addEffectLayer(newEffectLayer: EffectLayer): void;
  101089. }
  101090. /**
  101091. * Defines the layer scene component responsible to manage any effect layers
  101092. * in a given scene.
  101093. */
  101094. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  101095. /**
  101096. * The component name helpfull to identify the component in the list of scene components.
  101097. */
  101098. readonly name: string;
  101099. /**
  101100. * The scene the component belongs to.
  101101. */
  101102. scene: Scene;
  101103. private _engine;
  101104. private _renderEffects;
  101105. private _needStencil;
  101106. private _previousStencilState;
  101107. /**
  101108. * Creates a new instance of the component for the given scene
  101109. * @param scene Defines the scene to register the component in
  101110. */
  101111. constructor(scene: Scene);
  101112. /**
  101113. * Registers the component in a given scene
  101114. */
  101115. register(): void;
  101116. /**
  101117. * Rebuilds the elements related to this component in case of
  101118. * context lost for instance.
  101119. */
  101120. rebuild(): void;
  101121. /**
  101122. * Serializes the component data to the specified json object
  101123. * @param serializationObject The object to serialize to
  101124. */
  101125. serialize(serializationObject: any): void;
  101126. /**
  101127. * Adds all the element from the container to the scene
  101128. * @param container the container holding the elements
  101129. */
  101130. addFromContainer(container: AbstractScene): void;
  101131. /**
  101132. * Removes all the elements in the container from the scene
  101133. * @param container contains the elements to remove
  101134. */
  101135. removeFromContainer(container: AbstractScene): void;
  101136. /**
  101137. * Disposes the component and the associated ressources.
  101138. */
  101139. dispose(): void;
  101140. private _isReadyForMesh;
  101141. private _renderMainTexture;
  101142. private _setStencil;
  101143. private _setStencilBack;
  101144. private _draw;
  101145. private _drawCamera;
  101146. private _drawRenderingGroup;
  101147. }
  101148. }
  101149. declare module BABYLON {
  101150. /** @hidden */
  101151. export var glowMapMergePixelShader: {
  101152. name: string;
  101153. shader: string;
  101154. };
  101155. }
  101156. declare module BABYLON {
  101157. /** @hidden */
  101158. export var glowMapMergeVertexShader: {
  101159. name: string;
  101160. shader: string;
  101161. };
  101162. }
  101163. declare module BABYLON {
  101164. interface AbstractScene {
  101165. /**
  101166. * Return a the first highlight layer of the scene with a given name.
  101167. * @param name The name of the highlight layer to look for.
  101168. * @return The highlight layer if found otherwise null.
  101169. */
  101170. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  101171. }
  101172. /**
  101173. * Glow layer options. This helps customizing the behaviour
  101174. * of the glow layer.
  101175. */
  101176. export interface IGlowLayerOptions {
  101177. /**
  101178. * Multiplication factor apply to the canvas size to compute the render target size
  101179. * used to generated the glowing objects (the smaller the faster).
  101180. */
  101181. mainTextureRatio: number;
  101182. /**
  101183. * Enforces a fixed size texture to ensure resize independant blur.
  101184. */
  101185. mainTextureFixedSize?: number;
  101186. /**
  101187. * How big is the kernel of the blur texture.
  101188. */
  101189. blurKernelSize: number;
  101190. /**
  101191. * The camera attached to the layer.
  101192. */
  101193. camera: Nullable<Camera>;
  101194. /**
  101195. * Enable MSAA by chosing the number of samples.
  101196. */
  101197. mainTextureSamples?: number;
  101198. /**
  101199. * The rendering group to draw the layer in.
  101200. */
  101201. renderingGroupId: number;
  101202. }
  101203. /**
  101204. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  101205. *
  101206. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  101207. * glowy meshes to your scene.
  101208. *
  101209. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  101210. */
  101211. export class GlowLayer extends EffectLayer {
  101212. /**
  101213. * Effect Name of the layer.
  101214. */
  101215. static readonly EffectName: string;
  101216. /**
  101217. * The default blur kernel size used for the glow.
  101218. */
  101219. static DefaultBlurKernelSize: number;
  101220. /**
  101221. * The default texture size ratio used for the glow.
  101222. */
  101223. static DefaultTextureRatio: number;
  101224. /**
  101225. * Sets the kernel size of the blur.
  101226. */
  101227. /**
  101228. * Gets the kernel size of the blur.
  101229. */
  101230. blurKernelSize: number;
  101231. /**
  101232. * Sets the glow intensity.
  101233. */
  101234. /**
  101235. * Gets the glow intensity.
  101236. */
  101237. intensity: number;
  101238. private _options;
  101239. private _intensity;
  101240. private _horizontalBlurPostprocess1;
  101241. private _verticalBlurPostprocess1;
  101242. private _horizontalBlurPostprocess2;
  101243. private _verticalBlurPostprocess2;
  101244. private _blurTexture1;
  101245. private _blurTexture2;
  101246. private _postProcesses1;
  101247. private _postProcesses2;
  101248. private _includedOnlyMeshes;
  101249. private _excludedMeshes;
  101250. /**
  101251. * Callback used to let the user override the color selection on a per mesh basis
  101252. */
  101253. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  101254. /**
  101255. * Callback used to let the user override the texture selection on a per mesh basis
  101256. */
  101257. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  101258. /**
  101259. * Instantiates a new glow Layer and references it to the scene.
  101260. * @param name The name of the layer
  101261. * @param scene The scene to use the layer in
  101262. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  101263. */
  101264. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  101265. /**
  101266. * Get the effect name of the layer.
  101267. * @return The effect name
  101268. */
  101269. getEffectName(): string;
  101270. /**
  101271. * Create the merge effect. This is the shader use to blit the information back
  101272. * to the main canvas at the end of the scene rendering.
  101273. */
  101274. protected _createMergeEffect(): Effect;
  101275. /**
  101276. * Creates the render target textures and post processes used in the glow layer.
  101277. */
  101278. protected _createTextureAndPostProcesses(): void;
  101279. /**
  101280. * Checks for the readiness of the element composing the layer.
  101281. * @param subMesh the mesh to check for
  101282. * @param useInstances specify wether or not to use instances to render the mesh
  101283. * @param emissiveTexture the associated emissive texture used to generate the glow
  101284. * @return true if ready otherwise, false
  101285. */
  101286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101287. /**
  101288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101289. */
  101290. needStencil(): boolean;
  101291. /**
  101292. * Returns true if the mesh can be rendered, otherwise false.
  101293. * @param mesh The mesh to render
  101294. * @param material The material used on the mesh
  101295. * @returns true if it can be rendered otherwise false
  101296. */
  101297. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101298. /**
  101299. * Implementation specific of rendering the generating effect on the main canvas.
  101300. * @param effect The effect used to render through
  101301. */
  101302. protected _internalRender(effect: Effect): void;
  101303. /**
  101304. * Sets the required values for both the emissive texture and and the main color.
  101305. */
  101306. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101307. /**
  101308. * Returns true if the mesh should render, otherwise false.
  101309. * @param mesh The mesh to render
  101310. * @returns true if it should render otherwise false
  101311. */
  101312. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101313. /**
  101314. * Adds specific effects defines.
  101315. * @param defines The defines to add specifics to.
  101316. */
  101317. protected _addCustomEffectDefines(defines: string[]): void;
  101318. /**
  101319. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  101320. * @param mesh The mesh to exclude from the glow layer
  101321. */
  101322. addExcludedMesh(mesh: Mesh): void;
  101323. /**
  101324. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  101325. * @param mesh The mesh to remove
  101326. */
  101327. removeExcludedMesh(mesh: Mesh): void;
  101328. /**
  101329. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  101330. * @param mesh The mesh to include in the glow layer
  101331. */
  101332. addIncludedOnlyMesh(mesh: Mesh): void;
  101333. /**
  101334. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  101335. * @param mesh The mesh to remove
  101336. */
  101337. removeIncludedOnlyMesh(mesh: Mesh): void;
  101338. /**
  101339. * Determine if a given mesh will be used in the glow layer
  101340. * @param mesh The mesh to test
  101341. * @returns true if the mesh will be highlighted by the current glow layer
  101342. */
  101343. hasMesh(mesh: AbstractMesh): boolean;
  101344. /**
  101345. * Free any resources and references associated to a mesh.
  101346. * Internal use
  101347. * @param mesh The mesh to free.
  101348. * @hidden
  101349. */
  101350. _disposeMesh(mesh: Mesh): void;
  101351. /**
  101352. * Gets the class name of the effect layer
  101353. * @returns the string with the class name of the effect layer
  101354. */
  101355. getClassName(): string;
  101356. /**
  101357. * Serializes this glow layer
  101358. * @returns a serialized glow layer object
  101359. */
  101360. serialize(): any;
  101361. /**
  101362. * Creates a Glow Layer from parsed glow layer data
  101363. * @param parsedGlowLayer defines glow layer data
  101364. * @param scene defines the current scene
  101365. * @param rootUrl defines the root URL containing the glow layer information
  101366. * @returns a parsed Glow Layer
  101367. */
  101368. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  101369. }
  101370. }
  101371. declare module BABYLON {
  101372. /** @hidden */
  101373. export var glowBlurPostProcessPixelShader: {
  101374. name: string;
  101375. shader: string;
  101376. };
  101377. }
  101378. declare module BABYLON {
  101379. interface AbstractScene {
  101380. /**
  101381. * Return a the first highlight layer of the scene with a given name.
  101382. * @param name The name of the highlight layer to look for.
  101383. * @return The highlight layer if found otherwise null.
  101384. */
  101385. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  101386. }
  101387. /**
  101388. * Highlight layer options. This helps customizing the behaviour
  101389. * of the highlight layer.
  101390. */
  101391. export interface IHighlightLayerOptions {
  101392. /**
  101393. * Multiplication factor apply to the canvas size to compute the render target size
  101394. * used to generated the glowing objects (the smaller the faster).
  101395. */
  101396. mainTextureRatio: number;
  101397. /**
  101398. * Enforces a fixed size texture to ensure resize independant blur.
  101399. */
  101400. mainTextureFixedSize?: number;
  101401. /**
  101402. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  101403. * of the picture to blur (the smaller the faster).
  101404. */
  101405. blurTextureSizeRatio: number;
  101406. /**
  101407. * How big in texel of the blur texture is the vertical blur.
  101408. */
  101409. blurVerticalSize: number;
  101410. /**
  101411. * How big in texel of the blur texture is the horizontal blur.
  101412. */
  101413. blurHorizontalSize: number;
  101414. /**
  101415. * Alpha blending mode used to apply the blur. Default is combine.
  101416. */
  101417. alphaBlendingMode: number;
  101418. /**
  101419. * The camera attached to the layer.
  101420. */
  101421. camera: Nullable<Camera>;
  101422. /**
  101423. * Should we display highlight as a solid stroke?
  101424. */
  101425. isStroke?: boolean;
  101426. /**
  101427. * The rendering group to draw the layer in.
  101428. */
  101429. renderingGroupId: number;
  101430. }
  101431. /**
  101432. * The highlight layer Helps adding a glow effect around a mesh.
  101433. *
  101434. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  101435. * glowy meshes to your scene.
  101436. *
  101437. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  101438. */
  101439. export class HighlightLayer extends EffectLayer {
  101440. name: string;
  101441. /**
  101442. * Effect Name of the highlight layer.
  101443. */
  101444. static readonly EffectName: string;
  101445. /**
  101446. * The neutral color used during the preparation of the glow effect.
  101447. * This is black by default as the blend operation is a blend operation.
  101448. */
  101449. static NeutralColor: Color4;
  101450. /**
  101451. * Stencil value used for glowing meshes.
  101452. */
  101453. static GlowingMeshStencilReference: number;
  101454. /**
  101455. * Stencil value used for the other meshes in the scene.
  101456. */
  101457. static NormalMeshStencilReference: number;
  101458. /**
  101459. * Specifies whether or not the inner glow is ACTIVE in the layer.
  101460. */
  101461. innerGlow: boolean;
  101462. /**
  101463. * Specifies whether or not the outer glow is ACTIVE in the layer.
  101464. */
  101465. outerGlow: boolean;
  101466. /**
  101467. * Specifies the horizontal size of the blur.
  101468. */
  101469. /**
  101470. * Gets the horizontal size of the blur.
  101471. */
  101472. blurHorizontalSize: number;
  101473. /**
  101474. * Specifies the vertical size of the blur.
  101475. */
  101476. /**
  101477. * Gets the vertical size of the blur.
  101478. */
  101479. blurVerticalSize: number;
  101480. /**
  101481. * An event triggered when the highlight layer is being blurred.
  101482. */
  101483. onBeforeBlurObservable: Observable<HighlightLayer>;
  101484. /**
  101485. * An event triggered when the highlight layer has been blurred.
  101486. */
  101487. onAfterBlurObservable: Observable<HighlightLayer>;
  101488. private _instanceGlowingMeshStencilReference;
  101489. private _options;
  101490. private _downSamplePostprocess;
  101491. private _horizontalBlurPostprocess;
  101492. private _verticalBlurPostprocess;
  101493. private _blurTexture;
  101494. private _meshes;
  101495. private _excludedMeshes;
  101496. /**
  101497. * Instantiates a new highlight Layer and references it to the scene..
  101498. * @param name The name of the layer
  101499. * @param scene The scene to use the layer in
  101500. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  101501. */
  101502. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  101503. /**
  101504. * Get the effect name of the layer.
  101505. * @return The effect name
  101506. */
  101507. getEffectName(): string;
  101508. /**
  101509. * Create the merge effect. This is the shader use to blit the information back
  101510. * to the main canvas at the end of the scene rendering.
  101511. */
  101512. protected _createMergeEffect(): Effect;
  101513. /**
  101514. * Creates the render target textures and post processes used in the highlight layer.
  101515. */
  101516. protected _createTextureAndPostProcesses(): void;
  101517. /**
  101518. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101519. */
  101520. needStencil(): boolean;
  101521. /**
  101522. * Checks for the readiness of the element composing the layer.
  101523. * @param subMesh the mesh to check for
  101524. * @param useInstances specify wether or not to use instances to render the mesh
  101525. * @param emissiveTexture the associated emissive texture used to generate the glow
  101526. * @return true if ready otherwise, false
  101527. */
  101528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101529. /**
  101530. * Implementation specific of rendering the generating effect on the main canvas.
  101531. * @param effect The effect used to render through
  101532. */
  101533. protected _internalRender(effect: Effect): void;
  101534. /**
  101535. * Returns true if the layer contains information to display, otherwise false.
  101536. */
  101537. shouldRender(): boolean;
  101538. /**
  101539. * Returns true if the mesh should render, otherwise false.
  101540. * @param mesh The mesh to render
  101541. * @returns true if it should render otherwise false
  101542. */
  101543. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101544. /**
  101545. * Sets the required values for both the emissive texture and and the main color.
  101546. */
  101547. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101548. /**
  101549. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  101550. * @param mesh The mesh to exclude from the highlight layer
  101551. */
  101552. addExcludedMesh(mesh: Mesh): void;
  101553. /**
  101554. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  101555. * @param mesh The mesh to highlight
  101556. */
  101557. removeExcludedMesh(mesh: Mesh): void;
  101558. /**
  101559. * Determine if a given mesh will be highlighted by the current HighlightLayer
  101560. * @param mesh mesh to test
  101561. * @returns true if the mesh will be highlighted by the current HighlightLayer
  101562. */
  101563. hasMesh(mesh: AbstractMesh): boolean;
  101564. /**
  101565. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  101566. * @param mesh The mesh to highlight
  101567. * @param color The color of the highlight
  101568. * @param glowEmissiveOnly Extract the glow from the emissive texture
  101569. */
  101570. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  101571. /**
  101572. * Remove a mesh from the highlight layer in order to make it stop glowing.
  101573. * @param mesh The mesh to highlight
  101574. */
  101575. removeMesh(mesh: Mesh): void;
  101576. /**
  101577. * Force the stencil to the normal expected value for none glowing parts
  101578. */
  101579. private _defaultStencilReference;
  101580. /**
  101581. * Free any resources and references associated to a mesh.
  101582. * Internal use
  101583. * @param mesh The mesh to free.
  101584. * @hidden
  101585. */
  101586. _disposeMesh(mesh: Mesh): void;
  101587. /**
  101588. * Dispose the highlight layer and free resources.
  101589. */
  101590. dispose(): void;
  101591. /**
  101592. * Gets the class name of the effect layer
  101593. * @returns the string with the class name of the effect layer
  101594. */
  101595. getClassName(): string;
  101596. /**
  101597. * Serializes this Highlight layer
  101598. * @returns a serialized Highlight layer object
  101599. */
  101600. serialize(): any;
  101601. /**
  101602. * Creates a Highlight layer from parsed Highlight layer data
  101603. * @param parsedHightlightLayer defines the Highlight layer data
  101604. * @param scene defines the current scene
  101605. * @param rootUrl defines the root URL containing the Highlight layer information
  101606. * @returns a parsed Highlight layer
  101607. */
  101608. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  101609. }
  101610. }
  101611. declare module BABYLON {
  101612. /** @hidden */
  101613. export var lensFlarePixelShader: {
  101614. name: string;
  101615. shader: string;
  101616. };
  101617. }
  101618. declare module BABYLON {
  101619. /** @hidden */
  101620. export var lensFlareVertexShader: {
  101621. name: string;
  101622. shader: string;
  101623. };
  101624. }
  101625. declare module BABYLON {
  101626. /**
  101627. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101628. * It is usually composed of several `lensFlare`.
  101629. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101630. */
  101631. export class LensFlareSystem {
  101632. /**
  101633. * Define the name of the lens flare system
  101634. */
  101635. name: string;
  101636. /**
  101637. * List of lens flares used in this system.
  101638. */
  101639. lensFlares: LensFlare[];
  101640. /**
  101641. * Define a limit from the border the lens flare can be visible.
  101642. */
  101643. borderLimit: number;
  101644. /**
  101645. * Define a viewport border we do not want to see the lens flare in.
  101646. */
  101647. viewportBorder: number;
  101648. /**
  101649. * Define a predicate which could limit the list of meshes able to occlude the effect.
  101650. */
  101651. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101652. /**
  101653. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  101654. */
  101655. layerMask: number;
  101656. /**
  101657. * Define the id of the lens flare system in the scene.
  101658. * (equal to name by default)
  101659. */
  101660. id: string;
  101661. private _scene;
  101662. private _emitter;
  101663. private _vertexBuffers;
  101664. private _indexBuffer;
  101665. private _effect;
  101666. private _positionX;
  101667. private _positionY;
  101668. private _isEnabled;
  101669. /** @hidden */
  101670. static _SceneComponentInitialization: (scene: Scene) => void;
  101671. /**
  101672. * Instantiates a lens flare system.
  101673. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101674. * It is usually composed of several `lensFlare`.
  101675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101676. * @param name Define the name of the lens flare system in the scene
  101677. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  101678. * @param scene Define the scene the lens flare system belongs to
  101679. */
  101680. constructor(
  101681. /**
  101682. * Define the name of the lens flare system
  101683. */
  101684. name: string, emitter: any, scene: Scene);
  101685. /**
  101686. * Define if the lens flare system is enabled.
  101687. */
  101688. isEnabled: boolean;
  101689. /**
  101690. * Get the scene the effects belongs to.
  101691. * @returns the scene holding the lens flare system
  101692. */
  101693. getScene(): Scene;
  101694. /**
  101695. * Get the emitter of the lens flare system.
  101696. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101697. * @returns the emitter of the lens flare system
  101698. */
  101699. getEmitter(): any;
  101700. /**
  101701. * Set the emitter of the lens flare system.
  101702. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101703. * @param newEmitter Define the new emitter of the system
  101704. */
  101705. setEmitter(newEmitter: any): void;
  101706. /**
  101707. * Get the lens flare system emitter position.
  101708. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  101709. * @returns the position
  101710. */
  101711. getEmitterPosition(): Vector3;
  101712. /**
  101713. * @hidden
  101714. */
  101715. computeEffectivePosition(globalViewport: Viewport): boolean;
  101716. /** @hidden */
  101717. _isVisible(): boolean;
  101718. /**
  101719. * @hidden
  101720. */
  101721. render(): boolean;
  101722. /**
  101723. * Dispose and release the lens flare with its associated resources.
  101724. */
  101725. dispose(): void;
  101726. /**
  101727. * Parse a lens flare system from a JSON repressentation
  101728. * @param parsedLensFlareSystem Define the JSON to parse
  101729. * @param scene Define the scene the parsed system should be instantiated in
  101730. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  101731. * @returns the parsed system
  101732. */
  101733. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  101734. /**
  101735. * Serialize the current Lens Flare System into a JSON representation.
  101736. * @returns the serialized JSON
  101737. */
  101738. serialize(): any;
  101739. }
  101740. }
  101741. declare module BABYLON {
  101742. /**
  101743. * This represents one of the lens effect in a `lensFlareSystem`.
  101744. * It controls one of the indiviual texture used in the effect.
  101745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101746. */
  101747. export class LensFlare {
  101748. /**
  101749. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101750. */
  101751. size: number;
  101752. /**
  101753. * 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.
  101754. */
  101755. position: number;
  101756. /**
  101757. * Define the lens color.
  101758. */
  101759. color: Color3;
  101760. /**
  101761. * Define the lens texture.
  101762. */
  101763. texture: Nullable<Texture>;
  101764. /**
  101765. * Define the alpha mode to render this particular lens.
  101766. */
  101767. alphaMode: number;
  101768. private _system;
  101769. /**
  101770. * Creates a new Lens Flare.
  101771. * This represents one of the lens effect in a `lensFlareSystem`.
  101772. * It controls one of the indiviual texture used in the effect.
  101773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101774. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  101775. * @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.
  101776. * @param color Define the lens color
  101777. * @param imgUrl Define the lens texture url
  101778. * @param system Define the `lensFlareSystem` this flare is part of
  101779. * @returns The newly created Lens Flare
  101780. */
  101781. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  101782. /**
  101783. * Instantiates a new Lens Flare.
  101784. * This represents one of the lens effect in a `lensFlareSystem`.
  101785. * It controls one of the indiviual texture used in the effect.
  101786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101787. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  101788. * @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.
  101789. * @param color Define the lens color
  101790. * @param imgUrl Define the lens texture url
  101791. * @param system Define the `lensFlareSystem` this flare is part of
  101792. */
  101793. constructor(
  101794. /**
  101795. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101796. */
  101797. size: number,
  101798. /**
  101799. * 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.
  101800. */
  101801. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101802. /**
  101803. * Dispose and release the lens flare with its associated resources.
  101804. */
  101805. dispose(): void;
  101806. }
  101807. }
  101808. declare module BABYLON {
  101809. interface AbstractScene {
  101810. /**
  101811. * The list of lens flare system added to the scene
  101812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101813. */
  101814. lensFlareSystems: Array<LensFlareSystem>;
  101815. /**
  101816. * Removes the given lens flare system from this scene.
  101817. * @param toRemove The lens flare system to remove
  101818. * @returns The index of the removed lens flare system
  101819. */
  101820. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101821. /**
  101822. * Adds the given lens flare system to this scene
  101823. * @param newLensFlareSystem The lens flare system to add
  101824. */
  101825. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101826. /**
  101827. * Gets a lens flare system using its name
  101828. * @param name defines the name to look for
  101829. * @returns the lens flare system or null if not found
  101830. */
  101831. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101832. /**
  101833. * Gets a lens flare system using its id
  101834. * @param id defines the id to look for
  101835. * @returns the lens flare system or null if not found
  101836. */
  101837. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101838. }
  101839. /**
  101840. * Defines the lens flare scene component responsible to manage any lens flares
  101841. * in a given scene.
  101842. */
  101843. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101844. /**
  101845. * The component name helpfull to identify the component in the list of scene components.
  101846. */
  101847. readonly name: string;
  101848. /**
  101849. * The scene the component belongs to.
  101850. */
  101851. scene: Scene;
  101852. /**
  101853. * Creates a new instance of the component for the given scene
  101854. * @param scene Defines the scene to register the component in
  101855. */
  101856. constructor(scene: Scene);
  101857. /**
  101858. * Registers the component in a given scene
  101859. */
  101860. register(): void;
  101861. /**
  101862. * Rebuilds the elements related to this component in case of
  101863. * context lost for instance.
  101864. */
  101865. rebuild(): void;
  101866. /**
  101867. * Adds all the element from the container to the scene
  101868. * @param container the container holding the elements
  101869. */
  101870. addFromContainer(container: AbstractScene): void;
  101871. /**
  101872. * Removes all the elements in the container from the scene
  101873. * @param container contains the elements to remove
  101874. */
  101875. removeFromContainer(container: AbstractScene): void;
  101876. /**
  101877. * Serializes the component data to the specified json object
  101878. * @param serializationObject The object to serialize to
  101879. */
  101880. serialize(serializationObject: any): void;
  101881. /**
  101882. * Disposes the component and the associated ressources.
  101883. */
  101884. dispose(): void;
  101885. private _draw;
  101886. }
  101887. }
  101888. declare module BABYLON {
  101889. /**
  101890. * Defines the shadow generator component responsible to manage any shadow generators
  101891. * in a given scene.
  101892. */
  101893. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101894. /**
  101895. * The component name helpfull to identify the component in the list of scene components.
  101896. */
  101897. readonly name: string;
  101898. /**
  101899. * The scene the component belongs to.
  101900. */
  101901. scene: Scene;
  101902. /**
  101903. * Creates a new instance of the component for the given scene
  101904. * @param scene Defines the scene to register the component in
  101905. */
  101906. constructor(scene: Scene);
  101907. /**
  101908. * Registers the component in a given scene
  101909. */
  101910. register(): void;
  101911. /**
  101912. * Rebuilds the elements related to this component in case of
  101913. * context lost for instance.
  101914. */
  101915. rebuild(): void;
  101916. /**
  101917. * Serializes the component data to the specified json object
  101918. * @param serializationObject The object to serialize to
  101919. */
  101920. serialize(serializationObject: any): void;
  101921. /**
  101922. * Adds all the element from the container to the scene
  101923. * @param container the container holding the elements
  101924. */
  101925. addFromContainer(container: AbstractScene): void;
  101926. /**
  101927. * Removes all the elements in the container from the scene
  101928. * @param container contains the elements to remove
  101929. */
  101930. removeFromContainer(container: AbstractScene): void;
  101931. /**
  101932. * Rebuilds the elements related to this component in case of
  101933. * context lost for instance.
  101934. */
  101935. dispose(): void;
  101936. private _gatherRenderTargets;
  101937. }
  101938. }
  101939. declare module BABYLON {
  101940. /**
  101941. * A directional light is defined by a direction (what a surprise!).
  101942. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101943. * 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.
  101944. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101945. */
  101946. export class DirectionalLight extends ShadowLight {
  101947. private _shadowFrustumSize;
  101948. /**
  101949. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101950. */
  101951. /**
  101952. * Specifies a fix frustum size for the shadow generation.
  101953. */
  101954. shadowFrustumSize: number;
  101955. private _shadowOrthoScale;
  101956. /**
  101957. * Gets the shadow projection scale against the optimal computed one.
  101958. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101959. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101960. */
  101961. /**
  101962. * Sets the shadow projection scale against the optimal computed one.
  101963. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101964. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101965. */
  101966. shadowOrthoScale: number;
  101967. /**
  101968. * Automatically compute the projection matrix to best fit (including all the casters)
  101969. * on each frame.
  101970. */
  101971. autoUpdateExtends: boolean;
  101972. private _orthoLeft;
  101973. private _orthoRight;
  101974. private _orthoTop;
  101975. private _orthoBottom;
  101976. /**
  101977. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101978. * The directional light is emitted from everywhere in the given direction.
  101979. * It can cast shadows.
  101980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101981. * @param name The friendly name of the light
  101982. * @param direction The direction of the light
  101983. * @param scene The scene the light belongs to
  101984. */
  101985. constructor(name: string, direction: Vector3, scene: Scene);
  101986. /**
  101987. * Returns the string "DirectionalLight".
  101988. * @return The class name
  101989. */
  101990. getClassName(): string;
  101991. /**
  101992. * Returns the integer 1.
  101993. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101994. */
  101995. getTypeID(): number;
  101996. /**
  101997. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101998. * Returns the DirectionalLight Shadow projection matrix.
  101999. */
  102000. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102001. /**
  102002. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102003. * Returns the DirectionalLight Shadow projection matrix.
  102004. */
  102005. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102006. /**
  102007. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102008. * Returns the DirectionalLight Shadow projection matrix.
  102009. */
  102010. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102011. protected _buildUniformLayout(): void;
  102012. /**
  102013. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102014. * @param effect The effect to update
  102015. * @param lightIndex The index of the light in the effect to update
  102016. * @returns The directional light
  102017. */
  102018. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102019. /**
  102020. * Gets the minZ used for shadow according to both the scene and the light.
  102021. *
  102022. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102023. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102024. * @param activeCamera The camera we are returning the min for
  102025. * @returns the depth min z
  102026. */
  102027. getDepthMinZ(activeCamera: Camera): number;
  102028. /**
  102029. * Gets the maxZ used for shadow according to both the scene and the light.
  102030. *
  102031. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102032. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102033. * @param activeCamera The camera we are returning the max for
  102034. * @returns the depth max z
  102035. */
  102036. getDepthMaxZ(activeCamera: Camera): number;
  102037. /**
  102038. * Prepares the list of defines specific to the light type.
  102039. * @param defines the list of defines
  102040. * @param lightIndex defines the index of the light for the effect
  102041. */
  102042. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102043. }
  102044. }
  102045. declare module BABYLON {
  102046. /**
  102047. * A point light is a light defined by an unique point in world space.
  102048. * The light is emitted in every direction from this point.
  102049. * A good example of a point light is a standard light bulb.
  102050. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102051. */
  102052. export class PointLight extends ShadowLight {
  102053. private _shadowAngle;
  102054. /**
  102055. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102056. * This specifies what angle the shadow will use to be created.
  102057. *
  102058. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102059. */
  102060. /**
  102061. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102062. * This specifies what angle the shadow will use to be created.
  102063. *
  102064. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102065. */
  102066. shadowAngle: number;
  102067. /**
  102068. * Gets the direction if it has been set.
  102069. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102070. */
  102071. /**
  102072. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102073. */
  102074. direction: Vector3;
  102075. /**
  102076. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  102077. * A PointLight emits the light in every direction.
  102078. * It can cast shadows.
  102079. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  102080. * ```javascript
  102081. * var pointLight = new PointLight("pl", camera.position, scene);
  102082. * ```
  102083. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102084. * @param name The light friendly name
  102085. * @param position The position of the point light in the scene
  102086. * @param scene The scene the lights belongs to
  102087. */
  102088. constructor(name: string, position: Vector3, scene: Scene);
  102089. /**
  102090. * Returns the string "PointLight"
  102091. * @returns the class name
  102092. */
  102093. getClassName(): string;
  102094. /**
  102095. * Returns the integer 0.
  102096. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102097. */
  102098. getTypeID(): number;
  102099. /**
  102100. * Specifies wether or not the shadowmap should be a cube texture.
  102101. * @returns true if the shadowmap needs to be a cube texture.
  102102. */
  102103. needCube(): boolean;
  102104. /**
  102105. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  102106. * @param faceIndex The index of the face we are computed the direction to generate shadow
  102107. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  102108. */
  102109. getShadowDirection(faceIndex?: number): Vector3;
  102110. /**
  102111. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  102112. * - fov = PI / 2
  102113. * - aspect ratio : 1.0
  102114. * - z-near and far equal to the active camera minZ and maxZ.
  102115. * Returns the PointLight.
  102116. */
  102117. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102118. protected _buildUniformLayout(): void;
  102119. /**
  102120. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  102121. * @param effect The effect to update
  102122. * @param lightIndex The index of the light in the effect to update
  102123. * @returns The point light
  102124. */
  102125. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  102126. /**
  102127. * Prepares the list of defines specific to the light type.
  102128. * @param defines the list of defines
  102129. * @param lightIndex defines the index of the light for the effect
  102130. */
  102131. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102137. * These values define a cone of light starting from the position, emitting toward the direction.
  102138. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102139. * and the exponent defines the speed of the decay of the light with distance (reach).
  102140. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102141. */
  102142. export class SpotLight extends ShadowLight {
  102143. private _angle;
  102144. private _innerAngle;
  102145. private _cosHalfAngle;
  102146. private _lightAngleScale;
  102147. private _lightAngleOffset;
  102148. /**
  102149. * Gets the cone angle of the spot light in Radians.
  102150. */
  102151. /**
  102152. * Sets the cone angle of the spot light in Radians.
  102153. */
  102154. angle: number;
  102155. /**
  102156. * Only used in gltf falloff mode, this defines the angle where
  102157. * the directional falloff will start before cutting at angle which could be seen
  102158. * as outer angle.
  102159. */
  102160. /**
  102161. * Only used in gltf falloff mode, this defines the angle where
  102162. * the directional falloff will start before cutting at angle which could be seen
  102163. * as outer angle.
  102164. */
  102165. innerAngle: number;
  102166. private _shadowAngleScale;
  102167. /**
  102168. * Allows scaling the angle of the light for shadow generation only.
  102169. */
  102170. /**
  102171. * Allows scaling the angle of the light for shadow generation only.
  102172. */
  102173. shadowAngleScale: number;
  102174. /**
  102175. * The light decay speed with the distance from the emission spot.
  102176. */
  102177. exponent: number;
  102178. private _projectionTextureMatrix;
  102179. /**
  102180. * Allows reading the projecton texture
  102181. */
  102182. readonly projectionTextureMatrix: Matrix;
  102183. protected _projectionTextureLightNear: number;
  102184. /**
  102185. * Gets the near clip of the Spotlight for texture projection.
  102186. */
  102187. /**
  102188. * Sets the near clip of the Spotlight for texture projection.
  102189. */
  102190. projectionTextureLightNear: number;
  102191. protected _projectionTextureLightFar: number;
  102192. /**
  102193. * Gets the far clip of the Spotlight for texture projection.
  102194. */
  102195. /**
  102196. * Sets the far clip of the Spotlight for texture projection.
  102197. */
  102198. projectionTextureLightFar: number;
  102199. protected _projectionTextureUpDirection: Vector3;
  102200. /**
  102201. * Gets the Up vector of the Spotlight for texture projection.
  102202. */
  102203. /**
  102204. * Sets the Up vector of the Spotlight for texture projection.
  102205. */
  102206. projectionTextureUpDirection: Vector3;
  102207. private _projectionTexture;
  102208. /**
  102209. * Gets the projection texture of the light.
  102210. */
  102211. /**
  102212. * Sets the projection texture of the light.
  102213. */
  102214. projectionTexture: Nullable<BaseTexture>;
  102215. private _projectionTextureViewLightDirty;
  102216. private _projectionTextureProjectionLightDirty;
  102217. private _projectionTextureDirty;
  102218. private _projectionTextureViewTargetVector;
  102219. private _projectionTextureViewLightMatrix;
  102220. private _projectionTextureProjectionLightMatrix;
  102221. private _projectionTextureScalingMatrix;
  102222. /**
  102223. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102224. * It can cast shadows.
  102225. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102226. * @param name The light friendly name
  102227. * @param position The position of the spot light in the scene
  102228. * @param direction The direction of the light in the scene
  102229. * @param angle The cone angle of the light in Radians
  102230. * @param exponent The light decay speed with the distance from the emission spot
  102231. * @param scene The scene the lights belongs to
  102232. */
  102233. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102234. /**
  102235. * Returns the string "SpotLight".
  102236. * @returns the class name
  102237. */
  102238. getClassName(): string;
  102239. /**
  102240. * Returns the integer 2.
  102241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102242. */
  102243. getTypeID(): number;
  102244. /**
  102245. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102246. */
  102247. protected _setDirection(value: Vector3): void;
  102248. /**
  102249. * Overrides the position setter to recompute the projection texture view light Matrix.
  102250. */
  102251. protected _setPosition(value: Vector3): void;
  102252. /**
  102253. * 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.
  102254. * Returns the SpotLight.
  102255. */
  102256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102257. protected _computeProjectionTextureViewLightMatrix(): void;
  102258. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102259. /**
  102260. * Main function for light texture projection matrix computing.
  102261. */
  102262. protected _computeProjectionTextureMatrix(): void;
  102263. protected _buildUniformLayout(): void;
  102264. private _computeAngleValues;
  102265. /**
  102266. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102267. * @param effect The effect to update
  102268. * @param lightIndex The index of the light in the effect to update
  102269. * @returns The spot light
  102270. */
  102271. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102272. /**
  102273. * Disposes the light and the associated resources.
  102274. */
  102275. dispose(): void;
  102276. /**
  102277. * Prepares the list of defines specific to the light type.
  102278. * @param defines the list of defines
  102279. * @param lightIndex defines the index of the light for the effect
  102280. */
  102281. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102282. }
  102283. }
  102284. declare module BABYLON {
  102285. /**
  102286. * Header information of HDR texture files.
  102287. */
  102288. export interface HDRInfo {
  102289. /**
  102290. * The height of the texture in pixels.
  102291. */
  102292. height: number;
  102293. /**
  102294. * The width of the texture in pixels.
  102295. */
  102296. width: number;
  102297. /**
  102298. * The index of the beginning of the data in the binary file.
  102299. */
  102300. dataPosition: number;
  102301. }
  102302. /**
  102303. * This groups tools to convert HDR texture to native colors array.
  102304. */
  102305. export class HDRTools {
  102306. private static Ldexp;
  102307. private static Rgbe2float;
  102308. private static readStringLine;
  102309. /**
  102310. * Reads header information from an RGBE texture stored in a native array.
  102311. * More information on this format are available here:
  102312. * https://en.wikipedia.org/wiki/RGBE_image_format
  102313. *
  102314. * @param uint8array The binary file stored in native array.
  102315. * @return The header information.
  102316. */
  102317. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  102318. /**
  102319. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  102320. * This RGBE texture needs to store the information as a panorama.
  102321. *
  102322. * More information on this format are available here:
  102323. * https://en.wikipedia.org/wiki/RGBE_image_format
  102324. *
  102325. * @param buffer The binary file stored in an array buffer.
  102326. * @param size The expected size of the extracted cubemap.
  102327. * @return The Cube Map information.
  102328. */
  102329. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  102330. /**
  102331. * Returns the pixels data extracted from an RGBE texture.
  102332. * This pixels will be stored left to right up to down in the R G B order in one array.
  102333. *
  102334. * More information on this format are available here:
  102335. * https://en.wikipedia.org/wiki/RGBE_image_format
  102336. *
  102337. * @param uint8array The binary file stored in an array buffer.
  102338. * @param hdrInfo The header information of the file.
  102339. * @return The pixels data in RGB right to left up to down order.
  102340. */
  102341. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  102342. private static RGBE_ReadPixels_RLE;
  102343. }
  102344. }
  102345. declare module BABYLON {
  102346. /**
  102347. * This represents a texture coming from an HDR input.
  102348. *
  102349. * The only supported format is currently panorama picture stored in RGBE format.
  102350. * Example of such files can be found on HDRLib: http://hdrlib.com/
  102351. */
  102352. export class HDRCubeTexture extends BaseTexture {
  102353. private static _facesMapping;
  102354. private _generateHarmonics;
  102355. private _noMipmap;
  102356. private _textureMatrix;
  102357. private _size;
  102358. private _onLoad;
  102359. private _onError;
  102360. /**
  102361. * The texture URL.
  102362. */
  102363. url: string;
  102364. /**
  102365. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  102366. */
  102367. coordinatesMode: number;
  102368. protected _isBlocking: boolean;
  102369. /**
  102370. * Sets wether or not the texture is blocking during loading.
  102371. */
  102372. /**
  102373. * Gets wether or not the texture is blocking during loading.
  102374. */
  102375. isBlocking: boolean;
  102376. protected _rotationY: number;
  102377. /**
  102378. * Sets texture matrix rotation angle around Y axis in radians.
  102379. */
  102380. /**
  102381. * Gets texture matrix rotation angle around Y axis radians.
  102382. */
  102383. rotationY: number;
  102384. /**
  102385. * Gets or sets the center of the bounding box associated with the cube texture
  102386. * It must define where the camera used to render the texture was set
  102387. */
  102388. boundingBoxPosition: Vector3;
  102389. private _boundingBoxSize;
  102390. /**
  102391. * Gets or sets the size of the bounding box associated with the cube texture
  102392. * When defined, the cubemap will switch to local mode
  102393. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102394. * @example https://www.babylonjs-playground.com/#RNASML
  102395. */
  102396. boundingBoxSize: Vector3;
  102397. /**
  102398. * Instantiates an HDRTexture from the following parameters.
  102399. *
  102400. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  102401. * @param scene The scene the texture will be used in
  102402. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  102403. * @param noMipmap Forces to not generate the mipmap if true
  102404. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  102405. * @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)
  102406. * @param reserved Reserved flag for internal use.
  102407. */
  102408. 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>);
  102409. /**
  102410. * Get the current class name of the texture useful for serialization or dynamic coding.
  102411. * @returns "HDRCubeTexture"
  102412. */
  102413. getClassName(): string;
  102414. /**
  102415. * Occurs when the file is raw .hdr file.
  102416. */
  102417. private loadTexture;
  102418. clone(): HDRCubeTexture;
  102419. delayLoad(): void;
  102420. /**
  102421. * Get the texture reflection matrix used to rotate/transform the reflection.
  102422. * @returns the reflection matrix
  102423. */
  102424. getReflectionTextureMatrix(): Matrix;
  102425. /**
  102426. * Set the texture reflection matrix used to rotate/transform the reflection.
  102427. * @param value Define the reflection matrix to set
  102428. */
  102429. setReflectionTextureMatrix(value: Matrix): void;
  102430. /**
  102431. * Parses a JSON representation of an HDR Texture in order to create the texture
  102432. * @param parsedTexture Define the JSON representation
  102433. * @param scene Define the scene the texture should be created in
  102434. * @param rootUrl Define the root url in case we need to load relative dependencies
  102435. * @returns the newly created texture after parsing
  102436. */
  102437. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  102438. serialize(): any;
  102439. }
  102440. }
  102441. declare module BABYLON {
  102442. /**
  102443. * Class used to control physics engine
  102444. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  102445. */
  102446. export class PhysicsEngine implements IPhysicsEngine {
  102447. private _physicsPlugin;
  102448. /**
  102449. * Global value used to control the smallest number supported by the simulation
  102450. */
  102451. static Epsilon: number;
  102452. private _impostors;
  102453. private _joints;
  102454. /**
  102455. * Gets the gravity vector used by the simulation
  102456. */
  102457. gravity: Vector3;
  102458. /**
  102459. * Factory used to create the default physics plugin.
  102460. * @returns The default physics plugin
  102461. */
  102462. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  102463. /**
  102464. * Creates a new Physics Engine
  102465. * @param gravity defines the gravity vector used by the simulation
  102466. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  102467. */
  102468. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  102469. /**
  102470. * Sets the gravity vector used by the simulation
  102471. * @param gravity defines the gravity vector to use
  102472. */
  102473. setGravity(gravity: Vector3): void;
  102474. /**
  102475. * Set the time step of the physics engine.
  102476. * Default is 1/60.
  102477. * To slow it down, enter 1/600 for example.
  102478. * To speed it up, 1/30
  102479. * @param newTimeStep defines the new timestep to apply to this world.
  102480. */
  102481. setTimeStep(newTimeStep?: number): void;
  102482. /**
  102483. * Get the time step of the physics engine.
  102484. * @returns the current time step
  102485. */
  102486. getTimeStep(): number;
  102487. /**
  102488. * Release all resources
  102489. */
  102490. dispose(): void;
  102491. /**
  102492. * Gets the name of the current physics plugin
  102493. * @returns the name of the plugin
  102494. */
  102495. getPhysicsPluginName(): string;
  102496. /**
  102497. * Adding a new impostor for the impostor tracking.
  102498. * This will be done by the impostor itself.
  102499. * @param impostor the impostor to add
  102500. */
  102501. addImpostor(impostor: PhysicsImpostor): void;
  102502. /**
  102503. * Remove an impostor from the engine.
  102504. * This impostor and its mesh will not longer be updated by the physics engine.
  102505. * @param impostor the impostor to remove
  102506. */
  102507. removeImpostor(impostor: PhysicsImpostor): void;
  102508. /**
  102509. * Add a joint to the physics engine
  102510. * @param mainImpostor defines the main impostor to which the joint is added.
  102511. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  102512. * @param joint defines the joint that will connect both impostors.
  102513. */
  102514. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102515. /**
  102516. * Removes a joint from the simulation
  102517. * @param mainImpostor defines the impostor used with the joint
  102518. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  102519. * @param joint defines the joint to remove
  102520. */
  102521. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102522. /**
  102523. * Called by the scene. No need to call it.
  102524. * @param delta defines the timespam between frames
  102525. */
  102526. _step(delta: number): void;
  102527. /**
  102528. * Gets the current plugin used to run the simulation
  102529. * @returns current plugin
  102530. */
  102531. getPhysicsPlugin(): IPhysicsEnginePlugin;
  102532. /**
  102533. * Gets the list of physic impostors
  102534. * @returns an array of PhysicsImpostor
  102535. */
  102536. getImpostors(): Array<PhysicsImpostor>;
  102537. /**
  102538. * Gets the impostor for a physics enabled object
  102539. * @param object defines the object impersonated by the impostor
  102540. * @returns the PhysicsImpostor or null if not found
  102541. */
  102542. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  102543. /**
  102544. * Gets the impostor for a physics body object
  102545. * @param body defines physics body used by the impostor
  102546. * @returns the PhysicsImpostor or null if not found
  102547. */
  102548. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  102549. }
  102550. }
  102551. declare module BABYLON {
  102552. /** @hidden */
  102553. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  102554. private _useDeltaForWorldStep;
  102555. world: any;
  102556. name: string;
  102557. private _physicsMaterials;
  102558. private _fixedTimeStep;
  102559. BJSCANNON: any;
  102560. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  102561. setGravity(gravity: Vector3): void;
  102562. setTimeStep(timeStep: number): void;
  102563. getTimeStep(): number;
  102564. executeStep(delta: number): void;
  102565. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102566. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102567. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102568. private _processChildMeshes;
  102569. removePhysicsBody(impostor: PhysicsImpostor): void;
  102570. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102571. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102572. private _addMaterial;
  102573. private _checkWithEpsilon;
  102574. private _createShape;
  102575. private _createHeightmap;
  102576. private _minus90X;
  102577. private _plus90X;
  102578. private _tmpPosition;
  102579. private _tmpDeltaPosition;
  102580. private _tmpUnityRotation;
  102581. private _updatePhysicsBodyTransformation;
  102582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102583. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102584. isSupported(): boolean;
  102585. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102586. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102587. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102588. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102590. getBodyMass(impostor: PhysicsImpostor): number;
  102591. getBodyFriction(impostor: PhysicsImpostor): number;
  102592. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102593. getBodyRestitution(impostor: PhysicsImpostor): number;
  102594. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102595. sleepBody(impostor: PhysicsImpostor): void;
  102596. wakeUpBody(impostor: PhysicsImpostor): void;
  102597. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  102598. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  102599. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  102600. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102601. getRadius(impostor: PhysicsImpostor): number;
  102602. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102603. dispose(): void;
  102604. private _extendNamespace;
  102605. }
  102606. }
  102607. declare module BABYLON {
  102608. /** @hidden */
  102609. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  102610. world: any;
  102611. name: string;
  102612. BJSOIMO: any;
  102613. constructor(iterations?: number, oimoInjection?: any);
  102614. setGravity(gravity: Vector3): void;
  102615. setTimeStep(timeStep: number): void;
  102616. getTimeStep(): number;
  102617. private _tmpImpostorsArray;
  102618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  102619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102620. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102622. private _tmpPositionVector;
  102623. removePhysicsBody(impostor: PhysicsImpostor): void;
  102624. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102625. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102626. isSupported(): boolean;
  102627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102628. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102634. getBodyMass(impostor: PhysicsImpostor): number;
  102635. getBodyFriction(impostor: PhysicsImpostor): number;
  102636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102637. getBodyRestitution(impostor: PhysicsImpostor): number;
  102638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102639. sleepBody(impostor: PhysicsImpostor): void;
  102640. wakeUpBody(impostor: PhysicsImpostor): void;
  102641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  102642. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  102643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  102644. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102645. getRadius(impostor: PhysicsImpostor): number;
  102646. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102647. dispose(): void;
  102648. }
  102649. }
  102650. declare module BABYLON {
  102651. interface AbstractScene {
  102652. /**
  102653. * The list of reflection probes added to the scene
  102654. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102655. */
  102656. reflectionProbes: Array<ReflectionProbe>;
  102657. /**
  102658. * Removes the given reflection probe from this scene.
  102659. * @param toRemove The reflection probe to remove
  102660. * @returns The index of the removed reflection probe
  102661. */
  102662. removeReflectionProbe(toRemove: ReflectionProbe): number;
  102663. /**
  102664. * Adds the given reflection probe to this scene.
  102665. * @param newReflectionProbe The reflection probe to add
  102666. */
  102667. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  102668. }
  102669. /**
  102670. * Class used to generate realtime reflection / refraction cube textures
  102671. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102672. */
  102673. export class ReflectionProbe {
  102674. /** defines the name of the probe */
  102675. name: string;
  102676. private _scene;
  102677. private _renderTargetTexture;
  102678. private _projectionMatrix;
  102679. private _viewMatrix;
  102680. private _target;
  102681. private _add;
  102682. private _attachedMesh;
  102683. private _invertYAxis;
  102684. /** Gets or sets probe position (center of the cube map) */
  102685. position: Vector3;
  102686. /**
  102687. * Creates a new reflection probe
  102688. * @param name defines the name of the probe
  102689. * @param size defines the texture resolution (for each face)
  102690. * @param scene defines the hosting scene
  102691. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  102692. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  102693. */
  102694. constructor(
  102695. /** defines the name of the probe */
  102696. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  102697. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  102698. samples: number;
  102699. /** Gets or sets the refresh rate to use (on every frame by default) */
  102700. refreshRate: number;
  102701. /**
  102702. * Gets the hosting scene
  102703. * @returns a Scene
  102704. */
  102705. getScene(): Scene;
  102706. /** Gets the internal CubeTexture used to render to */
  102707. readonly cubeTexture: RenderTargetTexture;
  102708. /** Gets the list of meshes to render */
  102709. readonly renderList: Nullable<AbstractMesh[]>;
  102710. /**
  102711. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  102712. * @param mesh defines the mesh to attach to
  102713. */
  102714. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102715. /**
  102716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  102717. * @param renderingGroupId The rendering group id corresponding to its index
  102718. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102719. */
  102720. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102721. /**
  102722. * Clean all associated resources
  102723. */
  102724. dispose(): void;
  102725. /**
  102726. * Converts the reflection probe information to a readable string for debug purpose.
  102727. * @param fullDetails Supports for multiple levels of logging within scene loading
  102728. * @returns the human readable reflection probe info
  102729. */
  102730. toString(fullDetails?: boolean): string;
  102731. /**
  102732. * Get the class name of the relfection probe.
  102733. * @returns "ReflectionProbe"
  102734. */
  102735. getClassName(): string;
  102736. /**
  102737. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  102738. * @returns The JSON representation of the texture
  102739. */
  102740. serialize(): any;
  102741. /**
  102742. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  102743. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  102744. * @param scene Define the scene the parsed reflection probe should be instantiated in
  102745. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102746. * @returns The parsed reflection probe if successful
  102747. */
  102748. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  102749. }
  102750. }
  102751. declare module BABYLON {
  102752. /** @hidden */
  102753. export var _BabylonLoaderRegistered: boolean;
  102754. }
  102755. declare module BABYLON {
  102756. /**
  102757. * The Physically based simple base material of BJS.
  102758. *
  102759. * This enables better naming and convention enforcements on top of the pbrMaterial.
  102760. * It is used as the base class for both the specGloss and metalRough conventions.
  102761. */
  102762. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  102763. /**
  102764. * Number of Simultaneous lights allowed on the material.
  102765. */
  102766. maxSimultaneousLights: number;
  102767. /**
  102768. * If sets to true, disables all the lights affecting the material.
  102769. */
  102770. disableLighting: boolean;
  102771. /**
  102772. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  102773. */
  102774. environmentTexture: BaseTexture;
  102775. /**
  102776. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102777. */
  102778. invertNormalMapX: boolean;
  102779. /**
  102780. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102781. */
  102782. invertNormalMapY: boolean;
  102783. /**
  102784. * Normal map used in the model.
  102785. */
  102786. normalTexture: BaseTexture;
  102787. /**
  102788. * Emissivie color used to self-illuminate the model.
  102789. */
  102790. emissiveColor: Color3;
  102791. /**
  102792. * Emissivie texture used to self-illuminate the model.
  102793. */
  102794. emissiveTexture: BaseTexture;
  102795. /**
  102796. * Occlusion Channel Strenght.
  102797. */
  102798. occlusionStrength: number;
  102799. /**
  102800. * Occlusion Texture of the material (adding extra occlusion effects).
  102801. */
  102802. occlusionTexture: BaseTexture;
  102803. /**
  102804. * Defines the alpha limits in alpha test mode.
  102805. */
  102806. alphaCutOff: number;
  102807. /**
  102808. * Gets the current double sided mode.
  102809. */
  102810. /**
  102811. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102812. */
  102813. doubleSided: boolean;
  102814. /**
  102815. * Stores the pre-calculated light information of a mesh in a texture.
  102816. */
  102817. lightmapTexture: BaseTexture;
  102818. /**
  102819. * If true, the light map contains occlusion information instead of lighting info.
  102820. */
  102821. useLightmapAsShadowmap: boolean;
  102822. /**
  102823. * Instantiates a new PBRMaterial instance.
  102824. *
  102825. * @param name The material name
  102826. * @param scene The scene the material will be use in.
  102827. */
  102828. constructor(name: string, scene: Scene);
  102829. getClassName(): string;
  102830. }
  102831. }
  102832. declare module BABYLON {
  102833. /**
  102834. * The PBR material of BJS following the metal roughness convention.
  102835. *
  102836. * This fits to the PBR convention in the GLTF definition:
  102837. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102838. */
  102839. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102840. /**
  102841. * The base color has two different interpretations depending on the value of metalness.
  102842. * When the material is a metal, the base color is the specific measured reflectance value
  102843. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102844. * of the material.
  102845. */
  102846. baseColor: Color3;
  102847. /**
  102848. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102849. * well as opacity information in the alpha channel.
  102850. */
  102851. baseTexture: BaseTexture;
  102852. /**
  102853. * Specifies the metallic scalar value of the material.
  102854. * Can also be used to scale the metalness values of the metallic texture.
  102855. */
  102856. metallic: number;
  102857. /**
  102858. * Specifies the roughness scalar value of the material.
  102859. * Can also be used to scale the roughness values of the metallic texture.
  102860. */
  102861. roughness: number;
  102862. /**
  102863. * Texture containing both the metallic value in the B channel and the
  102864. * roughness value in the G channel to keep better precision.
  102865. */
  102866. metallicRoughnessTexture: BaseTexture;
  102867. /**
  102868. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102869. *
  102870. * @param name The material name
  102871. * @param scene The scene the material will be use in.
  102872. */
  102873. constructor(name: string, scene: Scene);
  102874. /**
  102875. * Return the currrent class name of the material.
  102876. */
  102877. getClassName(): string;
  102878. /**
  102879. * Makes a duplicate of the current material.
  102880. * @param name - name to use for the new material.
  102881. */
  102882. clone(name: string): PBRMetallicRoughnessMaterial;
  102883. /**
  102884. * Serialize the material to a parsable JSON object.
  102885. */
  102886. serialize(): any;
  102887. /**
  102888. * Parses a JSON object correponding to the serialize function.
  102889. */
  102890. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102891. }
  102892. }
  102893. declare module BABYLON {
  102894. /**
  102895. * The PBR material of BJS following the specular glossiness convention.
  102896. *
  102897. * This fits to the PBR convention in the GLTF definition:
  102898. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102899. */
  102900. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102901. /**
  102902. * Specifies the diffuse color of the material.
  102903. */
  102904. diffuseColor: Color3;
  102905. /**
  102906. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102907. * channel.
  102908. */
  102909. diffuseTexture: BaseTexture;
  102910. /**
  102911. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102912. */
  102913. specularColor: Color3;
  102914. /**
  102915. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102916. */
  102917. glossiness: number;
  102918. /**
  102919. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102920. */
  102921. specularGlossinessTexture: BaseTexture;
  102922. /**
  102923. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102924. *
  102925. * @param name The material name
  102926. * @param scene The scene the material will be use in.
  102927. */
  102928. constructor(name: string, scene: Scene);
  102929. /**
  102930. * Return the currrent class name of the material.
  102931. */
  102932. getClassName(): string;
  102933. /**
  102934. * Makes a duplicate of the current material.
  102935. * @param name - name to use for the new material.
  102936. */
  102937. clone(name: string): PBRSpecularGlossinessMaterial;
  102938. /**
  102939. * Serialize the material to a parsable JSON object.
  102940. */
  102941. serialize(): any;
  102942. /**
  102943. * Parses a JSON object correponding to the serialize function.
  102944. */
  102945. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102946. }
  102947. }
  102948. declare module BABYLON {
  102949. /**
  102950. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102951. * It can help converting any input color in a desired output one. This can then be used to create effects
  102952. * from sepia, black and white to sixties or futuristic rendering...
  102953. *
  102954. * The only supported format is currently 3dl.
  102955. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102956. */
  102957. export class ColorGradingTexture extends BaseTexture {
  102958. /**
  102959. * The current texture matrix. (will always be identity in color grading texture)
  102960. */
  102961. private _textureMatrix;
  102962. /**
  102963. * The texture URL.
  102964. */
  102965. url: string;
  102966. /**
  102967. * Empty line regex stored for GC.
  102968. */
  102969. private static _noneEmptyLineRegex;
  102970. private _engine;
  102971. /**
  102972. * Instantiates a ColorGradingTexture from the following parameters.
  102973. *
  102974. * @param url The location of the color gradind data (currently only supporting 3dl)
  102975. * @param scene The scene the texture will be used in
  102976. */
  102977. constructor(url: string, scene: Scene);
  102978. /**
  102979. * Returns the texture matrix used in most of the material.
  102980. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102981. */
  102982. getTextureMatrix(): Matrix;
  102983. /**
  102984. * Occurs when the file being loaded is a .3dl LUT file.
  102985. */
  102986. private load3dlTexture;
  102987. /**
  102988. * Starts the loading process of the texture.
  102989. */
  102990. private loadTexture;
  102991. /**
  102992. * Clones the color gradind texture.
  102993. */
  102994. clone(): ColorGradingTexture;
  102995. /**
  102996. * Called during delayed load for textures.
  102997. */
  102998. delayLoad(): void;
  102999. /**
  103000. * Parses a color grading texture serialized by Babylon.
  103001. * @param parsedTexture The texture information being parsedTexture
  103002. * @param scene The scene to load the texture in
  103003. * @param rootUrl The root url of the data assets to load
  103004. * @return A color gradind texture
  103005. */
  103006. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103007. /**
  103008. * Serializes the LUT texture to json format.
  103009. */
  103010. serialize(): any;
  103011. }
  103012. }
  103013. declare module BABYLON {
  103014. /**
  103015. * Direct draw surface info
  103016. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103017. */
  103018. export interface DDSInfo {
  103019. /**
  103020. * Width of the texture
  103021. */
  103022. width: number;
  103023. /**
  103024. * Width of the texture
  103025. */
  103026. height: number;
  103027. /**
  103028. * Number of Mipmaps for the texture
  103029. * @see https://en.wikipedia.org/wiki/Mipmap
  103030. */
  103031. mipmapCount: number;
  103032. /**
  103033. * If the textures format is a known fourCC format
  103034. * @see https://www.fourcc.org/
  103035. */
  103036. isFourCC: boolean;
  103037. /**
  103038. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103039. */
  103040. isRGB: boolean;
  103041. /**
  103042. * If the texture is a lumincance format
  103043. */
  103044. isLuminance: boolean;
  103045. /**
  103046. * If this is a cube texture
  103047. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103048. */
  103049. isCube: boolean;
  103050. /**
  103051. * If the texture is a compressed format eg. FOURCC_DXT1
  103052. */
  103053. isCompressed: boolean;
  103054. /**
  103055. * The dxgiFormat of the texture
  103056. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103057. */
  103058. dxgiFormat: number;
  103059. /**
  103060. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103061. */
  103062. textureType: number;
  103063. /**
  103064. * Sphericle polynomial created for the dds texture
  103065. */
  103066. sphericalPolynomial?: SphericalPolynomial;
  103067. }
  103068. /**
  103069. * Class used to provide DDS decompression tools
  103070. */
  103071. export class DDSTools {
  103072. /**
  103073. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103074. */
  103075. static StoreLODInAlphaChannel: boolean;
  103076. /**
  103077. * Gets DDS information from an array buffer
  103078. * @param arrayBuffer defines the array buffer to read data from
  103079. * @returns the DDS information
  103080. */
  103081. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103082. private static _FloatView;
  103083. private static _Int32View;
  103084. private static _ToHalfFloat;
  103085. private static _FromHalfFloat;
  103086. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103087. private static _GetHalfFloatRGBAArrayBuffer;
  103088. private static _GetFloatRGBAArrayBuffer;
  103089. private static _GetFloatAsUIntRGBAArrayBuffer;
  103090. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103091. private static _GetRGBAArrayBuffer;
  103092. private static _ExtractLongWordOrder;
  103093. private static _GetRGBArrayBuffer;
  103094. private static _GetLuminanceArrayBuffer;
  103095. /**
  103096. * Uploads DDS Levels to a Babylon Texture
  103097. * @hidden
  103098. */
  103099. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103100. }
  103101. interface Engine {
  103102. /**
  103103. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103104. * @param rootUrl defines the url where the file to load is located
  103105. * @param scene defines the current scene
  103106. * @param lodScale defines scale to apply to the mip map selection
  103107. * @param lodOffset defines offset to apply to the mip map selection
  103108. * @param onLoad defines an optional callback raised when the texture is loaded
  103109. * @param onError defines an optional callback raised if there is an issue to load the texture
  103110. * @param format defines the format of the data
  103111. * @param forcedExtension defines the extension to use to pick the right loader
  103112. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103113. * @returns the cube texture as an InternalTexture
  103114. */
  103115. 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;
  103116. }
  103117. }
  103118. declare module BABYLON {
  103119. /**
  103120. * Implementation of the DDS Texture Loader.
  103121. * @hidden
  103122. */
  103123. export class _DDSTextureLoader implements IInternalTextureLoader {
  103124. /**
  103125. * Defines wether the loader supports cascade loading the different faces.
  103126. */
  103127. readonly supportCascades: boolean;
  103128. /**
  103129. * This returns if the loader support the current file information.
  103130. * @param extension defines the file extension of the file being loaded
  103131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103132. * @param fallback defines the fallback internal texture if any
  103133. * @param isBase64 defines whether the texture is encoded as a base64
  103134. * @param isBuffer defines whether the texture data are stored as a buffer
  103135. * @returns true if the loader can load the specified file
  103136. */
  103137. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103138. /**
  103139. * Transform the url before loading if required.
  103140. * @param rootUrl the url of the texture
  103141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103142. * @returns the transformed texture
  103143. */
  103144. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103145. /**
  103146. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103147. * @param rootUrl the url of the texture
  103148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103149. * @returns the fallback texture
  103150. */
  103151. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103152. /**
  103153. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103154. * @param data contains the texture data
  103155. * @param texture defines the BabylonJS internal texture
  103156. * @param createPolynomials will be true if polynomials have been requested
  103157. * @param onLoad defines the callback to trigger once the texture is ready
  103158. * @param onError defines the callback to trigger in case of error
  103159. */
  103160. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103161. /**
  103162. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103163. * @param data contains the texture data
  103164. * @param texture defines the BabylonJS internal texture
  103165. * @param callback defines the method to call once ready to upload
  103166. */
  103167. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /** @hidden */
  103172. export var rgbdEncodePixelShader: {
  103173. name: string;
  103174. shader: string;
  103175. };
  103176. }
  103177. declare module BABYLON {
  103178. /** @hidden */
  103179. export var rgbdDecodePixelShader: {
  103180. name: string;
  103181. shader: string;
  103182. };
  103183. }
  103184. declare module BABYLON {
  103185. /**
  103186. * Raw texture data and descriptor sufficient for WebGL texture upload
  103187. */
  103188. export interface EnvironmentTextureInfo {
  103189. /**
  103190. * Version of the environment map
  103191. */
  103192. version: number;
  103193. /**
  103194. * Width of image
  103195. */
  103196. width: number;
  103197. /**
  103198. * Irradiance information stored in the file.
  103199. */
  103200. irradiance: any;
  103201. /**
  103202. * Specular information stored in the file.
  103203. */
  103204. specular: any;
  103205. }
  103206. /**
  103207. * Sets of helpers addressing the serialization and deserialization of environment texture
  103208. * stored in a BabylonJS env file.
  103209. * Those files are usually stored as .env files.
  103210. */
  103211. export class EnvironmentTextureTools {
  103212. /**
  103213. * Magic number identifying the env file.
  103214. */
  103215. private static _MagicBytes;
  103216. /**
  103217. * Gets the environment info from an env file.
  103218. * @param data The array buffer containing the .env bytes.
  103219. * @returns the environment file info (the json header) if successfully parsed.
  103220. */
  103221. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103222. /**
  103223. * Creates an environment texture from a loaded cube texture.
  103224. * @param texture defines the cube texture to convert in env file
  103225. * @return a promise containing the environment data if succesfull.
  103226. */
  103227. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103228. /**
  103229. * Creates a JSON representation of the spherical data.
  103230. * @param texture defines the texture containing the polynomials
  103231. * @return the JSON representation of the spherical info
  103232. */
  103233. private static _CreateEnvTextureIrradiance;
  103234. /**
  103235. * Uploads the texture info contained in the env file to the GPU.
  103236. * @param texture defines the internal texture to upload to
  103237. * @param arrayBuffer defines the buffer cotaining the data to load
  103238. * @param info defines the texture info retrieved through the GetEnvInfo method
  103239. * @returns a promise
  103240. */
  103241. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103242. /**
  103243. * Uploads the levels of image data to the GPU.
  103244. * @param texture defines the internal texture to upload to
  103245. * @param imageData defines the array buffer views of image data [mipmap][face]
  103246. * @returns a promise
  103247. */
  103248. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103249. /**
  103250. * Uploads spherical polynomials information to the texture.
  103251. * @param texture defines the texture we are trying to upload the information to
  103252. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103253. */
  103254. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103255. /** @hidden */
  103256. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103257. }
  103258. }
  103259. declare module BABYLON {
  103260. /**
  103261. * Implementation of the ENV Texture Loader.
  103262. * @hidden
  103263. */
  103264. export class _ENVTextureLoader implements IInternalTextureLoader {
  103265. /**
  103266. * Defines wether the loader supports cascade loading the different faces.
  103267. */
  103268. readonly supportCascades: boolean;
  103269. /**
  103270. * This returns if the loader support the current file information.
  103271. * @param extension defines the file extension of the file being loaded
  103272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103273. * @param fallback defines the fallback internal texture if any
  103274. * @param isBase64 defines whether the texture is encoded as a base64
  103275. * @param isBuffer defines whether the texture data are stored as a buffer
  103276. * @returns true if the loader can load the specified file
  103277. */
  103278. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103279. /**
  103280. * Transform the url before loading if required.
  103281. * @param rootUrl the url of the texture
  103282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103283. * @returns the transformed texture
  103284. */
  103285. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103286. /**
  103287. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103288. * @param rootUrl the url of the texture
  103289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103290. * @returns the fallback texture
  103291. */
  103292. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103293. /**
  103294. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103295. * @param data contains the texture data
  103296. * @param texture defines the BabylonJS internal texture
  103297. * @param createPolynomials will be true if polynomials have been requested
  103298. * @param onLoad defines the callback to trigger once the texture is ready
  103299. * @param onError defines the callback to trigger in case of error
  103300. */
  103301. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103302. /**
  103303. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103304. * @param data contains the texture data
  103305. * @param texture defines the BabylonJS internal texture
  103306. * @param callback defines the method to call once ready to upload
  103307. */
  103308. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103309. }
  103310. }
  103311. declare module BABYLON {
  103312. /**
  103313. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103314. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103315. */
  103316. export class KhronosTextureContainer {
  103317. /** contents of the KTX container file */
  103318. arrayBuffer: any;
  103319. private static HEADER_LEN;
  103320. private static COMPRESSED_2D;
  103321. private static COMPRESSED_3D;
  103322. private static TEX_2D;
  103323. private static TEX_3D;
  103324. /**
  103325. * Gets the openGL type
  103326. */
  103327. glType: number;
  103328. /**
  103329. * Gets the openGL type size
  103330. */
  103331. glTypeSize: number;
  103332. /**
  103333. * Gets the openGL format
  103334. */
  103335. glFormat: number;
  103336. /**
  103337. * Gets the openGL internal format
  103338. */
  103339. glInternalFormat: number;
  103340. /**
  103341. * Gets the base internal format
  103342. */
  103343. glBaseInternalFormat: number;
  103344. /**
  103345. * Gets image width in pixel
  103346. */
  103347. pixelWidth: number;
  103348. /**
  103349. * Gets image height in pixel
  103350. */
  103351. pixelHeight: number;
  103352. /**
  103353. * Gets image depth in pixels
  103354. */
  103355. pixelDepth: number;
  103356. /**
  103357. * Gets the number of array elements
  103358. */
  103359. numberOfArrayElements: number;
  103360. /**
  103361. * Gets the number of faces
  103362. */
  103363. numberOfFaces: number;
  103364. /**
  103365. * Gets the number of mipmap levels
  103366. */
  103367. numberOfMipmapLevels: number;
  103368. /**
  103369. * Gets the bytes of key value data
  103370. */
  103371. bytesOfKeyValueData: number;
  103372. /**
  103373. * Gets the load type
  103374. */
  103375. loadType: number;
  103376. /**
  103377. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103378. */
  103379. isInvalid: boolean;
  103380. /**
  103381. * Creates a new KhronosTextureContainer
  103382. * @param arrayBuffer contents of the KTX container file
  103383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103386. */
  103387. constructor(
  103388. /** contents of the KTX container file */
  103389. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103390. /**
  103391. * Uploads KTX content to a Babylon Texture.
  103392. * It is assumed that the texture has already been created & is currently bound
  103393. * @hidden
  103394. */
  103395. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103396. private _upload2DCompressedLevels;
  103397. }
  103398. }
  103399. declare module BABYLON {
  103400. /**
  103401. * Implementation of the KTX Texture Loader.
  103402. * @hidden
  103403. */
  103404. export class _KTXTextureLoader implements IInternalTextureLoader {
  103405. /**
  103406. * Defines wether the loader supports cascade loading the different faces.
  103407. */
  103408. readonly supportCascades: boolean;
  103409. /**
  103410. * This returns if the loader support the current file information.
  103411. * @param extension defines the file extension of the file being loaded
  103412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103413. * @param fallback defines the fallback internal texture if any
  103414. * @param isBase64 defines whether the texture is encoded as a base64
  103415. * @param isBuffer defines whether the texture data are stored as a buffer
  103416. * @returns true if the loader can load the specified file
  103417. */
  103418. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103419. /**
  103420. * Transform the url before loading if required.
  103421. * @param rootUrl the url of the texture
  103422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103423. * @returns the transformed texture
  103424. */
  103425. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103426. /**
  103427. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103428. * @param rootUrl the url of the texture
  103429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103430. * @returns the fallback texture
  103431. */
  103432. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103433. /**
  103434. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103435. * @param data contains the texture data
  103436. * @param texture defines the BabylonJS internal texture
  103437. * @param createPolynomials will be true if polynomials have been requested
  103438. * @param onLoad defines the callback to trigger once the texture is ready
  103439. * @param onError defines the callback to trigger in case of error
  103440. */
  103441. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103442. /**
  103443. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103444. * @param data contains the texture data
  103445. * @param texture defines the BabylonJS internal texture
  103446. * @param callback defines the method to call once ready to upload
  103447. */
  103448. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103449. }
  103450. }
  103451. declare module BABYLON {
  103452. /**
  103453. * Based on jsTGALoader - Javascript loader for TGA file
  103454. * By Vincent Thibault
  103455. * @see http://blog.robrowser.com/javascript-tga-loader.html
  103456. */
  103457. export class TGATools {
  103458. private static _TYPE_INDEXED;
  103459. private static _TYPE_RGB;
  103460. private static _TYPE_GREY;
  103461. private static _TYPE_RLE_INDEXED;
  103462. private static _TYPE_RLE_RGB;
  103463. private static _TYPE_RLE_GREY;
  103464. private static _ORIGIN_MASK;
  103465. private static _ORIGIN_SHIFT;
  103466. private static _ORIGIN_BL;
  103467. private static _ORIGIN_BR;
  103468. private static _ORIGIN_UL;
  103469. private static _ORIGIN_UR;
  103470. /**
  103471. * Gets the header of a TGA file
  103472. * @param data defines the TGA data
  103473. * @returns the header
  103474. */
  103475. static GetTGAHeader(data: Uint8Array): any;
  103476. /**
  103477. * Uploads TGA content to a Babylon Texture
  103478. * @hidden
  103479. */
  103480. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  103481. /** @hidden */
  103482. 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;
  103483. /** @hidden */
  103484. 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;
  103485. /** @hidden */
  103486. 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;
  103487. /** @hidden */
  103488. 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;
  103489. /** @hidden */
  103490. 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;
  103491. /** @hidden */
  103492. 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;
  103493. }
  103494. }
  103495. declare module BABYLON {
  103496. /**
  103497. * Implementation of the TGA Texture Loader.
  103498. * @hidden
  103499. */
  103500. export class _TGATextureLoader implements IInternalTextureLoader {
  103501. /**
  103502. * Defines wether the loader supports cascade loading the different faces.
  103503. */
  103504. readonly supportCascades: boolean;
  103505. /**
  103506. * This returns if the loader support the current file information.
  103507. * @param extension defines the file extension of the file being loaded
  103508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103509. * @param fallback defines the fallback internal texture if any
  103510. * @param isBase64 defines whether the texture is encoded as a base64
  103511. * @param isBuffer defines whether the texture data are stored as a buffer
  103512. * @returns true if the loader can load the specified file
  103513. */
  103514. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103515. /**
  103516. * Transform the url before loading if required.
  103517. * @param rootUrl the url of the texture
  103518. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103519. * @returns the transformed texture
  103520. */
  103521. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103522. /**
  103523. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103524. * @param rootUrl the url of the texture
  103525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103526. * @returns the fallback texture
  103527. */
  103528. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103529. /**
  103530. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103531. * @param data contains the texture data
  103532. * @param texture defines the BabylonJS internal texture
  103533. * @param createPolynomials will be true if polynomials have been requested
  103534. * @param onLoad defines the callback to trigger once the texture is ready
  103535. * @param onError defines the callback to trigger in case of error
  103536. */
  103537. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103538. /**
  103539. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103540. * @param data contains the texture data
  103541. * @param texture defines the BabylonJS internal texture
  103542. * @param callback defines the method to call once ready to upload
  103543. */
  103544. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103545. }
  103546. }
  103547. declare module BABYLON {
  103548. /**
  103549. * 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.
  103550. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103551. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103552. */
  103553. export class CustomProceduralTexture extends ProceduralTexture {
  103554. private _animate;
  103555. private _time;
  103556. private _config;
  103557. private _texturePath;
  103558. /**
  103559. * Instantiates a new Custom Procedural Texture.
  103560. * 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.
  103561. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103563. * @param name Define the name of the texture
  103564. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  103565. * @param size Define the size of the texture to create
  103566. * @param scene Define the scene the texture belongs to
  103567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  103568. * @param generateMipMaps Define if the texture should creates mip maps or not
  103569. */
  103570. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103571. private _loadJson;
  103572. /**
  103573. * Is the texture ready to be used ? (rendered at least once)
  103574. * @returns true if ready, otherwise, false.
  103575. */
  103576. isReady(): boolean;
  103577. /**
  103578. * Render the texture to its associated render target.
  103579. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  103580. */
  103581. render(useCameraPostProcess?: boolean): void;
  103582. /**
  103583. * Update the list of dependant textures samplers in the shader.
  103584. */
  103585. updateTextures(): void;
  103586. /**
  103587. * Update the uniform values of the procedural texture in the shader.
  103588. */
  103589. updateShaderUniforms(): void;
  103590. /**
  103591. * Define if the texture animates or not.
  103592. */
  103593. animate: boolean;
  103594. }
  103595. }
  103596. declare module BABYLON {
  103597. /** @hidden */
  103598. export var noisePixelShader: {
  103599. name: string;
  103600. shader: string;
  103601. };
  103602. }
  103603. declare module BABYLON {
  103604. /**
  103605. * Class used to generate noise procedural textures
  103606. */
  103607. export class NoiseProceduralTexture extends ProceduralTexture {
  103608. private _time;
  103609. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  103610. brightness: number;
  103611. /** Defines the number of octaves to process */
  103612. octaves: number;
  103613. /** Defines the level of persistence (0.8 by default) */
  103614. persistence: number;
  103615. /** Gets or sets animation speed factor (default is 1) */
  103616. animationSpeedFactor: number;
  103617. /**
  103618. * Creates a new NoiseProceduralTexture
  103619. * @param name defines the name fo the texture
  103620. * @param size defines the size of the texture (default is 256)
  103621. * @param scene defines the hosting scene
  103622. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  103623. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  103624. */
  103625. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103626. private _updateShaderUniforms;
  103627. protected _getDefines(): string;
  103628. /** Generate the current state of the procedural texture */
  103629. render(useCameraPostProcess?: boolean): void;
  103630. /**
  103631. * Serializes this noise procedural texture
  103632. * @returns a serialized noise procedural texture object
  103633. */
  103634. serialize(): any;
  103635. /**
  103636. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  103637. * @param parsedTexture defines parsed texture data
  103638. * @param scene defines the current scene
  103639. * @param rootUrl defines the root URL containing noise procedural texture information
  103640. * @returns a parsed NoiseProceduralTexture
  103641. */
  103642. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  103643. }
  103644. }
  103645. declare module BABYLON {
  103646. /**
  103647. * Raw cube texture where the raw buffers are passed in
  103648. */
  103649. export class RawCubeTexture extends CubeTexture {
  103650. /**
  103651. * Creates a cube texture where the raw buffers are passed in.
  103652. * @param scene defines the scene the texture is attached to
  103653. * @param data defines the array of data to use to create each face
  103654. * @param size defines the size of the textures
  103655. * @param format defines the format of the data
  103656. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  103657. * @param generateMipMaps defines if the engine should generate the mip levels
  103658. * @param invertY defines if data must be stored with Y axis inverted
  103659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  103660. * @param compression defines the compression used (null by default)
  103661. */
  103662. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  103663. /**
  103664. * Updates the raw cube texture.
  103665. * @param data defines the data to store
  103666. * @param format defines the data format
  103667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  103668. * @param invertY defines if data must be stored with Y axis inverted
  103669. * @param compression defines the compression used (null by default)
  103670. * @param level defines which level of the texture to update
  103671. */
  103672. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  103673. /**
  103674. * Updates a raw cube texture with RGBD encoded data.
  103675. * @param data defines the array of data [mipmap][face] to use to create each face
  103676. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  103677. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  103678. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  103679. * @returns a promsie that resolves when the operation is complete
  103680. */
  103681. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  103682. /**
  103683. * Clones the raw cube texture.
  103684. * @return a new cube texture
  103685. */
  103686. clone(): CubeTexture;
  103687. /** @hidden */
  103688. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103689. }
  103690. }
  103691. declare module BABYLON {
  103692. /**
  103693. * Class used to store 3D textures containing user data
  103694. */
  103695. export class RawTexture3D extends Texture {
  103696. /** Gets or sets the texture format to use */
  103697. format: number;
  103698. private _engine;
  103699. /**
  103700. * Create a new RawTexture3D
  103701. * @param data defines the data of the texture
  103702. * @param width defines the width of the texture
  103703. * @param height defines the height of the texture
  103704. * @param depth defines the depth of the texture
  103705. * @param format defines the texture format to use
  103706. * @param scene defines the hosting scene
  103707. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  103708. * @param invertY defines if texture must be stored with Y axis inverted
  103709. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  103710. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  103711. */
  103712. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  103713. /** Gets or sets the texture format to use */
  103714. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  103715. /**
  103716. * Update the texture with new data
  103717. * @param data defines the data to store in the texture
  103718. */
  103719. update(data: ArrayBufferView): void;
  103720. }
  103721. }
  103722. declare module BABYLON {
  103723. /**
  103724. * Creates a refraction texture used by refraction channel of the standard material.
  103725. * It is like a mirror but to see through a material.
  103726. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103727. */
  103728. export class RefractionTexture extends RenderTargetTexture {
  103729. /**
  103730. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  103731. * 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.
  103732. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103733. */
  103734. refractionPlane: Plane;
  103735. /**
  103736. * Define how deep under the surface we should see.
  103737. */
  103738. depth: number;
  103739. /**
  103740. * Creates a refraction texture used by refraction channel of the standard material.
  103741. * It is like a mirror but to see through a material.
  103742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103743. * @param name Define the texture name
  103744. * @param size Define the size of the underlying texture
  103745. * @param scene Define the scene the refraction belongs to
  103746. * @param generateMipMaps Define if we need to generate mips level for the refraction
  103747. */
  103748. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  103749. /**
  103750. * Clone the refraction texture.
  103751. * @returns the cloned texture
  103752. */
  103753. clone(): RefractionTexture;
  103754. /**
  103755. * Serialize the texture to a JSON representation you could use in Parse later on
  103756. * @returns the serialized JSON representation
  103757. */
  103758. serialize(): any;
  103759. }
  103760. }
  103761. declare module BABYLON {
  103762. /**
  103763. * Configuration for Draco compression
  103764. */
  103765. export interface IDracoCompressionConfiguration {
  103766. /**
  103767. * Configuration for the decoder.
  103768. */
  103769. decoder?: {
  103770. /**
  103771. * The url to the WebAssembly module.
  103772. */
  103773. wasmUrl?: string;
  103774. /**
  103775. * The url to the WebAssembly binary.
  103776. */
  103777. wasmBinaryUrl?: string;
  103778. /**
  103779. * The url to the fallback JavaScript module.
  103780. */
  103781. fallbackUrl?: string;
  103782. };
  103783. }
  103784. /**
  103785. * Draco compression (https://google.github.io/draco/)
  103786. *
  103787. * This class wraps the Draco module.
  103788. *
  103789. * **Encoder**
  103790. *
  103791. * The encoder is not currently implemented.
  103792. *
  103793. * **Decoder**
  103794. *
  103795. * 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.
  103796. *
  103797. * To update the configuration, use the following code:
  103798. * ```javascript
  103799. * DracoCompression.Configuration = {
  103800. * decoder: {
  103801. * wasmUrl: "<url to the WebAssembly library>",
  103802. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103803. * fallbackUrl: "<url to the fallback JavaScript library>",
  103804. * }
  103805. * };
  103806. * ```
  103807. *
  103808. * 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.
  103809. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103810. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103811. *
  103812. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103813. * ```javascript
  103814. * var dracoCompression = new DracoCompression();
  103815. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103816. * [VertexBuffer.PositionKind]: 0
  103817. * });
  103818. * ```
  103819. *
  103820. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103821. */
  103822. export class DracoCompression implements IDisposable {
  103823. private static _DecoderModulePromise;
  103824. /**
  103825. * The configuration. Defaults to the following urls:
  103826. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103827. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103828. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103829. */
  103830. static Configuration: IDracoCompressionConfiguration;
  103831. /**
  103832. * Returns true if the decoder is available.
  103833. */
  103834. static readonly DecoderAvailable: boolean;
  103835. /**
  103836. * Constructor
  103837. */
  103838. constructor();
  103839. /**
  103840. * Stop all async operations and release resources.
  103841. */
  103842. dispose(): void;
  103843. /**
  103844. * Decode Draco compressed mesh data to vertex data.
  103845. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103846. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103847. * @returns A promise that resolves with the decoded vertex data
  103848. */
  103849. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103850. [kind: string]: number;
  103851. }): Promise<VertexData>;
  103852. private static _GetDecoderModule;
  103853. private static _LoadScriptAsync;
  103854. private static _LoadFileAsync;
  103855. }
  103856. }
  103857. declare module BABYLON {
  103858. /**
  103859. * Class for building Constructive Solid Geometry
  103860. */
  103861. export class CSG {
  103862. private polygons;
  103863. /**
  103864. * The world matrix
  103865. */
  103866. matrix: Matrix;
  103867. /**
  103868. * Stores the position
  103869. */
  103870. position: Vector3;
  103871. /**
  103872. * Stores the rotation
  103873. */
  103874. rotation: Vector3;
  103875. /**
  103876. * Stores the rotation quaternion
  103877. */
  103878. rotationQuaternion: Nullable<Quaternion>;
  103879. /**
  103880. * Stores the scaling vector
  103881. */
  103882. scaling: Vector3;
  103883. /**
  103884. * Convert the Mesh to CSG
  103885. * @param mesh The Mesh to convert to CSG
  103886. * @returns A new CSG from the Mesh
  103887. */
  103888. static FromMesh(mesh: Mesh): CSG;
  103889. /**
  103890. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103891. * @param polygons Polygons used to construct a CSG solid
  103892. */
  103893. private static FromPolygons;
  103894. /**
  103895. * Clones, or makes a deep copy, of the CSG
  103896. * @returns A new CSG
  103897. */
  103898. clone(): CSG;
  103899. /**
  103900. * Unions this CSG with another CSG
  103901. * @param csg The CSG to union against this CSG
  103902. * @returns The unioned CSG
  103903. */
  103904. union(csg: CSG): CSG;
  103905. /**
  103906. * Unions this CSG with another CSG in place
  103907. * @param csg The CSG to union against this CSG
  103908. */
  103909. unionInPlace(csg: CSG): void;
  103910. /**
  103911. * Subtracts this CSG with another CSG
  103912. * @param csg The CSG to subtract against this CSG
  103913. * @returns A new CSG
  103914. */
  103915. subtract(csg: CSG): CSG;
  103916. /**
  103917. * Subtracts this CSG with another CSG in place
  103918. * @param csg The CSG to subtact against this CSG
  103919. */
  103920. subtractInPlace(csg: CSG): void;
  103921. /**
  103922. * Intersect this CSG with another CSG
  103923. * @param csg The CSG to intersect against this CSG
  103924. * @returns A new CSG
  103925. */
  103926. intersect(csg: CSG): CSG;
  103927. /**
  103928. * Intersects this CSG with another CSG in place
  103929. * @param csg The CSG to intersect against this CSG
  103930. */
  103931. intersectInPlace(csg: CSG): void;
  103932. /**
  103933. * Return a new CSG solid with solid and empty space switched. This solid is
  103934. * not modified.
  103935. * @returns A new CSG solid with solid and empty space switched
  103936. */
  103937. inverse(): CSG;
  103938. /**
  103939. * Inverses the CSG in place
  103940. */
  103941. inverseInPlace(): void;
  103942. /**
  103943. * This is used to keep meshes transformations so they can be restored
  103944. * when we build back a Babylon Mesh
  103945. * NB : All CSG operations are performed in world coordinates
  103946. * @param csg The CSG to copy the transform attributes from
  103947. * @returns This CSG
  103948. */
  103949. copyTransformAttributes(csg: CSG): CSG;
  103950. /**
  103951. * Build Raw mesh from CSG
  103952. * Coordinates here are in world space
  103953. * @param name The name of the mesh geometry
  103954. * @param scene The Scene
  103955. * @param keepSubMeshes Specifies if the submeshes should be kept
  103956. * @returns A new Mesh
  103957. */
  103958. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103959. /**
  103960. * Build Mesh from CSG taking material and transforms into account
  103961. * @param name The name of the Mesh
  103962. * @param material The material of the Mesh
  103963. * @param scene The Scene
  103964. * @param keepSubMeshes Specifies if submeshes should be kept
  103965. * @returns The new Mesh
  103966. */
  103967. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103968. }
  103969. }
  103970. declare module BABYLON {
  103971. /**
  103972. * Class used to create a trail following a mesh
  103973. */
  103974. export class TrailMesh extends Mesh {
  103975. private _generator;
  103976. private _autoStart;
  103977. private _running;
  103978. private _diameter;
  103979. private _length;
  103980. private _sectionPolygonPointsCount;
  103981. private _sectionVectors;
  103982. private _sectionNormalVectors;
  103983. private _beforeRenderObserver;
  103984. /**
  103985. * @constructor
  103986. * @param name The value used by scene.getMeshByName() to do a lookup.
  103987. * @param generator The mesh to generate a trail.
  103988. * @param scene The scene to add this mesh to.
  103989. * @param diameter Diameter of trailing mesh. Default is 1.
  103990. * @param length Length of trailing mesh. Default is 60.
  103991. * @param autoStart Automatically start trailing mesh. Default true.
  103992. */
  103993. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  103994. /**
  103995. * "TrailMesh"
  103996. * @returns "TrailMesh"
  103997. */
  103998. getClassName(): string;
  103999. private _createMesh;
  104000. /**
  104001. * Start trailing mesh.
  104002. */
  104003. start(): void;
  104004. /**
  104005. * Stop trailing mesh.
  104006. */
  104007. stop(): void;
  104008. /**
  104009. * Update trailing mesh geometry.
  104010. */
  104011. update(): void;
  104012. /**
  104013. * Returns a new TrailMesh object.
  104014. * @param name is a string, the name given to the new mesh
  104015. * @param newGenerator use new generator object for cloned trail mesh
  104016. * @returns a new mesh
  104017. */
  104018. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104019. /**
  104020. * Serializes this trail mesh
  104021. * @param serializationObject object to write serialization to
  104022. */
  104023. serialize(serializationObject: any): void;
  104024. /**
  104025. * Parses a serialized trail mesh
  104026. * @param parsedMesh the serialized mesh
  104027. * @param scene the scene to create the trail mesh in
  104028. * @returns the created trail mesh
  104029. */
  104030. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104031. }
  104032. }
  104033. declare module BABYLON {
  104034. /**
  104035. * Class containing static functions to help procedurally build meshes
  104036. */
  104037. export class RibbonBuilder {
  104038. /**
  104039. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104040. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104041. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104042. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104043. * * 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
  104044. * * 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
  104045. * * 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
  104046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104049. * * 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
  104050. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104051. * * 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
  104052. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104054. * @param name defines the name of the mesh
  104055. * @param options defines the options used to create the mesh
  104056. * @param scene defines the hosting scene
  104057. * @returns the ribbon mesh
  104058. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104060. */
  104061. static CreateRibbon(name: string, options: {
  104062. pathArray: Vector3[][];
  104063. closeArray?: boolean;
  104064. closePath?: boolean;
  104065. offset?: number;
  104066. updatable?: boolean;
  104067. sideOrientation?: number;
  104068. frontUVs?: Vector4;
  104069. backUVs?: Vector4;
  104070. instance?: Mesh;
  104071. invertUV?: boolean;
  104072. uvs?: Vector2[];
  104073. colors?: Color4[];
  104074. }, scene?: Nullable<Scene>): Mesh;
  104075. }
  104076. }
  104077. declare module BABYLON {
  104078. /**
  104079. * Class containing static functions to help procedurally build meshes
  104080. */
  104081. export class TorusKnotBuilder {
  104082. /**
  104083. * Creates a torus knot mesh
  104084. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104085. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104086. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104087. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104091. * @param name defines the name of the mesh
  104092. * @param options defines the options used to create the mesh
  104093. * @param scene defines the hosting scene
  104094. * @returns the torus knot mesh
  104095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104096. */
  104097. static CreateTorusKnot(name: string, options: {
  104098. radius?: number;
  104099. tube?: number;
  104100. radialSegments?: number;
  104101. tubularSegments?: number;
  104102. p?: number;
  104103. q?: number;
  104104. updatable?: boolean;
  104105. sideOrientation?: number;
  104106. frontUVs?: Vector4;
  104107. backUVs?: Vector4;
  104108. }, scene: any): Mesh;
  104109. }
  104110. }
  104111. declare module BABYLON {
  104112. /**
  104113. * Polygon
  104114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  104115. */
  104116. export class Polygon {
  104117. /**
  104118. * Creates a rectangle
  104119. * @param xmin bottom X coord
  104120. * @param ymin bottom Y coord
  104121. * @param xmax top X coord
  104122. * @param ymax top Y coord
  104123. * @returns points that make the resulting rectation
  104124. */
  104125. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  104126. /**
  104127. * Creates a circle
  104128. * @param radius radius of circle
  104129. * @param cx scale in x
  104130. * @param cy scale in y
  104131. * @param numberOfSides number of sides that make up the circle
  104132. * @returns points that make the resulting circle
  104133. */
  104134. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  104135. /**
  104136. * Creates a polygon from input string
  104137. * @param input Input polygon data
  104138. * @returns the parsed points
  104139. */
  104140. static Parse(input: string): Vector2[];
  104141. /**
  104142. * Starts building a polygon from x and y coordinates
  104143. * @param x x coordinate
  104144. * @param y y coordinate
  104145. * @returns the started path2
  104146. */
  104147. static StartingAt(x: number, y: number): Path2;
  104148. }
  104149. /**
  104150. * Builds a polygon
  104151. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  104152. */
  104153. export class PolygonMeshBuilder {
  104154. private _points;
  104155. private _outlinepoints;
  104156. private _holes;
  104157. private _name;
  104158. private _scene;
  104159. private _epoints;
  104160. private _eholes;
  104161. private _addToepoint;
  104162. /**
  104163. * Babylon reference to the earcut plugin.
  104164. */
  104165. bjsEarcut: any;
  104166. /**
  104167. * Creates a PolygonMeshBuilder
  104168. * @param name name of the builder
  104169. * @param contours Path of the polygon
  104170. * @param scene scene to add to
  104171. * @param earcutInjection can be used to inject your own earcut reference
  104172. */
  104173. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  104174. /**
  104175. * Adds a whole within the polygon
  104176. * @param hole Array of points defining the hole
  104177. * @returns this
  104178. */
  104179. addHole(hole: Vector2[]): PolygonMeshBuilder;
  104180. /**
  104181. * Creates the polygon
  104182. * @param updatable If the mesh should be updatable
  104183. * @param depth The depth of the mesh created
  104184. * @returns the created mesh
  104185. */
  104186. build(updatable?: boolean, depth?: number): Mesh;
  104187. /**
  104188. * Adds a side to the polygon
  104189. * @param positions points that make the polygon
  104190. * @param normals normals of the polygon
  104191. * @param uvs uvs of the polygon
  104192. * @param indices indices of the polygon
  104193. * @param bounds bounds of the polygon
  104194. * @param points points of the polygon
  104195. * @param depth depth of the polygon
  104196. * @param flip flip of the polygon
  104197. */
  104198. private addSide;
  104199. }
  104200. }
  104201. declare module BABYLON {
  104202. /**
  104203. * Class containing static functions to help procedurally build meshes
  104204. */
  104205. export class PolygonBuilder {
  104206. /**
  104207. * Creates a polygon mesh
  104208. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104209. * * 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
  104210. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104213. * * Remember you can only change the shape positions, not their number when updating a polygon
  104214. * @param name defines the name of the mesh
  104215. * @param options defines the options used to create the mesh
  104216. * @param scene defines the hosting scene
  104217. * @param earcutInjection can be used to inject your own earcut reference
  104218. * @returns the polygon mesh
  104219. */
  104220. static CreatePolygon(name: string, options: {
  104221. shape: Vector3[];
  104222. holes?: Vector3[][];
  104223. depth?: number;
  104224. faceUV?: Vector4[];
  104225. faceColors?: Color4[];
  104226. updatable?: boolean;
  104227. sideOrientation?: number;
  104228. frontUVs?: Vector4;
  104229. backUVs?: Vector4;
  104230. }, scene: Scene, earcutInjection?: any): Mesh;
  104231. /**
  104232. * Creates an extruded polygon mesh, with depth in the Y direction.
  104233. * * 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)
  104234. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104235. * @param name defines the name of the mesh
  104236. * @param options defines the options used to create the mesh
  104237. * @param scene defines the hosting scene
  104238. * @param earcutInjection can be used to inject your own earcut reference
  104239. * @returns the polygon mesh
  104240. */
  104241. static ExtrudePolygon(name: string, options: {
  104242. shape: Vector3[];
  104243. holes?: Vector3[][];
  104244. depth?: number;
  104245. faceUV?: Vector4[];
  104246. faceColors?: Color4[];
  104247. updatable?: boolean;
  104248. sideOrientation?: number;
  104249. frontUVs?: Vector4;
  104250. backUVs?: Vector4;
  104251. }, scene: Scene, earcutInjection?: any): Mesh;
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /**
  104256. * Class containing static functions to help procedurally build meshes
  104257. */
  104258. export class ShapeBuilder {
  104259. /**
  104260. * 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.
  104261. * * 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.
  104262. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104263. * * 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.
  104264. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  104265. * * 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
  104266. * * 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
  104267. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104272. * @param name defines the name of the mesh
  104273. * @param options defines the options used to create the mesh
  104274. * @param scene defines the hosting scene
  104275. * @returns the extruded shape mesh
  104276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104278. */
  104279. static ExtrudeShape(name: string, options: {
  104280. shape: Vector3[];
  104281. path: Vector3[];
  104282. scale?: number;
  104283. rotation?: number;
  104284. cap?: number;
  104285. updatable?: boolean;
  104286. sideOrientation?: number;
  104287. frontUVs?: Vector4;
  104288. backUVs?: Vector4;
  104289. instance?: Mesh;
  104290. invertUV?: boolean;
  104291. }, scene?: Nullable<Scene>): Mesh;
  104292. /**
  104293. * Creates an custom extruded shape mesh.
  104294. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104295. * * 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.
  104296. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104297. * * 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
  104298. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104299. * * 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
  104300. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104301. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104302. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104303. * * 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
  104304. * * 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
  104305. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104310. * @param name defines the name of the mesh
  104311. * @param options defines the options used to create the mesh
  104312. * @param scene defines the hosting scene
  104313. * @returns the custom extruded shape mesh
  104314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104317. */
  104318. static ExtrudeShapeCustom(name: string, options: {
  104319. shape: Vector3[];
  104320. path: Vector3[];
  104321. scaleFunction?: any;
  104322. rotationFunction?: any;
  104323. ribbonCloseArray?: boolean;
  104324. ribbonClosePath?: boolean;
  104325. cap?: number;
  104326. updatable?: boolean;
  104327. sideOrientation?: number;
  104328. frontUVs?: Vector4;
  104329. backUVs?: Vector4;
  104330. instance?: Mesh;
  104331. invertUV?: boolean;
  104332. }, scene: Scene): Mesh;
  104333. private static _ExtrudeShapeGeneric;
  104334. }
  104335. }
  104336. declare module BABYLON {
  104337. /**
  104338. * Class containing static functions to help procedurally build meshes
  104339. */
  104340. export class LatheBuilder {
  104341. /**
  104342. * Creates lathe mesh.
  104343. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104344. * * 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
  104345. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104346. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104347. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104348. * * 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
  104349. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104350. * * 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
  104351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104355. * @param name defines the name of the mesh
  104356. * @param options defines the options used to create the mesh
  104357. * @param scene defines the hosting scene
  104358. * @returns the lathe mesh
  104359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104360. */
  104361. static CreateLathe(name: string, options: {
  104362. shape: Vector3[];
  104363. radius?: number;
  104364. tessellation?: number;
  104365. clip?: number;
  104366. arc?: number;
  104367. closed?: boolean;
  104368. updatable?: boolean;
  104369. sideOrientation?: number;
  104370. frontUVs?: Vector4;
  104371. backUVs?: Vector4;
  104372. cap?: number;
  104373. invertUV?: boolean;
  104374. }, scene: Scene): Mesh;
  104375. }
  104376. }
  104377. declare module BABYLON {
  104378. /**
  104379. * Class containing static functions to help procedurally build meshes
  104380. */
  104381. export class TubeBuilder {
  104382. /**
  104383. * Creates a tube mesh.
  104384. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104385. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104386. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104387. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104388. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104389. * * 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)
  104390. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104391. * * 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
  104392. * * 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
  104393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104397. * @param name defines the name of the mesh
  104398. * @param options defines the options used to create the mesh
  104399. * @param scene defines the hosting scene
  104400. * @returns the tube mesh
  104401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104402. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104403. */
  104404. static CreateTube(name: string, options: {
  104405. path: Vector3[];
  104406. radius?: number;
  104407. tessellation?: number;
  104408. radiusFunction?: {
  104409. (i: number, distance: number): number;
  104410. };
  104411. cap?: number;
  104412. arc?: number;
  104413. updatable?: boolean;
  104414. sideOrientation?: number;
  104415. frontUVs?: Vector4;
  104416. backUVs?: Vector4;
  104417. instance?: Mesh;
  104418. invertUV?: boolean;
  104419. }, scene: Scene): Mesh;
  104420. }
  104421. }
  104422. declare module BABYLON {
  104423. /**
  104424. * Class containing static functions to help procedurally build meshes
  104425. */
  104426. export class IcoSphereBuilder {
  104427. /**
  104428. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104429. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104430. * * 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`)
  104431. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104432. * * 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
  104433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104436. * @param name defines the name of the mesh
  104437. * @param options defines the options used to create the mesh
  104438. * @param scene defines the hosting scene
  104439. * @returns the icosahedron mesh
  104440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104441. */
  104442. static CreateIcoSphere(name: string, options: {
  104443. radius?: number;
  104444. radiusX?: number;
  104445. radiusY?: number;
  104446. radiusZ?: number;
  104447. flat?: boolean;
  104448. subdivisions?: number;
  104449. sideOrientation?: number;
  104450. frontUVs?: Vector4;
  104451. backUVs?: Vector4;
  104452. updatable?: boolean;
  104453. }, scene: Scene): Mesh;
  104454. }
  104455. }
  104456. declare module BABYLON {
  104457. /**
  104458. * Class containing static functions to help procedurally build meshes
  104459. */
  104460. export class DecalBuilder {
  104461. /**
  104462. * Creates a decal mesh.
  104463. * 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
  104464. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104465. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104466. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104467. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104468. * @param name defines the name of the mesh
  104469. * @param sourceMesh defines the mesh where the decal must be applied
  104470. * @param options defines the options used to create the mesh
  104471. * @param scene defines the hosting scene
  104472. * @returns the decal mesh
  104473. * @see https://doc.babylonjs.com/how_to/decals
  104474. */
  104475. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104476. position?: Vector3;
  104477. normal?: Vector3;
  104478. size?: Vector3;
  104479. angle?: number;
  104480. }): Mesh;
  104481. }
  104482. }
  104483. declare module BABYLON {
  104484. /**
  104485. * Class containing static functions to help procedurally build meshes
  104486. */
  104487. export class MeshBuilder {
  104488. /**
  104489. * Creates a box mesh
  104490. * * The parameter `size` sets the size (float) of each box side (default 1)
  104491. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104492. * * 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)
  104493. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104497. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104498. * @param name defines the name of the mesh
  104499. * @param options defines the options used to create the mesh
  104500. * @param scene defines the hosting scene
  104501. * @returns the box mesh
  104502. */
  104503. static CreateBox(name: string, options: {
  104504. size?: number;
  104505. width?: number;
  104506. height?: number;
  104507. depth?: number;
  104508. faceUV?: Vector4[];
  104509. faceColors?: Color4[];
  104510. sideOrientation?: number;
  104511. frontUVs?: Vector4;
  104512. backUVs?: Vector4;
  104513. updatable?: boolean;
  104514. }, scene?: Nullable<Scene>): Mesh;
  104515. /**
  104516. * Creates a sphere mesh
  104517. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104518. * * 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`)
  104519. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104520. * * 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
  104521. * * 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)
  104522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104525. * @param name defines the name of the mesh
  104526. * @param options defines the options used to create the mesh
  104527. * @param scene defines the hosting scene
  104528. * @returns the sphere mesh
  104529. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104530. */
  104531. static CreateSphere(name: string, options: {
  104532. segments?: number;
  104533. diameter?: number;
  104534. diameterX?: number;
  104535. diameterY?: number;
  104536. diameterZ?: number;
  104537. arc?: number;
  104538. slice?: number;
  104539. sideOrientation?: number;
  104540. frontUVs?: Vector4;
  104541. backUVs?: Vector4;
  104542. updatable?: boolean;
  104543. }, scene: any): Mesh;
  104544. /**
  104545. * Creates a plane polygonal mesh. By default, this is a disc
  104546. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  104547. * * 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
  104548. * * 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
  104549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104552. * @param name defines the name of the mesh
  104553. * @param options defines the options used to create the mesh
  104554. * @param scene defines the hosting scene
  104555. * @returns the plane polygonal mesh
  104556. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  104557. */
  104558. static CreateDisc(name: string, options: {
  104559. radius?: number;
  104560. tessellation?: number;
  104561. arc?: number;
  104562. updatable?: boolean;
  104563. sideOrientation?: number;
  104564. frontUVs?: Vector4;
  104565. backUVs?: Vector4;
  104566. }, scene?: Nullable<Scene>): Mesh;
  104567. /**
  104568. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104569. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104570. * * 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`)
  104571. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104572. * * 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
  104573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104576. * @param name defines the name of the mesh
  104577. * @param options defines the options used to create the mesh
  104578. * @param scene defines the hosting scene
  104579. * @returns the icosahedron mesh
  104580. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104581. */
  104582. static CreateIcoSphere(name: string, options: {
  104583. radius?: number;
  104584. radiusX?: number;
  104585. radiusY?: number;
  104586. radiusZ?: number;
  104587. flat?: boolean;
  104588. subdivisions?: number;
  104589. sideOrientation?: number;
  104590. frontUVs?: Vector4;
  104591. backUVs?: Vector4;
  104592. updatable?: boolean;
  104593. }, scene: Scene): Mesh;
  104594. /**
  104595. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104596. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104597. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104598. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104599. * * 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
  104600. * * 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
  104601. * * 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
  104602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104605. * * 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
  104606. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104607. * * 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
  104608. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104610. * @param name defines the name of the mesh
  104611. * @param options defines the options used to create the mesh
  104612. * @param scene defines the hosting scene
  104613. * @returns the ribbon mesh
  104614. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104615. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104616. */
  104617. static CreateRibbon(name: string, options: {
  104618. pathArray: Vector3[][];
  104619. closeArray?: boolean;
  104620. closePath?: boolean;
  104621. offset?: number;
  104622. updatable?: boolean;
  104623. sideOrientation?: number;
  104624. frontUVs?: Vector4;
  104625. backUVs?: Vector4;
  104626. instance?: Mesh;
  104627. invertUV?: boolean;
  104628. uvs?: Vector2[];
  104629. colors?: Color4[];
  104630. }, scene?: Nullable<Scene>): Mesh;
  104631. /**
  104632. * Creates a cylinder or a cone mesh
  104633. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104634. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104635. * * 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.
  104636. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104637. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104638. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104639. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104640. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104641. * * 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).
  104642. * * 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
  104643. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104644. * * 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
  104645. * * 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.
  104646. * * If `enclose` is false, a ring surface is one element.
  104647. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104648. * * 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
  104649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104652. * @param name defines the name of the mesh
  104653. * @param options defines the options used to create the mesh
  104654. * @param scene defines the hosting scene
  104655. * @returns the cylinder mesh
  104656. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104657. */
  104658. static CreateCylinder(name: string, options: {
  104659. height?: number;
  104660. diameterTop?: number;
  104661. diameterBottom?: number;
  104662. diameter?: number;
  104663. tessellation?: number;
  104664. subdivisions?: number;
  104665. arc?: number;
  104666. faceColors?: Color4[];
  104667. faceUV?: Vector4[];
  104668. updatable?: boolean;
  104669. hasRings?: boolean;
  104670. enclose?: boolean;
  104671. sideOrientation?: number;
  104672. frontUVs?: Vector4;
  104673. backUVs?: Vector4;
  104674. }, scene: any): Mesh;
  104675. /**
  104676. * Creates a torus mesh
  104677. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104678. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104679. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104683. * @param name defines the name of the mesh
  104684. * @param options defines the options used to create the mesh
  104685. * @param scene defines the hosting scene
  104686. * @returns the torus mesh
  104687. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104688. */
  104689. static CreateTorus(name: string, options: {
  104690. diameter?: number;
  104691. thickness?: number;
  104692. tessellation?: number;
  104693. updatable?: boolean;
  104694. sideOrientation?: number;
  104695. frontUVs?: Vector4;
  104696. backUVs?: Vector4;
  104697. }, scene: any): Mesh;
  104698. /**
  104699. * Creates a torus knot mesh
  104700. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104701. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104702. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104703. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104707. * @param name defines the name of the mesh
  104708. * @param options defines the options used to create the mesh
  104709. * @param scene defines the hosting scene
  104710. * @returns the torus knot mesh
  104711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104712. */
  104713. static CreateTorusKnot(name: string, options: {
  104714. radius?: number;
  104715. tube?: number;
  104716. radialSegments?: number;
  104717. tubularSegments?: number;
  104718. p?: number;
  104719. q?: number;
  104720. updatable?: boolean;
  104721. sideOrientation?: number;
  104722. frontUVs?: Vector4;
  104723. backUVs?: Vector4;
  104724. }, scene: any): Mesh;
  104725. /**
  104726. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104727. * * 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
  104728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104729. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104730. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104731. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104732. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104733. * * 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
  104734. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104737. * @param name defines the name of the new line system
  104738. * @param options defines the options used to create the line system
  104739. * @param scene defines the hosting scene
  104740. * @returns a new line system mesh
  104741. */
  104742. static CreateLineSystem(name: string, options: {
  104743. lines: Vector3[][];
  104744. updatable?: boolean;
  104745. instance?: Nullable<LinesMesh>;
  104746. colors?: Nullable<Color4[][]>;
  104747. useVertexAlpha?: boolean;
  104748. }, scene: Nullable<Scene>): LinesMesh;
  104749. /**
  104750. * Creates a line mesh
  104751. * 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
  104752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104753. * * The parameter `points` is an array successive Vector3
  104754. * * 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
  104755. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104757. * * When updating an instance, remember that only point positions can change, not the number of points
  104758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104760. * @param name defines the name of the new line system
  104761. * @param options defines the options used to create the line system
  104762. * @param scene defines the hosting scene
  104763. * @returns a new line mesh
  104764. */
  104765. static CreateLines(name: string, options: {
  104766. points: Vector3[];
  104767. updatable?: boolean;
  104768. instance?: Nullable<LinesMesh>;
  104769. colors?: Color4[];
  104770. useVertexAlpha?: boolean;
  104771. }, scene?: Nullable<Scene>): LinesMesh;
  104772. /**
  104773. * Creates a dashed line mesh
  104774. * * 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
  104775. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104776. * * The parameter `points` is an array successive Vector3
  104777. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104778. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104779. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104780. * * 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
  104781. * * When updating an instance, remember that only point positions can change, not the number of points
  104782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104783. * @param name defines the name of the mesh
  104784. * @param options defines the options used to create the mesh
  104785. * @param scene defines the hosting scene
  104786. * @returns the dashed line mesh
  104787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104788. */
  104789. static CreateDashedLines(name: string, options: {
  104790. points: Vector3[];
  104791. dashSize?: number;
  104792. gapSize?: number;
  104793. dashNb?: number;
  104794. updatable?: boolean;
  104795. instance?: LinesMesh;
  104796. }, scene?: Nullable<Scene>): LinesMesh;
  104797. /**
  104798. * 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.
  104799. * * 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.
  104800. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104801. * * 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.
  104802. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  104803. * * 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
  104804. * * 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
  104805. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104810. * @param name defines the name of the mesh
  104811. * @param options defines the options used to create the mesh
  104812. * @param scene defines the hosting scene
  104813. * @returns the extruded shape mesh
  104814. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104816. */
  104817. static ExtrudeShape(name: string, options: {
  104818. shape: Vector3[];
  104819. path: Vector3[];
  104820. scale?: number;
  104821. rotation?: number;
  104822. cap?: number;
  104823. updatable?: boolean;
  104824. sideOrientation?: number;
  104825. frontUVs?: Vector4;
  104826. backUVs?: Vector4;
  104827. instance?: Mesh;
  104828. invertUV?: boolean;
  104829. }, scene?: Nullable<Scene>): Mesh;
  104830. /**
  104831. * Creates an custom extruded shape mesh.
  104832. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104833. * * 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.
  104834. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104835. * * 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
  104836. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104837. * * 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
  104838. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104839. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104840. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104841. * * 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
  104842. * * 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
  104843. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104846. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104848. * @param name defines the name of the mesh
  104849. * @param options defines the options used to create the mesh
  104850. * @param scene defines the hosting scene
  104851. * @returns the custom extruded shape mesh
  104852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104853. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104855. */
  104856. static ExtrudeShapeCustom(name: string, options: {
  104857. shape: Vector3[];
  104858. path: Vector3[];
  104859. scaleFunction?: any;
  104860. rotationFunction?: any;
  104861. ribbonCloseArray?: boolean;
  104862. ribbonClosePath?: boolean;
  104863. cap?: number;
  104864. updatable?: boolean;
  104865. sideOrientation?: number;
  104866. frontUVs?: Vector4;
  104867. backUVs?: Vector4;
  104868. instance?: Mesh;
  104869. invertUV?: boolean;
  104870. }, scene: Scene): Mesh;
  104871. /**
  104872. * Creates lathe mesh.
  104873. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104874. * * 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
  104875. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104876. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104877. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104878. * * 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
  104879. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104880. * * 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
  104881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104885. * @param name defines the name of the mesh
  104886. * @param options defines the options used to create the mesh
  104887. * @param scene defines the hosting scene
  104888. * @returns the lathe mesh
  104889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104890. */
  104891. static CreateLathe(name: string, options: {
  104892. shape: Vector3[];
  104893. radius?: number;
  104894. tessellation?: number;
  104895. clip?: number;
  104896. arc?: number;
  104897. closed?: boolean;
  104898. updatable?: boolean;
  104899. sideOrientation?: number;
  104900. frontUVs?: Vector4;
  104901. backUVs?: Vector4;
  104902. cap?: number;
  104903. invertUV?: boolean;
  104904. }, scene: Scene): Mesh;
  104905. /**
  104906. * Creates a plane mesh
  104907. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104908. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104909. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104913. * @param name defines the name of the mesh
  104914. * @param options defines the options used to create the mesh
  104915. * @param scene defines the hosting scene
  104916. * @returns the plane mesh
  104917. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104918. */
  104919. static CreatePlane(name: string, options: {
  104920. size?: number;
  104921. width?: number;
  104922. height?: number;
  104923. sideOrientation?: number;
  104924. frontUVs?: Vector4;
  104925. backUVs?: Vector4;
  104926. updatable?: boolean;
  104927. sourcePlane?: Plane;
  104928. }, scene: Scene): Mesh;
  104929. /**
  104930. * Creates a ground mesh
  104931. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104932. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104934. * @param name defines the name of the mesh
  104935. * @param options defines the options used to create the mesh
  104936. * @param scene defines the hosting scene
  104937. * @returns the ground mesh
  104938. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104939. */
  104940. static CreateGround(name: string, options: {
  104941. width?: number;
  104942. height?: number;
  104943. subdivisions?: number;
  104944. subdivisionsX?: number;
  104945. subdivisionsY?: number;
  104946. updatable?: boolean;
  104947. }, scene: any): Mesh;
  104948. /**
  104949. * Creates a tiled ground mesh
  104950. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104951. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104952. * * 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
  104953. * * 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
  104954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104955. * @param name defines the name of the mesh
  104956. * @param options defines the options used to create the mesh
  104957. * @param scene defines the hosting scene
  104958. * @returns the tiled ground mesh
  104959. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104960. */
  104961. static CreateTiledGround(name: string, options: {
  104962. xmin: number;
  104963. zmin: number;
  104964. xmax: number;
  104965. zmax: number;
  104966. subdivisions?: {
  104967. w: number;
  104968. h: number;
  104969. };
  104970. precision?: {
  104971. w: number;
  104972. h: number;
  104973. };
  104974. updatable?: boolean;
  104975. }, scene: Scene): Mesh;
  104976. /**
  104977. * Creates a ground mesh from a height map
  104978. * * The parameter `url` sets the URL of the height map image resource.
  104979. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104980. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104981. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104982. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104983. * * 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.
  104984. * * 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).
  104985. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104987. * @param name defines the name of the mesh
  104988. * @param url defines the url to the height map
  104989. * @param options defines the options used to create the mesh
  104990. * @param scene defines the hosting scene
  104991. * @returns the ground mesh
  104992. * @see https://doc.babylonjs.com/babylon101/height_map
  104993. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104994. */
  104995. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104996. width?: number;
  104997. height?: number;
  104998. subdivisions?: number;
  104999. minHeight?: number;
  105000. maxHeight?: number;
  105001. colorFilter?: Color3;
  105002. alphaFilter?: number;
  105003. updatable?: boolean;
  105004. onReady?: (mesh: GroundMesh) => void;
  105005. }, scene: Scene): GroundMesh;
  105006. /**
  105007. * Creates a polygon mesh
  105008. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105009. * * 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
  105010. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105013. * * Remember you can only change the shape positions, not their number when updating a polygon
  105014. * @param name defines the name of the mesh
  105015. * @param options defines the options used to create the mesh
  105016. * @param scene defines the hosting scene
  105017. * @param earcutInjection can be used to inject your own earcut reference
  105018. * @returns the polygon mesh
  105019. */
  105020. static CreatePolygon(name: string, options: {
  105021. shape: Vector3[];
  105022. holes?: Vector3[][];
  105023. depth?: number;
  105024. faceUV?: Vector4[];
  105025. faceColors?: Color4[];
  105026. updatable?: boolean;
  105027. sideOrientation?: number;
  105028. frontUVs?: Vector4;
  105029. backUVs?: Vector4;
  105030. }, scene: Scene, earcutInjection?: any): Mesh;
  105031. /**
  105032. * Creates an extruded polygon mesh, with depth in the Y direction.
  105033. * * 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)
  105034. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105035. * @param name defines the name of the mesh
  105036. * @param options defines the options used to create the mesh
  105037. * @param scene defines the hosting scene
  105038. * @param earcutInjection can be used to inject your own earcut reference
  105039. * @returns the polygon mesh
  105040. */
  105041. static ExtrudePolygon(name: string, options: {
  105042. shape: Vector3[];
  105043. holes?: Vector3[][];
  105044. depth?: number;
  105045. faceUV?: Vector4[];
  105046. faceColors?: Color4[];
  105047. updatable?: boolean;
  105048. sideOrientation?: number;
  105049. frontUVs?: Vector4;
  105050. backUVs?: Vector4;
  105051. }, scene: Scene, earcutInjection?: any): Mesh;
  105052. /**
  105053. * Creates a tube mesh.
  105054. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105055. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105056. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105057. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105058. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105059. * * 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)
  105060. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105061. * * 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
  105062. * * 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
  105063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105067. * @param name defines the name of the mesh
  105068. * @param options defines the options used to create the mesh
  105069. * @param scene defines the hosting scene
  105070. * @returns the tube mesh
  105071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105072. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105073. */
  105074. static CreateTube(name: string, options: {
  105075. path: Vector3[];
  105076. radius?: number;
  105077. tessellation?: number;
  105078. radiusFunction?: {
  105079. (i: number, distance: number): number;
  105080. };
  105081. cap?: number;
  105082. arc?: number;
  105083. updatable?: boolean;
  105084. sideOrientation?: number;
  105085. frontUVs?: Vector4;
  105086. backUVs?: Vector4;
  105087. instance?: Mesh;
  105088. invertUV?: boolean;
  105089. }, scene: Scene): Mesh;
  105090. /**
  105091. * Creates a polyhedron mesh
  105092. * * 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
  105093. * * The parameter `size` (positive float, default 1) sets the polygon size
  105094. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105095. * * 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`
  105096. * * 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
  105097. * * 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)`)
  105098. * * 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
  105099. * * 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
  105100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105103. * @param name defines the name of the mesh
  105104. * @param options defines the options used to create the mesh
  105105. * @param scene defines the hosting scene
  105106. * @returns the polyhedron mesh
  105107. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105108. */
  105109. static CreatePolyhedron(name: string, options: {
  105110. type?: number;
  105111. size?: number;
  105112. sizeX?: number;
  105113. sizeY?: number;
  105114. sizeZ?: number;
  105115. custom?: any;
  105116. faceUV?: Vector4[];
  105117. faceColors?: Color4[];
  105118. flat?: boolean;
  105119. updatable?: boolean;
  105120. sideOrientation?: number;
  105121. frontUVs?: Vector4;
  105122. backUVs?: Vector4;
  105123. }, scene: Scene): Mesh;
  105124. /**
  105125. * Creates a decal mesh.
  105126. * 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
  105127. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105128. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105129. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105130. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105131. * @param name defines the name of the mesh
  105132. * @param sourceMesh defines the mesh where the decal must be applied
  105133. * @param options defines the options used to create the mesh
  105134. * @param scene defines the hosting scene
  105135. * @returns the decal mesh
  105136. * @see https://doc.babylonjs.com/how_to/decals
  105137. */
  105138. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105139. position?: Vector3;
  105140. normal?: Vector3;
  105141. size?: Vector3;
  105142. angle?: number;
  105143. }): Mesh;
  105144. }
  105145. }
  105146. declare module BABYLON {
  105147. /**
  105148. * A simplifier interface for future simplification implementations
  105149. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105150. */
  105151. export interface ISimplifier {
  105152. /**
  105153. * Simplification of a given mesh according to the given settings.
  105154. * Since this requires computation, it is assumed that the function runs async.
  105155. * @param settings The settings of the simplification, including quality and distance
  105156. * @param successCallback A callback that will be called after the mesh was simplified.
  105157. * @param errorCallback in case of an error, this callback will be called. optional.
  105158. */
  105159. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  105160. }
  105161. /**
  105162. * Expected simplification settings.
  105163. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  105164. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105165. */
  105166. export interface ISimplificationSettings {
  105167. /**
  105168. * Gets or sets the expected quality
  105169. */
  105170. quality: number;
  105171. /**
  105172. * Gets or sets the distance when this optimized version should be used
  105173. */
  105174. distance: number;
  105175. /**
  105176. * Gets an already optimized mesh
  105177. */
  105178. optimizeMesh?: boolean;
  105179. }
  105180. /**
  105181. * Class used to specify simplification options
  105182. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105183. */
  105184. export class SimplificationSettings implements ISimplificationSettings {
  105185. /** expected quality */
  105186. quality: number;
  105187. /** distance when this optimized version should be used */
  105188. distance: number;
  105189. /** already optimized mesh */
  105190. optimizeMesh?: boolean | undefined;
  105191. /**
  105192. * Creates a SimplificationSettings
  105193. * @param quality expected quality
  105194. * @param distance distance when this optimized version should be used
  105195. * @param optimizeMesh already optimized mesh
  105196. */
  105197. constructor(
  105198. /** expected quality */
  105199. quality: number,
  105200. /** distance when this optimized version should be used */
  105201. distance: number,
  105202. /** already optimized mesh */
  105203. optimizeMesh?: boolean | undefined);
  105204. }
  105205. /**
  105206. * Interface used to define a simplification task
  105207. */
  105208. export interface ISimplificationTask {
  105209. /**
  105210. * Array of settings
  105211. */
  105212. settings: Array<ISimplificationSettings>;
  105213. /**
  105214. * Simplification type
  105215. */
  105216. simplificationType: SimplificationType;
  105217. /**
  105218. * Mesh to simplify
  105219. */
  105220. mesh: Mesh;
  105221. /**
  105222. * Callback called on success
  105223. */
  105224. successCallback?: () => void;
  105225. /**
  105226. * Defines if parallel processing can be used
  105227. */
  105228. parallelProcessing: boolean;
  105229. }
  105230. /**
  105231. * Queue used to order the simplification tasks
  105232. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105233. */
  105234. export class SimplificationQueue {
  105235. private _simplificationArray;
  105236. /**
  105237. * Gets a boolean indicating that the process is still running
  105238. */
  105239. running: boolean;
  105240. /**
  105241. * Creates a new queue
  105242. */
  105243. constructor();
  105244. /**
  105245. * Adds a new simplification task
  105246. * @param task defines a task to add
  105247. */
  105248. addTask(task: ISimplificationTask): void;
  105249. /**
  105250. * Execute next task
  105251. */
  105252. executeNext(): void;
  105253. /**
  105254. * Execute a simplification task
  105255. * @param task defines the task to run
  105256. */
  105257. runSimplification(task: ISimplificationTask): void;
  105258. private getSimplifier;
  105259. }
  105260. /**
  105261. * The implemented types of simplification
  105262. * At the moment only Quadratic Error Decimation is implemented
  105263. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105264. */
  105265. export enum SimplificationType {
  105266. /** Quadratic error decimation */
  105267. QUADRATIC = 0
  105268. }
  105269. }
  105270. declare module BABYLON {
  105271. interface Scene {
  105272. /** @hidden (Backing field) */
  105273. _simplificationQueue: SimplificationQueue;
  105274. /**
  105275. * Gets or sets the simplification queue attached to the scene
  105276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105277. */
  105278. simplificationQueue: SimplificationQueue;
  105279. }
  105280. interface Mesh {
  105281. /**
  105282. * Simplify the mesh according to the given array of settings.
  105283. * Function will return immediately and will simplify async
  105284. * @param settings a collection of simplification settings
  105285. * @param parallelProcessing should all levels calculate parallel or one after the other
  105286. * @param simplificationType the type of simplification to run
  105287. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  105288. * @returns the current mesh
  105289. */
  105290. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  105291. }
  105292. /**
  105293. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  105294. * created in a scene
  105295. */
  105296. export class SimplicationQueueSceneComponent implements ISceneComponent {
  105297. /**
  105298. * The component name helpfull to identify the component in the list of scene components.
  105299. */
  105300. readonly name: string;
  105301. /**
  105302. * The scene the component belongs to.
  105303. */
  105304. scene: Scene;
  105305. /**
  105306. * Creates a new instance of the component for the given scene
  105307. * @param scene Defines the scene to register the component in
  105308. */
  105309. constructor(scene: Scene);
  105310. /**
  105311. * Registers the component in a given scene
  105312. */
  105313. register(): void;
  105314. /**
  105315. * Rebuilds the elements related to this component in case of
  105316. * context lost for instance.
  105317. */
  105318. rebuild(): void;
  105319. /**
  105320. * Disposes the component and the associated ressources
  105321. */
  105322. dispose(): void;
  105323. private _beforeCameraUpdate;
  105324. }
  105325. }
  105326. declare module BABYLON {
  105327. /**
  105328. * Class used to enable access to IndexedDB
  105329. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105330. */
  105331. export class Database implements IOfflineProvider {
  105332. private _callbackManifestChecked;
  105333. private _currentSceneUrl;
  105334. private _db;
  105335. private _enableSceneOffline;
  105336. private _enableTexturesOffline;
  105337. private _manifestVersionFound;
  105338. private _mustUpdateRessources;
  105339. private _hasReachedQuota;
  105340. private _isSupported;
  105341. private _idbFactory;
  105342. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  105343. private static IsUASupportingBlobStorage;
  105344. /**
  105345. * Gets a boolean indicating if Database storate is enabled (off by default)
  105346. */
  105347. static IDBStorageEnabled: boolean;
  105348. /**
  105349. * Gets a boolean indicating if scene must be saved in the database
  105350. */
  105351. readonly enableSceneOffline: boolean;
  105352. /**
  105353. * Gets a boolean indicating if textures must be saved in the database
  105354. */
  105355. readonly enableTexturesOffline: boolean;
  105356. /**
  105357. * Creates a new Database
  105358. * @param urlToScene defines the url to load the scene
  105359. * @param callbackManifestChecked defines the callback to use when manifest is checked
  105360. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  105361. */
  105362. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  105363. private static _ParseURL;
  105364. private static _ReturnFullUrlLocation;
  105365. private _checkManifestFile;
  105366. /**
  105367. * Open the database and make it available
  105368. * @param successCallback defines the callback to call on success
  105369. * @param errorCallback defines the callback to call on error
  105370. */
  105371. open(successCallback: () => void, errorCallback: () => void): void;
  105372. /**
  105373. * Loads an image from the database
  105374. * @param url defines the url to load from
  105375. * @param image defines the target DOM image
  105376. */
  105377. loadImage(url: string, image: HTMLImageElement): void;
  105378. private _loadImageFromDBAsync;
  105379. private _saveImageIntoDBAsync;
  105380. private _checkVersionFromDB;
  105381. private _loadVersionFromDBAsync;
  105382. private _saveVersionIntoDBAsync;
  105383. /**
  105384. * Loads a file from database
  105385. * @param url defines the URL to load from
  105386. * @param sceneLoaded defines a callback to call on success
  105387. * @param progressCallBack defines a callback to call when progress changed
  105388. * @param errorCallback defines a callback to call on error
  105389. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  105390. */
  105391. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  105392. private _loadFileAsync;
  105393. private _saveFileAsync;
  105394. /**
  105395. * Validates if xhr data is correct
  105396. * @param xhr defines the request to validate
  105397. * @param dataType defines the expected data type
  105398. * @returns true if data is correct
  105399. */
  105400. private static _ValidateXHRData;
  105401. }
  105402. }
  105403. declare module BABYLON {
  105404. /** @hidden */
  105405. export var gpuUpdateParticlesPixelShader: {
  105406. name: string;
  105407. shader: string;
  105408. };
  105409. }
  105410. declare module BABYLON {
  105411. /** @hidden */
  105412. export var gpuUpdateParticlesVertexShader: {
  105413. name: string;
  105414. shader: string;
  105415. };
  105416. }
  105417. declare module BABYLON {
  105418. /** @hidden */
  105419. export var clipPlaneFragmentDeclaration2: {
  105420. name: string;
  105421. shader: string;
  105422. };
  105423. }
  105424. declare module BABYLON {
  105425. /** @hidden */
  105426. export var gpuRenderParticlesPixelShader: {
  105427. name: string;
  105428. shader: string;
  105429. };
  105430. }
  105431. declare module BABYLON {
  105432. /** @hidden */
  105433. export var clipPlaneVertexDeclaration2: {
  105434. name: string;
  105435. shader: string;
  105436. };
  105437. }
  105438. declare module BABYLON {
  105439. /** @hidden */
  105440. export var gpuRenderParticlesVertexShader: {
  105441. name: string;
  105442. shader: string;
  105443. };
  105444. }
  105445. declare module BABYLON {
  105446. /**
  105447. * This represents a GPU particle system in Babylon
  105448. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  105449. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  105450. */
  105451. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  105452. /**
  105453. * The layer mask we are rendering the particles through.
  105454. */
  105455. layerMask: number;
  105456. private _capacity;
  105457. private _activeCount;
  105458. private _currentActiveCount;
  105459. private _accumulatedCount;
  105460. private _renderEffect;
  105461. private _updateEffect;
  105462. private _buffer0;
  105463. private _buffer1;
  105464. private _spriteBuffer;
  105465. private _updateVAO;
  105466. private _renderVAO;
  105467. private _targetIndex;
  105468. private _sourceBuffer;
  105469. private _targetBuffer;
  105470. private _engine;
  105471. private _currentRenderId;
  105472. private _started;
  105473. private _stopped;
  105474. private _timeDelta;
  105475. private _randomTexture;
  105476. private _randomTexture2;
  105477. private _attributesStrideSize;
  105478. private _updateEffectOptions;
  105479. private _randomTextureSize;
  105480. private _actualFrame;
  105481. private readonly _rawTextureWidth;
  105482. /**
  105483. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  105484. */
  105485. static readonly IsSupported: boolean;
  105486. /**
  105487. * An event triggered when the system is disposed.
  105488. */
  105489. onDisposeObservable: Observable<GPUParticleSystem>;
  105490. /**
  105491. * Gets the maximum number of particles active at the same time.
  105492. * @returns The max number of active particles.
  105493. */
  105494. getCapacity(): number;
  105495. /**
  105496. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105497. * to override the particles.
  105498. */
  105499. forceDepthWrite: boolean;
  105500. /**
  105501. * Gets or set the number of active particles
  105502. */
  105503. activeParticleCount: number;
  105504. private _preWarmDone;
  105505. /**
  105506. * Is this system ready to be used/rendered
  105507. * @return true if the system is ready
  105508. */
  105509. isReady(): boolean;
  105510. /**
  105511. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105512. * @returns True if it has been started, otherwise false.
  105513. */
  105514. isStarted(): boolean;
  105515. /**
  105516. * Starts the particle system and begins to emit
  105517. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105518. */
  105519. start(delay?: number): void;
  105520. /**
  105521. * Stops the particle system.
  105522. */
  105523. stop(): void;
  105524. /**
  105525. * Remove all active particles
  105526. */
  105527. reset(): void;
  105528. /**
  105529. * Returns the string "GPUParticleSystem"
  105530. * @returns a string containing the class name
  105531. */
  105532. getClassName(): string;
  105533. private _colorGradientsTexture;
  105534. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  105535. /**
  105536. * Adds a new color gradient
  105537. * @param gradient defines the gradient to use (between 0 and 1)
  105538. * @param color1 defines the color to affect to the specified gradient
  105539. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105540. * @returns the current particle system
  105541. */
  105542. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  105543. /**
  105544. * Remove a specific color gradient
  105545. * @param gradient defines the gradient to remove
  105546. * @returns the current particle system
  105547. */
  105548. removeColorGradient(gradient: number): GPUParticleSystem;
  105549. private _angularSpeedGradientsTexture;
  105550. private _sizeGradientsTexture;
  105551. private _velocityGradientsTexture;
  105552. private _limitVelocityGradientsTexture;
  105553. private _dragGradientsTexture;
  105554. private _addFactorGradient;
  105555. /**
  105556. * Adds a new size gradient
  105557. * @param gradient defines the gradient to use (between 0 and 1)
  105558. * @param factor defines the size factor to affect to the specified gradient
  105559. * @returns the current particle system
  105560. */
  105561. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  105562. /**
  105563. * Remove a specific size gradient
  105564. * @param gradient defines the gradient to remove
  105565. * @returns the current particle system
  105566. */
  105567. removeSizeGradient(gradient: number): GPUParticleSystem;
  105568. /**
  105569. * Adds a new angular speed gradient
  105570. * @param gradient defines the gradient to use (between 0 and 1)
  105571. * @param factor defines the angular speed to affect to the specified gradient
  105572. * @returns the current particle system
  105573. */
  105574. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  105575. /**
  105576. * Remove a specific angular speed gradient
  105577. * @param gradient defines the gradient to remove
  105578. * @returns the current particle system
  105579. */
  105580. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  105581. /**
  105582. * Adds a new velocity gradient
  105583. * @param gradient defines the gradient to use (between 0 and 1)
  105584. * @param factor defines the velocity to affect to the specified gradient
  105585. * @returns the current particle system
  105586. */
  105587. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105588. /**
  105589. * Remove a specific velocity gradient
  105590. * @param gradient defines the gradient to remove
  105591. * @returns the current particle system
  105592. */
  105593. removeVelocityGradient(gradient: number): GPUParticleSystem;
  105594. /**
  105595. * Adds a new limit velocity gradient
  105596. * @param gradient defines the gradient to use (between 0 and 1)
  105597. * @param factor defines the limit velocity value to affect to the specified gradient
  105598. * @returns the current particle system
  105599. */
  105600. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105601. /**
  105602. * Remove a specific limit velocity gradient
  105603. * @param gradient defines the gradient to remove
  105604. * @returns the current particle system
  105605. */
  105606. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  105607. /**
  105608. * Adds a new drag gradient
  105609. * @param gradient defines the gradient to use (between 0 and 1)
  105610. * @param factor defines the drag value to affect to the specified gradient
  105611. * @returns the current particle system
  105612. */
  105613. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  105614. /**
  105615. * Remove a specific drag gradient
  105616. * @param gradient defines the gradient to remove
  105617. * @returns the current particle system
  105618. */
  105619. removeDragGradient(gradient: number): GPUParticleSystem;
  105620. /**
  105621. * Not supported by GPUParticleSystem
  105622. * @param gradient defines the gradient to use (between 0 and 1)
  105623. * @param factor defines the emit rate value to affect to the specified gradient
  105624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105625. * @returns the current particle system
  105626. */
  105627. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105628. /**
  105629. * Not supported by GPUParticleSystem
  105630. * @param gradient defines the gradient to remove
  105631. * @returns the current particle system
  105632. */
  105633. removeEmitRateGradient(gradient: number): IParticleSystem;
  105634. /**
  105635. * Not supported by GPUParticleSystem
  105636. * @param gradient defines the gradient to use (between 0 and 1)
  105637. * @param factor defines the start size value to affect to the specified gradient
  105638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105639. * @returns the current particle system
  105640. */
  105641. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105642. /**
  105643. * Not supported by GPUParticleSystem
  105644. * @param gradient defines the gradient to remove
  105645. * @returns the current particle system
  105646. */
  105647. removeStartSizeGradient(gradient: number): IParticleSystem;
  105648. /**
  105649. * Not supported by GPUParticleSystem
  105650. * @param gradient defines the gradient to use (between 0 and 1)
  105651. * @param min defines the color remap minimal range
  105652. * @param max defines the color remap maximal range
  105653. * @returns the current particle system
  105654. */
  105655. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105656. /**
  105657. * Not supported by GPUParticleSystem
  105658. * @param gradient defines the gradient to remove
  105659. * @returns the current particle system
  105660. */
  105661. removeColorRemapGradient(): IParticleSystem;
  105662. /**
  105663. * Not supported by GPUParticleSystem
  105664. * @param gradient defines the gradient to use (between 0 and 1)
  105665. * @param min defines the alpha remap minimal range
  105666. * @param max defines the alpha remap maximal range
  105667. * @returns the current particle system
  105668. */
  105669. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105670. /**
  105671. * Not supported by GPUParticleSystem
  105672. * @param gradient defines the gradient to remove
  105673. * @returns the current particle system
  105674. */
  105675. removeAlphaRemapGradient(): IParticleSystem;
  105676. /**
  105677. * Not supported by GPUParticleSystem
  105678. * @param gradient defines the gradient to use (between 0 and 1)
  105679. * @param color defines the color to affect to the specified gradient
  105680. * @returns the current particle system
  105681. */
  105682. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  105683. /**
  105684. * Not supported by GPUParticleSystem
  105685. * @param gradient defines the gradient to remove
  105686. * @returns the current particle system
  105687. */
  105688. removeRampGradient(): IParticleSystem;
  105689. /**
  105690. * Not supported by GPUParticleSystem
  105691. * @returns the list of ramp gradients
  105692. */
  105693. getRampGradients(): Nullable<Array<Color3Gradient>>;
  105694. /**
  105695. * Not supported by GPUParticleSystem
  105696. * Gets or sets a boolean indicating that ramp gradients must be used
  105697. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105698. */
  105699. useRampGradients: boolean;
  105700. /**
  105701. * Not supported by GPUParticleSystem
  105702. * @param gradient defines the gradient to use (between 0 and 1)
  105703. * @param factor defines the life time factor to affect to the specified gradient
  105704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105705. * @returns the current particle system
  105706. */
  105707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105708. /**
  105709. * Not supported by GPUParticleSystem
  105710. * @param gradient defines the gradient to remove
  105711. * @returns the current particle system
  105712. */
  105713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  105714. /**
  105715. * Instantiates a GPU particle system.
  105716. * 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.
  105717. * @param name The name of the particle system
  105718. * @param options The options used to create the system
  105719. * @param scene The scene the particle system belongs to
  105720. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105721. */
  105722. constructor(name: string, options: Partial<{
  105723. capacity: number;
  105724. randomTextureSize: number;
  105725. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  105726. protected _reset(): void;
  105727. private _createUpdateVAO;
  105728. private _createRenderVAO;
  105729. private _initialize;
  105730. /** @hidden */
  105731. _recreateUpdateEffect(): void;
  105732. /** @hidden */
  105733. _recreateRenderEffect(): void;
  105734. /**
  105735. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105736. * @param preWarm defines if we are in the pre-warmimg phase
  105737. */
  105738. animate(preWarm?: boolean): void;
  105739. private _createFactorGradientTexture;
  105740. private _createSizeGradientTexture;
  105741. private _createAngularSpeedGradientTexture;
  105742. private _createVelocityGradientTexture;
  105743. private _createLimitVelocityGradientTexture;
  105744. private _createDragGradientTexture;
  105745. private _createColorGradientTexture;
  105746. /**
  105747. * Renders the particle system in its current state
  105748. * @param preWarm defines if the system should only update the particles but not render them
  105749. * @returns the current number of particles
  105750. */
  105751. render(preWarm?: boolean): number;
  105752. /**
  105753. * Rebuilds the particle system
  105754. */
  105755. rebuild(): void;
  105756. private _releaseBuffers;
  105757. private _releaseVAOs;
  105758. /**
  105759. * Disposes the particle system and free the associated resources
  105760. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105761. */
  105762. dispose(disposeTexture?: boolean): void;
  105763. /**
  105764. * Clones the particle system.
  105765. * @param name The name of the cloned object
  105766. * @param newEmitter The new emitter to use
  105767. * @returns the cloned particle system
  105768. */
  105769. clone(name: string, newEmitter: any): GPUParticleSystem;
  105770. /**
  105771. * Serializes the particle system to a JSON object.
  105772. * @returns the JSON object
  105773. */
  105774. serialize(): any;
  105775. /**
  105776. * Parses a JSON object to create a GPU particle system.
  105777. * @param parsedParticleSystem The JSON object to parse
  105778. * @param scene The scene to create the particle system in
  105779. * @param rootUrl The root url to use to load external dependencies like texture
  105780. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  105781. * @returns the parsed GPU particle system
  105782. */
  105783. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  105784. }
  105785. }
  105786. declare module BABYLON {
  105787. /**
  105788. * Represents a set of particle systems working together to create a specific effect
  105789. */
  105790. export class ParticleSystemSet implements IDisposable {
  105791. private _emitterCreationOptions;
  105792. private _emitterNode;
  105793. /**
  105794. * Gets the particle system list
  105795. */
  105796. systems: IParticleSystem[];
  105797. /**
  105798. * Gets the emitter node used with this set
  105799. */
  105800. readonly emitterNode: Nullable<TransformNode>;
  105801. /**
  105802. * Creates a new emitter mesh as a sphere
  105803. * @param options defines the options used to create the sphere
  105804. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  105805. * @param scene defines the hosting scene
  105806. */
  105807. setEmitterAsSphere(options: {
  105808. diameter: number;
  105809. segments: number;
  105810. color: Color3;
  105811. }, renderingGroupId: number, scene: Scene): void;
  105812. /**
  105813. * Starts all particle systems of the set
  105814. * @param emitter defines an optional mesh to use as emitter for the particle systems
  105815. */
  105816. start(emitter?: AbstractMesh): void;
  105817. /**
  105818. * Release all associated resources
  105819. */
  105820. dispose(): void;
  105821. /**
  105822. * Serialize the set into a JSON compatible object
  105823. * @returns a JSON compatible representation of the set
  105824. */
  105825. serialize(): any;
  105826. /**
  105827. * Parse a new ParticleSystemSet from a serialized source
  105828. * @param data defines a JSON compatible representation of the set
  105829. * @param scene defines the hosting scene
  105830. * @param gpu defines if we want GPU particles or CPU particles
  105831. * @returns a new ParticleSystemSet
  105832. */
  105833. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  105834. }
  105835. }
  105836. declare module BABYLON {
  105837. /**
  105838. * This class is made for on one-liner static method to help creating particle system set.
  105839. */
  105840. export class ParticleHelper {
  105841. /**
  105842. * Gets or sets base Assets URL
  105843. */
  105844. static BaseAssetsUrl: string;
  105845. /**
  105846. * Create a default particle system that you can tweak
  105847. * @param emitter defines the emitter to use
  105848. * @param capacity defines the system capacity (default is 500 particles)
  105849. * @param scene defines the hosting scene
  105850. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105851. * @returns the new Particle system
  105852. */
  105853. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  105854. /**
  105855. * This is the main static method (one-liner) of this helper to create different particle systems
  105856. * @param type This string represents the type to the particle system to create
  105857. * @param scene The scene where the particle system should live
  105858. * @param gpu If the system will use gpu
  105859. * @returns the ParticleSystemSet created
  105860. */
  105861. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  105862. /**
  105863. * Static function used to export a particle system to a ParticleSystemSet variable.
  105864. * Please note that the emitter shape is not exported
  105865. * @param systems defines the particle systems to export
  105866. * @returns the created particle system set
  105867. */
  105868. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  105869. }
  105870. }
  105871. declare module BABYLON {
  105872. interface Engine {
  105873. /**
  105874. * Create an effect to use with particle systems.
  105875. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  105876. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  105877. * @param uniformsNames defines a list of attribute names
  105878. * @param samplers defines an array of string used to represent textures
  105879. * @param defines defines the string containing the defines to use to compile the shaders
  105880. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105881. * @param onCompiled defines a function to call when the effect creation is successful
  105882. * @param onError defines a function to call when the effect creation has failed
  105883. * @returns the new Effect
  105884. */
  105885. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  105886. }
  105887. interface Mesh {
  105888. /**
  105889. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  105890. * @returns an array of IParticleSystem
  105891. */
  105892. getEmittedParticleSystems(): IParticleSystem[];
  105893. /**
  105894. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  105895. * @returns an array of IParticleSystem
  105896. */
  105897. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  105898. }
  105899. /**
  105900. * @hidden
  105901. */
  105902. export var _IDoNeedToBeInTheBuild: number;
  105903. }
  105904. declare module BABYLON {
  105905. interface Scene {
  105906. /** @hidden (Backing field) */
  105907. _physicsEngine: Nullable<IPhysicsEngine>;
  105908. /**
  105909. * Gets the current physics engine
  105910. * @returns a IPhysicsEngine or null if none attached
  105911. */
  105912. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105913. /**
  105914. * Enables physics to the current scene
  105915. * @param gravity defines the scene's gravity for the physics engine
  105916. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105917. * @return a boolean indicating if the physics engine was initialized
  105918. */
  105919. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105920. /**
  105921. * Disables and disposes the physics engine associated with the scene
  105922. */
  105923. disablePhysicsEngine(): void;
  105924. /**
  105925. * Gets a boolean indicating if there is an active physics engine
  105926. * @returns a boolean indicating if there is an active physics engine
  105927. */
  105928. isPhysicsEnabled(): boolean;
  105929. /**
  105930. * Deletes a physics compound impostor
  105931. * @param compound defines the compound to delete
  105932. */
  105933. deleteCompoundImpostor(compound: any): void;
  105934. /**
  105935. * An event triggered when physic simulation is about to be run
  105936. */
  105937. onBeforePhysicsObservable: Observable<Scene>;
  105938. /**
  105939. * An event triggered when physic simulation has been done
  105940. */
  105941. onAfterPhysicsObservable: Observable<Scene>;
  105942. }
  105943. interface AbstractMesh {
  105944. /** @hidden */
  105945. _physicsImpostor: Nullable<PhysicsImpostor>;
  105946. /**
  105947. * Gets or sets impostor used for physic simulation
  105948. * @see http://doc.babylonjs.com/features/physics_engine
  105949. */
  105950. physicsImpostor: Nullable<PhysicsImpostor>;
  105951. /**
  105952. * Gets the current physics impostor
  105953. * @see http://doc.babylonjs.com/features/physics_engine
  105954. * @returns a physics impostor or null
  105955. */
  105956. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105957. /** Apply a physic impulse to the mesh
  105958. * @param force defines the force to apply
  105959. * @param contactPoint defines where to apply the force
  105960. * @returns the current mesh
  105961. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105962. */
  105963. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105964. /**
  105965. * Creates a physic joint between two meshes
  105966. * @param otherMesh defines the other mesh to use
  105967. * @param pivot1 defines the pivot to use on this mesh
  105968. * @param pivot2 defines the pivot to use on the other mesh
  105969. * @param options defines additional options (can be plugin dependent)
  105970. * @returns the current mesh
  105971. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105972. */
  105973. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105974. /** @hidden */
  105975. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105976. }
  105977. /**
  105978. * Defines the physics engine scene component responsible to manage a physics engine
  105979. */
  105980. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105981. /**
  105982. * The component name helpful to identify the component in the list of scene components.
  105983. */
  105984. readonly name: string;
  105985. /**
  105986. * The scene the component belongs to.
  105987. */
  105988. scene: Scene;
  105989. /**
  105990. * Creates a new instance of the component for the given scene
  105991. * @param scene Defines the scene to register the component in
  105992. */
  105993. constructor(scene: Scene);
  105994. /**
  105995. * Registers the component in a given scene
  105996. */
  105997. register(): void;
  105998. /**
  105999. * Rebuilds the elements related to this component in case of
  106000. * context lost for instance.
  106001. */
  106002. rebuild(): void;
  106003. /**
  106004. * Disposes the component and the associated ressources
  106005. */
  106006. dispose(): void;
  106007. }
  106008. }
  106009. declare module BABYLON {
  106010. /**
  106011. * A helper for physics simulations
  106012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106013. */
  106014. export class PhysicsHelper {
  106015. private _scene;
  106016. private _physicsEngine;
  106017. /**
  106018. * Initializes the Physics helper
  106019. * @param scene Babylon.js scene
  106020. */
  106021. constructor(scene: Scene);
  106022. /**
  106023. * Applies a radial explosion impulse
  106024. * @param origin the origin of the explosion
  106025. * @param radius the explosion radius
  106026. * @param strength the explosion strength
  106027. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106028. * @returns A physics radial explosion event, or null
  106029. */
  106030. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106031. /**
  106032. * Applies a radial explosion force
  106033. * @param origin the origin of the explosion
  106034. * @param radius the explosion radius
  106035. * @param strength the explosion strength
  106036. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106037. * @returns A physics radial explosion event, or null
  106038. */
  106039. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106040. /**
  106041. * Creates a gravitational field
  106042. * @param origin the origin of the explosion
  106043. * @param radius the explosion radius
  106044. * @param strength the explosion strength
  106045. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106046. * @returns A physics gravitational field event, or null
  106047. */
  106048. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106049. /**
  106050. * Creates a physics updraft event
  106051. * @param origin the origin of the updraft
  106052. * @param radius the radius of the updraft
  106053. * @param strength the strength of the updraft
  106054. * @param height the height of the updraft
  106055. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  106056. * @returns A physics updraft event, or null
  106057. */
  106058. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  106059. /**
  106060. * Creates a physics vortex event
  106061. * @param origin the of the vortex
  106062. * @param radius the radius of the vortex
  106063. * @param strength the strength of the vortex
  106064. * @param height the height of the vortex
  106065. * @returns a Physics vortex event, or null
  106066. * A physics vortex event or null
  106067. */
  106068. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  106069. }
  106070. /**
  106071. * Represents a physics radial explosion event
  106072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106073. */
  106074. export class PhysicsRadialExplosionEvent {
  106075. private _scene;
  106076. private _sphere;
  106077. private _sphereOptions;
  106078. private _rays;
  106079. private _dataFetched;
  106080. /**
  106081. * Initializes a radial explosioin event
  106082. * @param scene BabylonJS scene
  106083. */
  106084. constructor(scene: Scene);
  106085. /**
  106086. * Returns the data related to the radial explosion event (sphere & rays).
  106087. * @returns The radial explosion event data
  106088. */
  106089. getData(): PhysicsRadialExplosionEventData;
  106090. /**
  106091. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  106092. * @param impostor A physics imposter
  106093. * @param origin the origin of the explosion
  106094. * @param radius the explosion radius
  106095. * @param strength the explosion strength
  106096. * @param falloff possible options: Constant & Linear
  106097. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  106098. */
  106099. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  106100. /**
  106101. * Disposes the sphere.
  106102. * @param force Specifies if the sphere should be disposed by force
  106103. */
  106104. dispose(force?: boolean): void;
  106105. /*** Helpers ***/
  106106. private _prepareSphere;
  106107. private _intersectsWithSphere;
  106108. }
  106109. /**
  106110. * Represents a gravitational field event
  106111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106112. */
  106113. export class PhysicsGravitationalFieldEvent {
  106114. private _physicsHelper;
  106115. private _scene;
  106116. private _origin;
  106117. private _radius;
  106118. private _strength;
  106119. private _falloff;
  106120. private _tickCallback;
  106121. private _sphere;
  106122. private _dataFetched;
  106123. /**
  106124. * Initializes the physics gravitational field event
  106125. * @param physicsHelper A physics helper
  106126. * @param scene BabylonJS scene
  106127. * @param origin The origin position of the gravitational field event
  106128. * @param radius The radius of the gravitational field event
  106129. * @param strength The strength of the gravitational field event
  106130. * @param falloff The falloff for the gravitational field event
  106131. */
  106132. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  106133. /**
  106134. * Returns the data related to the gravitational field event (sphere).
  106135. * @returns A gravitational field event
  106136. */
  106137. getData(): PhysicsGravitationalFieldEventData;
  106138. /**
  106139. * Enables the gravitational field.
  106140. */
  106141. enable(): void;
  106142. /**
  106143. * Disables the gravitational field.
  106144. */
  106145. disable(): void;
  106146. /**
  106147. * Disposes the sphere.
  106148. * @param force The force to dispose from the gravitational field event
  106149. */
  106150. dispose(force?: boolean): void;
  106151. private _tick;
  106152. }
  106153. /**
  106154. * Represents a physics updraft event
  106155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106156. */
  106157. export class PhysicsUpdraftEvent {
  106158. private _scene;
  106159. private _origin;
  106160. private _radius;
  106161. private _strength;
  106162. private _height;
  106163. private _updraftMode;
  106164. private _physicsEngine;
  106165. private _originTop;
  106166. private _originDirection;
  106167. private _tickCallback;
  106168. private _cylinder;
  106169. private _cylinderPosition;
  106170. private _dataFetched;
  106171. /**
  106172. * Initializes the physics updraft event
  106173. * @param _scene BabylonJS scene
  106174. * @param _origin The origin position of the updraft
  106175. * @param _radius The radius of the updraft
  106176. * @param _strength The strength of the updraft
  106177. * @param _height The height of the updraft
  106178. * @param _updraftMode The mode of the updraft
  106179. */
  106180. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  106181. /**
  106182. * Returns the data related to the updraft event (cylinder).
  106183. * @returns A physics updraft event
  106184. */
  106185. getData(): PhysicsUpdraftEventData;
  106186. /**
  106187. * Enables the updraft.
  106188. */
  106189. enable(): void;
  106190. /**
  106191. * Disables the cortex.
  106192. */
  106193. disable(): void;
  106194. /**
  106195. * Disposes the sphere.
  106196. * @param force Specifies if the updraft should be disposed by force
  106197. */
  106198. dispose(force?: boolean): void;
  106199. private getImpostorForceAndContactPoint;
  106200. private _tick;
  106201. /*** Helpers ***/
  106202. private _prepareCylinder;
  106203. private _intersectsWithCylinder;
  106204. }
  106205. /**
  106206. * Represents a physics vortex event
  106207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106208. */
  106209. export class PhysicsVortexEvent {
  106210. private _scene;
  106211. private _origin;
  106212. private _radius;
  106213. private _strength;
  106214. private _height;
  106215. private _physicsEngine;
  106216. private _originTop;
  106217. private _centripetalForceThreshold;
  106218. private _updraftMultiplier;
  106219. private _tickCallback;
  106220. private _cylinder;
  106221. private _cylinderPosition;
  106222. private _dataFetched;
  106223. /**
  106224. * Initializes the physics vortex event
  106225. * @param _scene The BabylonJS scene
  106226. * @param _origin The origin position of the vortex
  106227. * @param _radius The radius of the vortex
  106228. * @param _strength The strength of the vortex
  106229. * @param _height The height of the vortex
  106230. */
  106231. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  106232. /**
  106233. * Returns the data related to the vortex event (cylinder).
  106234. * @returns The physics vortex event data
  106235. */
  106236. getData(): PhysicsVortexEventData;
  106237. /**
  106238. * Enables the vortex.
  106239. */
  106240. enable(): void;
  106241. /**
  106242. * Disables the cortex.
  106243. */
  106244. disable(): void;
  106245. /**
  106246. * Disposes the sphere.
  106247. * @param force
  106248. */
  106249. dispose(force?: boolean): void;
  106250. private getImpostorForceAndContactPoint;
  106251. private _tick;
  106252. /*** Helpers ***/
  106253. private _prepareCylinder;
  106254. private _intersectsWithCylinder;
  106255. }
  106256. /**
  106257. * The strenght of the force in correspondence to the distance of the affected object
  106258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106259. */
  106260. export enum PhysicsRadialImpulseFalloff {
  106261. /** Defines that impulse is constant in strength across it's whole radius */
  106262. Constant = 0,
  106263. /** DEfines that impulse gets weaker if it's further from the origin */
  106264. Linear = 1
  106265. }
  106266. /**
  106267. * The strength of the force in correspondence to the distance of the affected object
  106268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106269. */
  106270. export enum PhysicsUpdraftMode {
  106271. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  106272. Center = 0,
  106273. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  106274. Perpendicular = 1
  106275. }
  106276. /**
  106277. * Interface for a physics force and contact point
  106278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106279. */
  106280. export interface PhysicsForceAndContactPoint {
  106281. /**
  106282. * The force applied at the contact point
  106283. */
  106284. force: Vector3;
  106285. /**
  106286. * The contact point
  106287. */
  106288. contactPoint: Vector3;
  106289. }
  106290. /**
  106291. * Interface for radial explosion event data
  106292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106293. */
  106294. export interface PhysicsRadialExplosionEventData {
  106295. /**
  106296. * A sphere used for the radial explosion event
  106297. */
  106298. sphere: Mesh;
  106299. /**
  106300. * An array of rays for the radial explosion event
  106301. */
  106302. rays: Array<Ray>;
  106303. }
  106304. /**
  106305. * Interface for gravitational field event data
  106306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106307. */
  106308. export interface PhysicsGravitationalFieldEventData {
  106309. /**
  106310. * A sphere mesh used for the gravitational field event
  106311. */
  106312. sphere: Mesh;
  106313. }
  106314. /**
  106315. * Interface for updraft event data
  106316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106317. */
  106318. export interface PhysicsUpdraftEventData {
  106319. /**
  106320. * A cylinder used for the updraft event
  106321. */
  106322. cylinder: Mesh;
  106323. }
  106324. /**
  106325. * Interface for vortex event data
  106326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106327. */
  106328. export interface PhysicsVortexEventData {
  106329. /**
  106330. * A cylinder used for the vortex event
  106331. */
  106332. cylinder: Mesh;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. /**
  106337. * AmmoJS Physics plugin
  106338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106339. * @see https://github.com/kripken/ammo.js/
  106340. */
  106341. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106342. private _useDeltaForWorldStep;
  106343. /**
  106344. * Reference to the Ammo library
  106345. */
  106346. bjsAMMO: any;
  106347. /**
  106348. * Created ammoJS world which physics bodies are added to
  106349. */
  106350. world: any;
  106351. /**
  106352. * Name of the plugin
  106353. */
  106354. name: string;
  106355. private _timeStep;
  106356. private _fixedTimeStep;
  106357. private _maxSteps;
  106358. private _tmpQuaternion;
  106359. private _tmpAmmoTransform;
  106360. private _tmpAmmoQuaternion;
  106361. private _tmpAmmoConcreteContactResultCallback;
  106362. private _collisionConfiguration;
  106363. private _dispatcher;
  106364. private _overlappingPairCache;
  106365. private _solver;
  106366. private _tmpAmmoVectorA;
  106367. private _tmpAmmoVectorB;
  106368. private _tmpAmmoVectorC;
  106369. private _tmpContactCallbackResult;
  106370. private static readonly DISABLE_COLLISION_FLAG;
  106371. private static readonly KINEMATIC_FLAG;
  106372. private static readonly DISABLE_DEACTIVATION_FLAG;
  106373. /**
  106374. * Initializes the ammoJS plugin
  106375. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  106376. * @param ammoInjection can be used to inject your own ammo reference
  106377. */
  106378. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  106379. /**
  106380. * Sets the gravity of the physics world (m/(s^2))
  106381. * @param gravity Gravity to set
  106382. */
  106383. setGravity(gravity: Vector3): void;
  106384. /**
  106385. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  106386. * @param timeStep timestep to use in seconds
  106387. */
  106388. setTimeStep(timeStep: number): void;
  106389. /**
  106390. * 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)
  106391. * @param fixedTimeStep fixedTimeStep to use in seconds
  106392. */
  106393. setFixedTimeStep(fixedTimeStep: number): void;
  106394. /**
  106395. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  106396. * @param maxSteps the maximum number of steps by the physics engine per frame
  106397. */
  106398. setMaxSteps(maxSteps: number): void;
  106399. /**
  106400. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  106401. * @returns the current timestep in seconds
  106402. */
  106403. getTimeStep(): number;
  106404. private _isImpostorInContact;
  106405. private _isImpostorPairInContact;
  106406. private _stepSimulation;
  106407. /**
  106408. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  106409. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  106410. * After the step the babylon meshes are set to the position of the physics imposters
  106411. * @param delta amount of time to step forward
  106412. * @param impostors array of imposters to update before/after the step
  106413. */
  106414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106415. private _tmpVector;
  106416. private _tmpMatrix;
  106417. /**
  106418. * Applies an implulse on the imposter
  106419. * @param impostor imposter to apply impulse
  106420. * @param force amount of force to be applied to the imposter
  106421. * @param contactPoint the location to apply the impulse on the imposter
  106422. */
  106423. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106424. /**
  106425. * Applies a force on the imposter
  106426. * @param impostor imposter to apply force
  106427. * @param force amount of force to be applied to the imposter
  106428. * @param contactPoint the location to apply the force on the imposter
  106429. */
  106430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106431. /**
  106432. * Creates a physics body using the plugin
  106433. * @param impostor the imposter to create the physics body on
  106434. */
  106435. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106436. /**
  106437. * Removes the physics body from the imposter and disposes of the body's memory
  106438. * @param impostor imposter to remove the physics body from
  106439. */
  106440. removePhysicsBody(impostor: PhysicsImpostor): void;
  106441. /**
  106442. * Generates a joint
  106443. * @param impostorJoint the imposter joint to create the joint with
  106444. */
  106445. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106446. /**
  106447. * Removes a joint
  106448. * @param impostorJoint the imposter joint to remove the joint from
  106449. */
  106450. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106451. private _addMeshVerts;
  106452. private _createShape;
  106453. /**
  106454. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  106455. * @param impostor imposter containing the physics body and babylon object
  106456. */
  106457. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106458. /**
  106459. * Sets the babylon object's position/rotation from the physics body's position/rotation
  106460. * @param impostor imposter containing the physics body and babylon object
  106461. * @param newPosition new position
  106462. * @param newRotation new rotation
  106463. */
  106464. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106465. /**
  106466. * If this plugin is supported
  106467. * @returns true if its supported
  106468. */
  106469. isSupported(): boolean;
  106470. /**
  106471. * Sets the linear velocity of the physics body
  106472. * @param impostor imposter to set the velocity on
  106473. * @param velocity velocity to set
  106474. */
  106475. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106476. /**
  106477. * Sets the angular velocity of the physics body
  106478. * @param impostor imposter to set the velocity on
  106479. * @param velocity velocity to set
  106480. */
  106481. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106482. /**
  106483. * gets the linear velocity
  106484. * @param impostor imposter to get linear velocity from
  106485. * @returns linear velocity
  106486. */
  106487. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106488. /**
  106489. * gets the angular velocity
  106490. * @param impostor imposter to get angular velocity from
  106491. * @returns angular velocity
  106492. */
  106493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106494. /**
  106495. * Sets the mass of physics body
  106496. * @param impostor imposter to set the mass on
  106497. * @param mass mass to set
  106498. */
  106499. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106500. /**
  106501. * Gets the mass of the physics body
  106502. * @param impostor imposter to get the mass from
  106503. * @returns mass
  106504. */
  106505. getBodyMass(impostor: PhysicsImpostor): number;
  106506. /**
  106507. * Gets friction of the impostor
  106508. * @param impostor impostor to get friction from
  106509. * @returns friction value
  106510. */
  106511. getBodyFriction(impostor: PhysicsImpostor): number;
  106512. /**
  106513. * Sets friction of the impostor
  106514. * @param impostor impostor to set friction on
  106515. * @param friction friction value
  106516. */
  106517. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106518. /**
  106519. * Gets restitution of the impostor
  106520. * @param impostor impostor to get restitution from
  106521. * @returns restitution value
  106522. */
  106523. getBodyRestitution(impostor: PhysicsImpostor): number;
  106524. /**
  106525. * Sets resitution of the impostor
  106526. * @param impostor impostor to set resitution on
  106527. * @param restitution resitution value
  106528. */
  106529. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106530. /**
  106531. * Sleeps the physics body and stops it from being active
  106532. * @param impostor impostor to sleep
  106533. */
  106534. sleepBody(impostor: PhysicsImpostor): void;
  106535. /**
  106536. * Activates the physics body
  106537. * @param impostor impostor to activate
  106538. */
  106539. wakeUpBody(impostor: PhysicsImpostor): void;
  106540. /**
  106541. * Updates the distance parameters of the joint
  106542. * @param joint joint to update
  106543. * @param maxDistance maximum distance of the joint
  106544. * @param minDistance minimum distance of the joint
  106545. */
  106546. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106547. /**
  106548. * Sets a motor on the joint
  106549. * @param joint joint to set motor on
  106550. * @param speed speed of the motor
  106551. * @param maxForce maximum force of the motor
  106552. * @param motorIndex index of the motor
  106553. */
  106554. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106555. /**
  106556. * Sets the motors limit
  106557. * @param joint joint to set limit on
  106558. * @param upperLimit upper limit
  106559. * @param lowerLimit lower limit
  106560. */
  106561. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106562. /**
  106563. * Syncs the position and rotation of a mesh with the impostor
  106564. * @param mesh mesh to sync
  106565. * @param impostor impostor to update the mesh with
  106566. */
  106567. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106568. /**
  106569. * Gets the radius of the impostor
  106570. * @param impostor impostor to get radius from
  106571. * @returns the radius
  106572. */
  106573. getRadius(impostor: PhysicsImpostor): number;
  106574. /**
  106575. * Gets the box size of the impostor
  106576. * @param impostor impostor to get box size from
  106577. * @param result the resulting box size
  106578. */
  106579. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106580. /**
  106581. * Disposes of the impostor
  106582. */
  106583. dispose(): void;
  106584. }
  106585. }
  106586. declare module BABYLON {
  106587. /** @hidden */
  106588. export var blackAndWhitePixelShader: {
  106589. name: string;
  106590. shader: string;
  106591. };
  106592. }
  106593. declare module BABYLON {
  106594. /**
  106595. * Post process used to render in black and white
  106596. */
  106597. export class BlackAndWhitePostProcess extends PostProcess {
  106598. /**
  106599. * Linear about to convert he result to black and white (default: 1)
  106600. */
  106601. degree: number;
  106602. /**
  106603. * Creates a black and white post process
  106604. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  106605. * @param name The name of the effect.
  106606. * @param options The required width/height ratio to downsize to before computing the render pass.
  106607. * @param camera The camera to apply the render pass to.
  106608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106609. * @param engine The engine which the post process will be applied. (default: current engine)
  106610. * @param reusable If the post process can be reused on the same frame. (default: false)
  106611. */
  106612. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106613. }
  106614. }
  106615. declare module BABYLON {
  106616. /**
  106617. * This represents a set of one or more post processes in Babylon.
  106618. * A post process can be used to apply a shader to a texture after it is rendered.
  106619. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106620. */
  106621. export class PostProcessRenderEffect {
  106622. private _postProcesses;
  106623. private _getPostProcesses;
  106624. private _singleInstance;
  106625. private _cameras;
  106626. private _indicesForCamera;
  106627. /**
  106628. * Name of the effect
  106629. * @hidden
  106630. */
  106631. _name: string;
  106632. /**
  106633. * Instantiates a post process render effect.
  106634. * A post process can be used to apply a shader to a texture after it is rendered.
  106635. * @param engine The engine the effect is tied to
  106636. * @param name The name of the effect
  106637. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  106638. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  106639. */
  106640. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  106641. /**
  106642. * Checks if all the post processes in the effect are supported.
  106643. */
  106644. readonly isSupported: boolean;
  106645. /**
  106646. * Updates the current state of the effect
  106647. * @hidden
  106648. */
  106649. _update(): void;
  106650. /**
  106651. * Attaches the effect on cameras
  106652. * @param cameras The camera to attach to.
  106653. * @hidden
  106654. */
  106655. _attachCameras(cameras: Camera): void;
  106656. /**
  106657. * Attaches the effect on cameras
  106658. * @param cameras The camera to attach to.
  106659. * @hidden
  106660. */
  106661. _attachCameras(cameras: Camera[]): void;
  106662. /**
  106663. * Detatches the effect on cameras
  106664. * @param cameras The camera to detatch from.
  106665. * @hidden
  106666. */
  106667. _detachCameras(cameras: Camera): void;
  106668. /**
  106669. * Detatches the effect on cameras
  106670. * @param cameras The camera to detatch from.
  106671. * @hidden
  106672. */
  106673. _detachCameras(cameras: Camera[]): void;
  106674. /**
  106675. * Enables the effect on given cameras
  106676. * @param cameras The camera to enable.
  106677. * @hidden
  106678. */
  106679. _enable(cameras: Camera): void;
  106680. /**
  106681. * Enables the effect on given cameras
  106682. * @param cameras The camera to enable.
  106683. * @hidden
  106684. */
  106685. _enable(cameras: Nullable<Camera[]>): void;
  106686. /**
  106687. * Disables the effect on the given cameras
  106688. * @param cameras The camera to disable.
  106689. * @hidden
  106690. */
  106691. _disable(cameras: Camera): void;
  106692. /**
  106693. * Disables the effect on the given cameras
  106694. * @param cameras The camera to disable.
  106695. * @hidden
  106696. */
  106697. _disable(cameras: Nullable<Camera[]>): void;
  106698. /**
  106699. * Gets a list of the post processes contained in the effect.
  106700. * @param camera The camera to get the post processes on.
  106701. * @returns The list of the post processes in the effect.
  106702. */
  106703. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  106704. }
  106705. }
  106706. declare module BABYLON {
  106707. /** @hidden */
  106708. export var extractHighlightsPixelShader: {
  106709. name: string;
  106710. shader: string;
  106711. };
  106712. }
  106713. declare module BABYLON {
  106714. /**
  106715. * 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.
  106716. */
  106717. export class ExtractHighlightsPostProcess extends PostProcess {
  106718. /**
  106719. * The luminance threshold, pixels below this value will be set to black.
  106720. */
  106721. threshold: number;
  106722. /** @hidden */
  106723. _exposure: number;
  106724. /**
  106725. * Post process which has the input texture to be used when performing highlight extraction
  106726. * @hidden
  106727. */
  106728. _inputPostProcess: Nullable<PostProcess>;
  106729. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106730. }
  106731. }
  106732. declare module BABYLON {
  106733. /** @hidden */
  106734. export var bloomMergePixelShader: {
  106735. name: string;
  106736. shader: string;
  106737. };
  106738. }
  106739. declare module BABYLON {
  106740. /**
  106741. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106742. */
  106743. export class BloomMergePostProcess extends PostProcess {
  106744. /** Weight of the bloom to be added to the original input. */
  106745. weight: number;
  106746. /**
  106747. * Creates a new instance of @see BloomMergePostProcess
  106748. * @param name The name of the effect.
  106749. * @param originalFromInput Post process which's input will be used for the merge.
  106750. * @param blurred Blurred highlights post process which's output will be used.
  106751. * @param weight Weight of the bloom to be added to the original input.
  106752. * @param options The required width/height ratio to downsize to before computing the render pass.
  106753. * @param camera The camera to apply the render pass to.
  106754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106755. * @param engine The engine which the post process will be applied. (default: current engine)
  106756. * @param reusable If the post process can be reused on the same frame. (default: false)
  106757. * @param textureType Type of textures used when performing the post process. (default: 0)
  106758. * @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)
  106759. */
  106760. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  106761. /** Weight of the bloom to be added to the original input. */
  106762. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106763. }
  106764. }
  106765. declare module BABYLON {
  106766. /**
  106767. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  106768. */
  106769. export class BloomEffect extends PostProcessRenderEffect {
  106770. private bloomScale;
  106771. /**
  106772. * @hidden Internal
  106773. */
  106774. _effects: Array<PostProcess>;
  106775. /**
  106776. * @hidden Internal
  106777. */
  106778. _downscale: ExtractHighlightsPostProcess;
  106779. private _blurX;
  106780. private _blurY;
  106781. private _merge;
  106782. /**
  106783. * The luminance threshold to find bright areas of the image to bloom.
  106784. */
  106785. threshold: number;
  106786. /**
  106787. * The strength of the bloom.
  106788. */
  106789. weight: number;
  106790. /**
  106791. * Specifies the size of the bloom blur kernel, relative to the final output size
  106792. */
  106793. kernel: number;
  106794. /**
  106795. * Creates a new instance of @see BloomEffect
  106796. * @param scene The scene the effect belongs to.
  106797. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  106798. * @param bloomKernel The size of the kernel to be used when applying the blur.
  106799. * @param bloomWeight The the strength of bloom.
  106800. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106801. * @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)
  106802. */
  106803. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  106804. /**
  106805. * Disposes each of the internal effects for a given camera.
  106806. * @param camera The camera to dispose the effect on.
  106807. */
  106808. disposeEffects(camera: Camera): void;
  106809. /**
  106810. * @hidden Internal
  106811. */
  106812. _updateEffects(): void;
  106813. /**
  106814. * Internal
  106815. * @returns if all the contained post processes are ready.
  106816. * @hidden
  106817. */
  106818. _isReady(): boolean;
  106819. }
  106820. }
  106821. declare module BABYLON {
  106822. /** @hidden */
  106823. export var chromaticAberrationPixelShader: {
  106824. name: string;
  106825. shader: string;
  106826. };
  106827. }
  106828. declare module BABYLON {
  106829. /**
  106830. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  106831. */
  106832. export class ChromaticAberrationPostProcess extends PostProcess {
  106833. /**
  106834. * The amount of seperation of rgb channels (default: 30)
  106835. */
  106836. aberrationAmount: number;
  106837. /**
  106838. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  106839. */
  106840. radialIntensity: number;
  106841. /**
  106842. * 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))
  106843. */
  106844. direction: Vector2;
  106845. /**
  106846. * 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))
  106847. */
  106848. centerPosition: Vector2;
  106849. /**
  106850. * Creates a new instance ChromaticAberrationPostProcess
  106851. * @param name The name of the effect.
  106852. * @param screenWidth The width of the screen to apply the effect on.
  106853. * @param screenHeight The height of the screen to apply the effect on.
  106854. * @param options The required width/height ratio to downsize to before computing the render pass.
  106855. * @param camera The camera to apply the render pass to.
  106856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106857. * @param engine The engine which the post process will be applied. (default: current engine)
  106858. * @param reusable If the post process can be reused on the same frame. (default: false)
  106859. * @param textureType Type of textures used when performing the post process. (default: 0)
  106860. * @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)
  106861. */
  106862. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106863. }
  106864. }
  106865. declare module BABYLON {
  106866. /** @hidden */
  106867. export var circleOfConfusionPixelShader: {
  106868. name: string;
  106869. shader: string;
  106870. };
  106871. }
  106872. declare module BABYLON {
  106873. /**
  106874. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  106875. */
  106876. export class CircleOfConfusionPostProcess extends PostProcess {
  106877. /**
  106878. * 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.
  106879. */
  106880. lensSize: number;
  106881. /**
  106882. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106883. */
  106884. fStop: number;
  106885. /**
  106886. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106887. */
  106888. focusDistance: number;
  106889. /**
  106890. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  106891. */
  106892. focalLength: number;
  106893. private _depthTexture;
  106894. /**
  106895. * Creates a new instance CircleOfConfusionPostProcess
  106896. * @param name The name of the effect.
  106897. * @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.
  106898. * @param options The required width/height ratio to downsize to before computing the render pass.
  106899. * @param camera The camera to apply the render pass to.
  106900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106901. * @param engine The engine which the post process will be applied. (default: current engine)
  106902. * @param reusable If the post process can be reused on the same frame. (default: false)
  106903. * @param textureType Type of textures used when performing the post process. (default: 0)
  106904. * @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)
  106905. */
  106906. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106907. /**
  106908. * 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.
  106909. */
  106910. depthTexture: RenderTargetTexture;
  106911. }
  106912. }
  106913. declare module BABYLON {
  106914. /** @hidden */
  106915. export var colorCorrectionPixelShader: {
  106916. name: string;
  106917. shader: string;
  106918. };
  106919. }
  106920. declare module BABYLON {
  106921. /**
  106922. *
  106923. * This post-process allows the modification of rendered colors by using
  106924. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106925. *
  106926. * The object needs to be provided an url to a texture containing the color
  106927. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106928. * Use an image editing software to tweak the LUT to match your needs.
  106929. *
  106930. * For an example of a color LUT, see here:
  106931. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106932. * For explanations on color grading, see here:
  106933. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106934. *
  106935. */
  106936. export class ColorCorrectionPostProcess extends PostProcess {
  106937. private _colorTableTexture;
  106938. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106939. }
  106940. }
  106941. declare module BABYLON {
  106942. /** @hidden */
  106943. export var convolutionPixelShader: {
  106944. name: string;
  106945. shader: string;
  106946. };
  106947. }
  106948. declare module BABYLON {
  106949. /**
  106950. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106951. * input texture to perform effects such as edge detection or sharpening
  106952. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106953. */
  106954. export class ConvolutionPostProcess extends PostProcess {
  106955. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106956. kernel: number[];
  106957. /**
  106958. * Creates a new instance ConvolutionPostProcess
  106959. * @param name The name of the effect.
  106960. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106961. * @param options The required width/height ratio to downsize to before computing the render pass.
  106962. * @param camera The camera to apply the render pass to.
  106963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106964. * @param engine The engine which the post process will be applied. (default: current engine)
  106965. * @param reusable If the post process can be reused on the same frame. (default: false)
  106966. * @param textureType Type of textures used when performing the post process. (default: 0)
  106967. */
  106968. constructor(name: string,
  106969. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106970. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106971. /**
  106972. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106973. */
  106974. static EdgeDetect0Kernel: number[];
  106975. /**
  106976. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106977. */
  106978. static EdgeDetect1Kernel: number[];
  106979. /**
  106980. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106981. */
  106982. static EdgeDetect2Kernel: number[];
  106983. /**
  106984. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106985. */
  106986. static SharpenKernel: number[];
  106987. /**
  106988. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106989. */
  106990. static EmbossKernel: number[];
  106991. /**
  106992. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106993. */
  106994. static GaussianKernel: number[];
  106995. }
  106996. }
  106997. declare module BABYLON {
  106998. /**
  106999. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107000. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107001. * based on samples that have a large difference in distance than the center pixel.
  107002. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107003. */
  107004. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107005. direction: Vector2;
  107006. /**
  107007. * Creates a new instance CircleOfConfusionPostProcess
  107008. * @param name The name of the effect.
  107009. * @param scene The scene the effect belongs to.
  107010. * @param direction The direction the blur should be applied.
  107011. * @param kernel The size of the kernel used to blur.
  107012. * @param options The required width/height ratio to downsize to before computing the render pass.
  107013. * @param camera The camera to apply the render pass to.
  107014. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107015. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107017. * @param engine The engine which the post process will be applied. (default: current engine)
  107018. * @param reusable If the post process can be reused on the same frame. (default: false)
  107019. * @param textureType Type of textures used when performing the post process. (default: 0)
  107020. * @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)
  107021. */
  107022. 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);
  107023. }
  107024. }
  107025. declare module BABYLON {
  107026. /** @hidden */
  107027. export var depthOfFieldMergePixelShader: {
  107028. name: string;
  107029. shader: string;
  107030. };
  107031. }
  107032. declare module BABYLON {
  107033. /**
  107034. * Options to be set when merging outputs from the default pipeline.
  107035. */
  107036. export class DepthOfFieldMergePostProcessOptions {
  107037. /**
  107038. * The original image to merge on top of
  107039. */
  107040. originalFromInput: PostProcess;
  107041. /**
  107042. * Parameters to perform the merge of the depth of field effect
  107043. */
  107044. depthOfField?: {
  107045. circleOfConfusion: PostProcess;
  107046. blurSteps: Array<PostProcess>;
  107047. };
  107048. /**
  107049. * Parameters to perform the merge of bloom effect
  107050. */
  107051. bloom?: {
  107052. blurred: PostProcess;
  107053. weight: number;
  107054. };
  107055. }
  107056. /**
  107057. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107058. */
  107059. export class DepthOfFieldMergePostProcess extends PostProcess {
  107060. private blurSteps;
  107061. /**
  107062. * Creates a new instance of DepthOfFieldMergePostProcess
  107063. * @param name The name of the effect.
  107064. * @param originalFromInput Post process which's input will be used for the merge.
  107065. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  107066. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  107067. * @param options The required width/height ratio to downsize to before computing the render pass.
  107068. * @param camera The camera to apply the render pass to.
  107069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107070. * @param engine The engine which the post process will be applied. (default: current engine)
  107071. * @param reusable If the post process can be reused on the same frame. (default: false)
  107072. * @param textureType Type of textures used when performing the post process. (default: 0)
  107073. * @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)
  107074. */
  107075. 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);
  107076. /**
  107077. * Updates the effect with the current post process compile time values and recompiles the shader.
  107078. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107079. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107080. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107081. * @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
  107082. * @param onCompiled Called when the shader has been compiled.
  107083. * @param onError Called if there is an error when compiling a shader.
  107084. */
  107085. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107086. }
  107087. }
  107088. declare module BABYLON {
  107089. /**
  107090. * Specifies the level of max blur that should be applied when using the depth of field effect
  107091. */
  107092. export enum DepthOfFieldEffectBlurLevel {
  107093. /**
  107094. * Subtle blur
  107095. */
  107096. Low = 0,
  107097. /**
  107098. * Medium blur
  107099. */
  107100. Medium = 1,
  107101. /**
  107102. * Large blur
  107103. */
  107104. High = 2
  107105. }
  107106. /**
  107107. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  107108. */
  107109. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  107110. private _circleOfConfusion;
  107111. /**
  107112. * @hidden Internal, blurs from high to low
  107113. */
  107114. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  107115. private _depthOfFieldBlurY;
  107116. private _dofMerge;
  107117. /**
  107118. * @hidden Internal post processes in depth of field effect
  107119. */
  107120. _effects: Array<PostProcess>;
  107121. /**
  107122. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  107123. */
  107124. focalLength: number;
  107125. /**
  107126. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107127. */
  107128. fStop: number;
  107129. /**
  107130. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107131. */
  107132. focusDistance: number;
  107133. /**
  107134. * 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.
  107135. */
  107136. lensSize: number;
  107137. /**
  107138. * Creates a new instance DepthOfFieldEffect
  107139. * @param scene The scene the effect belongs to.
  107140. * @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.
  107141. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107142. * @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)
  107143. */
  107144. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  107145. /**
  107146. * 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.
  107147. */
  107148. depthTexture: RenderTargetTexture;
  107149. /**
  107150. * Disposes each of the internal effects for a given camera.
  107151. * @param camera The camera to dispose the effect on.
  107152. */
  107153. disposeEffects(camera: Camera): void;
  107154. /**
  107155. * @hidden Internal
  107156. */
  107157. _updateEffects(): void;
  107158. /**
  107159. * Internal
  107160. * @returns if all the contained post processes are ready.
  107161. * @hidden
  107162. */
  107163. _isReady(): boolean;
  107164. }
  107165. }
  107166. declare module BABYLON {
  107167. /** @hidden */
  107168. export var displayPassPixelShader: {
  107169. name: string;
  107170. shader: string;
  107171. };
  107172. }
  107173. declare module BABYLON {
  107174. /**
  107175. * DisplayPassPostProcess which produces an output the same as it's input
  107176. */
  107177. export class DisplayPassPostProcess extends PostProcess {
  107178. /**
  107179. * Creates the DisplayPassPostProcess
  107180. * @param name The name of the effect.
  107181. * @param options The required width/height ratio to downsize to before computing the render pass.
  107182. * @param camera The camera to apply the render pass to.
  107183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107184. * @param engine The engine which the post process will be applied. (default: current engine)
  107185. * @param reusable If the post process can be reused on the same frame. (default: false)
  107186. */
  107187. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107188. }
  107189. }
  107190. declare module BABYLON {
  107191. /** @hidden */
  107192. export var filterPixelShader: {
  107193. name: string;
  107194. shader: string;
  107195. };
  107196. }
  107197. declare module BABYLON {
  107198. /**
  107199. * Applies a kernel filter to the image
  107200. */
  107201. export class FilterPostProcess extends PostProcess {
  107202. /** The matrix to be applied to the image */
  107203. kernelMatrix: Matrix;
  107204. /**
  107205. *
  107206. * @param name The name of the effect.
  107207. * @param kernelMatrix The matrix to be applied to the image
  107208. * @param options The required width/height ratio to downsize to before computing the render pass.
  107209. * @param camera The camera to apply the render pass to.
  107210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107211. * @param engine The engine which the post process will be applied. (default: current engine)
  107212. * @param reusable If the post process can be reused on the same frame. (default: false)
  107213. */
  107214. constructor(name: string,
  107215. /** The matrix to be applied to the image */
  107216. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107217. }
  107218. }
  107219. declare module BABYLON {
  107220. /** @hidden */
  107221. export var fxaaPixelShader: {
  107222. name: string;
  107223. shader: string;
  107224. };
  107225. }
  107226. declare module BABYLON {
  107227. /** @hidden */
  107228. export var fxaaVertexShader: {
  107229. name: string;
  107230. shader: string;
  107231. };
  107232. }
  107233. declare module BABYLON {
  107234. /**
  107235. * Fxaa post process
  107236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  107237. */
  107238. export class FxaaPostProcess extends PostProcess {
  107239. /** @hidden */
  107240. texelWidth: number;
  107241. /** @hidden */
  107242. texelHeight: number;
  107243. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107244. private _getDefines;
  107245. }
  107246. }
  107247. declare module BABYLON {
  107248. /** @hidden */
  107249. export var grainPixelShader: {
  107250. name: string;
  107251. shader: string;
  107252. };
  107253. }
  107254. declare module BABYLON {
  107255. /**
  107256. * The GrainPostProcess adds noise to the image at mid luminance levels
  107257. */
  107258. export class GrainPostProcess extends PostProcess {
  107259. /**
  107260. * The intensity of the grain added (default: 30)
  107261. */
  107262. intensity: number;
  107263. /**
  107264. * If the grain should be randomized on every frame
  107265. */
  107266. animated: boolean;
  107267. /**
  107268. * Creates a new instance of @see GrainPostProcess
  107269. * @param name The name of the effect.
  107270. * @param options The required width/height ratio to downsize to before computing the render pass.
  107271. * @param camera The camera to apply the render pass to.
  107272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107273. * @param engine The engine which the post process will be applied. (default: current engine)
  107274. * @param reusable If the post process can be reused on the same frame. (default: false)
  107275. * @param textureType Type of textures used when performing the post process. (default: 0)
  107276. * @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)
  107277. */
  107278. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /** @hidden */
  107283. export var highlightsPixelShader: {
  107284. name: string;
  107285. shader: string;
  107286. };
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * Extracts highlights from the image
  107291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107292. */
  107293. export class HighlightsPostProcess extends PostProcess {
  107294. /**
  107295. * Extracts highlights from the image
  107296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107297. * @param name The name of the effect.
  107298. * @param options The required width/height ratio to downsize to before computing the render pass.
  107299. * @param camera The camera to apply the render pass to.
  107300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107301. * @param engine The engine which the post process will be applied. (default: current engine)
  107302. * @param reusable If the post process can be reused on the same frame. (default: false)
  107303. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  107304. */
  107305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107306. }
  107307. }
  107308. declare module BABYLON {
  107309. /** @hidden */
  107310. export var mrtFragmentDeclaration: {
  107311. name: string;
  107312. shader: string;
  107313. };
  107314. }
  107315. declare module BABYLON {
  107316. /** @hidden */
  107317. export var geometryPixelShader: {
  107318. name: string;
  107319. shader: string;
  107320. };
  107321. }
  107322. declare module BABYLON {
  107323. /** @hidden */
  107324. export var geometryVertexShader: {
  107325. name: string;
  107326. shader: string;
  107327. };
  107328. }
  107329. declare module BABYLON {
  107330. /**
  107331. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107332. */
  107333. export class GeometryBufferRenderer {
  107334. /**
  107335. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107336. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107337. */
  107338. static readonly POSITION_TEXTURE_TYPE: number;
  107339. /**
  107340. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107341. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107342. */
  107343. static readonly VELOCITY_TEXTURE_TYPE: number;
  107344. /**
  107345. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107346. * in order to compute objects velocities when enableVelocity is set to "true"
  107347. * @hidden
  107348. */
  107349. _previousTransformationMatrices: {
  107350. [index: number]: Matrix;
  107351. };
  107352. private _scene;
  107353. private _multiRenderTarget;
  107354. private _ratio;
  107355. private _enablePosition;
  107356. private _enableVelocity;
  107357. private _positionIndex;
  107358. private _velocityIndex;
  107359. protected _effect: Effect;
  107360. protected _cachedDefines: string;
  107361. /**
  107362. * Set the render list (meshes to be rendered) used in the G buffer.
  107363. */
  107364. renderList: Mesh[];
  107365. /**
  107366. * Gets wether or not G buffer are supported by the running hardware.
  107367. * This requires draw buffer supports
  107368. */
  107369. readonly isSupported: boolean;
  107370. /**
  107371. * Returns the index of the given texture type in the G-Buffer textures array
  107372. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107373. * @returns the index of the given texture type in the G-Buffer textures array
  107374. */
  107375. getTextureIndex(textureType: number): number;
  107376. /**
  107377. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107378. */
  107379. /**
  107380. * Sets whether or not objects positions are enabled for the G buffer.
  107381. */
  107382. enablePosition: boolean;
  107383. /**
  107384. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107385. */
  107386. /**
  107387. * Sets wether or not objects velocities are enabled for the G buffer.
  107388. */
  107389. enableVelocity: boolean;
  107390. /**
  107391. * Gets the scene associated with the buffer.
  107392. */
  107393. readonly scene: Scene;
  107394. /**
  107395. * Gets the ratio used by the buffer during its creation.
  107396. * How big is the buffer related to the main canvas.
  107397. */
  107398. readonly ratio: number;
  107399. /** @hidden */
  107400. static _SceneComponentInitialization: (scene: Scene) => void;
  107401. /**
  107402. * Creates a new G Buffer for the scene
  107403. * @param scene The scene the buffer belongs to
  107404. * @param ratio How big is the buffer related to the main canvas.
  107405. */
  107406. constructor(scene: Scene, ratio?: number);
  107407. /**
  107408. * Checks wether everything is ready to render a submesh to the G buffer.
  107409. * @param subMesh the submesh to check readiness for
  107410. * @param useInstances is the mesh drawn using instance or not
  107411. * @returns true if ready otherwise false
  107412. */
  107413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107414. /**
  107415. * Gets the current underlying G Buffer.
  107416. * @returns the buffer
  107417. */
  107418. getGBuffer(): MultiRenderTarget;
  107419. /**
  107420. * Gets the number of samples used to render the buffer (anti aliasing).
  107421. */
  107422. /**
  107423. * Sets the number of samples used to render the buffer (anti aliasing).
  107424. */
  107425. samples: number;
  107426. /**
  107427. * Disposes the renderer and frees up associated resources.
  107428. */
  107429. dispose(): void;
  107430. protected _createRenderTargets(): void;
  107431. }
  107432. }
  107433. declare module BABYLON {
  107434. /** @hidden */
  107435. export var motionBlurPixelShader: {
  107436. name: string;
  107437. shader: string;
  107438. };
  107439. }
  107440. declare module BABYLON {
  107441. /**
  107442. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  107443. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  107444. * As an example, all you have to do is to create the post-process:
  107445. * var mb = new BABYLON.MotionBlurPostProcess(
  107446. * 'mb', // The name of the effect.
  107447. * scene, // The scene containing the objects to blur according to their velocity.
  107448. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  107449. * camera // The camera to apply the render pass to.
  107450. * );
  107451. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  107452. */
  107453. export class MotionBlurPostProcess extends PostProcess {
  107454. /**
  107455. * Defines how much the image is blurred by the movement. Default value is equal to 1
  107456. */
  107457. motionStrength: number;
  107458. /**
  107459. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  107460. */
  107461. /**
  107462. * Sets the number of iterations to be used for motion blur quality
  107463. */
  107464. motionBlurSamples: number;
  107465. private _motionBlurSamples;
  107466. private _geometryBufferRenderer;
  107467. /**
  107468. * Creates a new instance MotionBlurPostProcess
  107469. * @param name The name of the effect.
  107470. * @param scene The scene containing the objects to blur according to their velocity.
  107471. * @param options The required width/height ratio to downsize to before computing the render pass.
  107472. * @param camera The camera to apply the render pass to.
  107473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107474. * @param engine The engine which the post process will be applied. (default: current engine)
  107475. * @param reusable If the post process can be reused on the same frame. (default: false)
  107476. * @param textureType Type of textures used when performing the post process. (default: 0)
  107477. * @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)
  107478. */
  107479. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107480. /**
  107481. * Disposes the post process.
  107482. * @param camera The camera to dispose the post process on.
  107483. */
  107484. dispose(camera?: Camera): void;
  107485. }
  107486. }
  107487. declare module BABYLON {
  107488. /** @hidden */
  107489. export var refractionPixelShader: {
  107490. name: string;
  107491. shader: string;
  107492. };
  107493. }
  107494. declare module BABYLON {
  107495. /**
  107496. * Post process which applies a refractin texture
  107497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107498. */
  107499. export class RefractionPostProcess extends PostProcess {
  107500. /** the base color of the refraction (used to taint the rendering) */
  107501. color: Color3;
  107502. /** simulated refraction depth */
  107503. depth: number;
  107504. /** the coefficient of the base color (0 to remove base color tainting) */
  107505. colorLevel: number;
  107506. private _refTexture;
  107507. private _ownRefractionTexture;
  107508. /**
  107509. * Gets or sets the refraction texture
  107510. * Please note that you are responsible for disposing the texture if you set it manually
  107511. */
  107512. refractionTexture: Texture;
  107513. /**
  107514. * Initializes the RefractionPostProcess
  107515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107516. * @param name The name of the effect.
  107517. * @param refractionTextureUrl Url of the refraction texture to use
  107518. * @param color the base color of the refraction (used to taint the rendering)
  107519. * @param depth simulated refraction depth
  107520. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  107521. * @param camera The camera to apply the render pass to.
  107522. * @param options The required width/height ratio to downsize to before computing the render pass.
  107523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107524. * @param engine The engine which the post process will be applied. (default: current engine)
  107525. * @param reusable If the post process can be reused on the same frame. (default: false)
  107526. */
  107527. constructor(name: string, refractionTextureUrl: string,
  107528. /** the base color of the refraction (used to taint the rendering) */
  107529. color: Color3,
  107530. /** simulated refraction depth */
  107531. depth: number,
  107532. /** the coefficient of the base color (0 to remove base color tainting) */
  107533. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107534. /**
  107535. * Disposes of the post process
  107536. * @param camera Camera to dispose post process on
  107537. */
  107538. dispose(camera: Camera): void;
  107539. }
  107540. }
  107541. declare module BABYLON {
  107542. /** @hidden */
  107543. export var sharpenPixelShader: {
  107544. name: string;
  107545. shader: string;
  107546. };
  107547. }
  107548. declare module BABYLON {
  107549. /**
  107550. * The SharpenPostProcess applies a sharpen kernel to every pixel
  107551. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107552. */
  107553. export class SharpenPostProcess extends PostProcess {
  107554. /**
  107555. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  107556. */
  107557. colorAmount: number;
  107558. /**
  107559. * How much sharpness should be applied (default: 0.3)
  107560. */
  107561. edgeAmount: number;
  107562. /**
  107563. * Creates a new instance ConvolutionPostProcess
  107564. * @param name The name of the effect.
  107565. * @param options The required width/height ratio to downsize to before computing the render pass.
  107566. * @param camera The camera to apply the render pass to.
  107567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107568. * @param engine The engine which the post process will be applied. (default: current engine)
  107569. * @param reusable If the post process can be reused on the same frame. (default: false)
  107570. * @param textureType Type of textures used when performing the post process. (default: 0)
  107571. * @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)
  107572. */
  107573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * PostProcessRenderPipeline
  107579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107580. */
  107581. export class PostProcessRenderPipeline {
  107582. private engine;
  107583. private _renderEffects;
  107584. private _renderEffectsForIsolatedPass;
  107585. /**
  107586. * @hidden
  107587. */
  107588. protected _cameras: Camera[];
  107589. /** @hidden */
  107590. _name: string;
  107591. /**
  107592. * Gets pipeline name
  107593. */
  107594. readonly name: string;
  107595. /**
  107596. * Initializes a PostProcessRenderPipeline
  107597. * @param engine engine to add the pipeline to
  107598. * @param name name of the pipeline
  107599. */
  107600. constructor(engine: Engine, name: string);
  107601. /**
  107602. * Gets the class name
  107603. * @returns "PostProcessRenderPipeline"
  107604. */
  107605. getClassName(): string;
  107606. /**
  107607. * If all the render effects in the pipeline are supported
  107608. */
  107609. readonly isSupported: boolean;
  107610. /**
  107611. * Adds an effect to the pipeline
  107612. * @param renderEffect the effect to add
  107613. */
  107614. addEffect(renderEffect: PostProcessRenderEffect): void;
  107615. /** @hidden */
  107616. _rebuild(): void;
  107617. /** @hidden */
  107618. _enableEffect(renderEffectName: string, cameras: Camera): void;
  107619. /** @hidden */
  107620. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  107621. /** @hidden */
  107622. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107623. /** @hidden */
  107624. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107625. /** @hidden */
  107626. _attachCameras(cameras: Camera, unique: boolean): void;
  107627. /** @hidden */
  107628. _attachCameras(cameras: Camera[], unique: boolean): void;
  107629. /** @hidden */
  107630. _detachCameras(cameras: Camera): void;
  107631. /** @hidden */
  107632. _detachCameras(cameras: Nullable<Camera[]>): void;
  107633. /** @hidden */
  107634. _update(): void;
  107635. /** @hidden */
  107636. _reset(): void;
  107637. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  107638. /**
  107639. * Disposes of the pipeline
  107640. */
  107641. dispose(): void;
  107642. }
  107643. }
  107644. declare module BABYLON {
  107645. /**
  107646. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  107647. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107648. */
  107649. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107650. private _scene;
  107651. private _camerasToBeAttached;
  107652. /**
  107653. * ID of the sharpen post process,
  107654. */
  107655. private readonly SharpenPostProcessId;
  107656. /**
  107657. * @ignore
  107658. * ID of the image processing post process;
  107659. */
  107660. readonly ImageProcessingPostProcessId: string;
  107661. /**
  107662. * @ignore
  107663. * ID of the Fast Approximate Anti-Aliasing post process;
  107664. */
  107665. readonly FxaaPostProcessId: string;
  107666. /**
  107667. * ID of the chromatic aberration post process,
  107668. */
  107669. private readonly ChromaticAberrationPostProcessId;
  107670. /**
  107671. * ID of the grain post process
  107672. */
  107673. private readonly GrainPostProcessId;
  107674. /**
  107675. * Sharpen post process which will apply a sharpen convolution to enhance edges
  107676. */
  107677. sharpen: SharpenPostProcess;
  107678. private _sharpenEffect;
  107679. private bloom;
  107680. /**
  107681. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  107682. */
  107683. depthOfField: DepthOfFieldEffect;
  107684. /**
  107685. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107686. */
  107687. fxaa: FxaaPostProcess;
  107688. /**
  107689. * Image post processing pass used to perform operations such as tone mapping or color grading.
  107690. */
  107691. imageProcessing: ImageProcessingPostProcess;
  107692. /**
  107693. * Chromatic aberration post process which will shift rgb colors in the image
  107694. */
  107695. chromaticAberration: ChromaticAberrationPostProcess;
  107696. private _chromaticAberrationEffect;
  107697. /**
  107698. * Grain post process which add noise to the image
  107699. */
  107700. grain: GrainPostProcess;
  107701. private _grainEffect;
  107702. /**
  107703. * Glow post process which adds a glow to emissive areas of the image
  107704. */
  107705. private _glowLayer;
  107706. /**
  107707. * Animations which can be used to tweak settings over a period of time
  107708. */
  107709. animations: Animation[];
  107710. private _imageProcessingConfigurationObserver;
  107711. private _sharpenEnabled;
  107712. private _bloomEnabled;
  107713. private _depthOfFieldEnabled;
  107714. private _depthOfFieldBlurLevel;
  107715. private _fxaaEnabled;
  107716. private _imageProcessingEnabled;
  107717. private _defaultPipelineTextureType;
  107718. private _bloomScale;
  107719. private _chromaticAberrationEnabled;
  107720. private _grainEnabled;
  107721. private _buildAllowed;
  107722. /**
  107723. * Gets active scene
  107724. */
  107725. readonly scene: Scene;
  107726. /**
  107727. * Enable or disable the sharpen process from the pipeline
  107728. */
  107729. sharpenEnabled: boolean;
  107730. private _resizeObserver;
  107731. private _hardwareScaleLevel;
  107732. private _bloomKernel;
  107733. /**
  107734. * Specifies the size of the bloom blur kernel, relative to the final output size
  107735. */
  107736. bloomKernel: number;
  107737. /**
  107738. * Specifies the weight of the bloom in the final rendering
  107739. */
  107740. private _bloomWeight;
  107741. /**
  107742. * Specifies the luma threshold for the area that will be blurred by the bloom
  107743. */
  107744. private _bloomThreshold;
  107745. private _hdr;
  107746. /**
  107747. * The strength of the bloom.
  107748. */
  107749. bloomWeight: number;
  107750. /**
  107751. * The strength of the bloom.
  107752. */
  107753. bloomThreshold: number;
  107754. /**
  107755. * The scale of the bloom, lower value will provide better performance.
  107756. */
  107757. bloomScale: number;
  107758. /**
  107759. * Enable or disable the bloom from the pipeline
  107760. */
  107761. bloomEnabled: boolean;
  107762. private _rebuildBloom;
  107763. /**
  107764. * If the depth of field is enabled.
  107765. */
  107766. depthOfFieldEnabled: boolean;
  107767. /**
  107768. * Blur level of the depth of field effect. (Higher blur will effect performance)
  107769. */
  107770. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  107771. /**
  107772. * If the anti aliasing is enabled.
  107773. */
  107774. fxaaEnabled: boolean;
  107775. private _samples;
  107776. /**
  107777. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107778. */
  107779. samples: number;
  107780. /**
  107781. * If image processing is enabled.
  107782. */
  107783. imageProcessingEnabled: boolean;
  107784. /**
  107785. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  107786. */
  107787. glowLayerEnabled: boolean;
  107788. /**
  107789. * Enable or disable the chromaticAberration process from the pipeline
  107790. */
  107791. chromaticAberrationEnabled: boolean;
  107792. /**
  107793. * Enable or disable the grain process from the pipeline
  107794. */
  107795. grainEnabled: boolean;
  107796. /**
  107797. * @constructor
  107798. * @param name - The rendering pipeline name (default: "")
  107799. * @param hdr - If high dynamic range textures should be used (default: true)
  107800. * @param scene - The scene linked to this pipeline (default: the last created scene)
  107801. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  107802. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  107803. */
  107804. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  107805. /**
  107806. * Get the class name
  107807. * @returns "DefaultRenderingPipeline"
  107808. */
  107809. getClassName(): string;
  107810. /**
  107811. * Force the compilation of the entire pipeline.
  107812. */
  107813. prepare(): void;
  107814. private _hasCleared;
  107815. private _prevPostProcess;
  107816. private _prevPrevPostProcess;
  107817. private _setAutoClearAndTextureSharing;
  107818. private _depthOfFieldSceneObserver;
  107819. private _buildPipeline;
  107820. private _disposePostProcesses;
  107821. /**
  107822. * Adds a camera to the pipeline
  107823. * @param camera the camera to be added
  107824. */
  107825. addCamera(camera: Camera): void;
  107826. /**
  107827. * Removes a camera from the pipeline
  107828. * @param camera the camera to remove
  107829. */
  107830. removeCamera(camera: Camera): void;
  107831. /**
  107832. * Dispose of the pipeline and stop all post processes
  107833. */
  107834. dispose(): void;
  107835. /**
  107836. * Serialize the rendering pipeline (Used when exporting)
  107837. * @returns the serialized object
  107838. */
  107839. serialize(): any;
  107840. /**
  107841. * Parse the serialized pipeline
  107842. * @param source Source pipeline.
  107843. * @param scene The scene to load the pipeline to.
  107844. * @param rootUrl The URL of the serialized pipeline.
  107845. * @returns An instantiated pipeline from the serialized object.
  107846. */
  107847. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  107848. }
  107849. }
  107850. declare module BABYLON {
  107851. /** @hidden */
  107852. export var lensHighlightsPixelShader: {
  107853. name: string;
  107854. shader: string;
  107855. };
  107856. }
  107857. declare module BABYLON {
  107858. /** @hidden */
  107859. export var depthOfFieldPixelShader: {
  107860. name: string;
  107861. shader: string;
  107862. };
  107863. }
  107864. declare module BABYLON {
  107865. /**
  107866. * BABYLON.JS Chromatic Aberration GLSL Shader
  107867. * Author: Olivier Guyot
  107868. * Separates very slightly R, G and B colors on the edges of the screen
  107869. * Inspired by Francois Tarlier & Martins Upitis
  107870. */
  107871. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  107872. /**
  107873. * @ignore
  107874. * The chromatic aberration PostProcess id in the pipeline
  107875. */
  107876. LensChromaticAberrationEffect: string;
  107877. /**
  107878. * @ignore
  107879. * The highlights enhancing PostProcess id in the pipeline
  107880. */
  107881. HighlightsEnhancingEffect: string;
  107882. /**
  107883. * @ignore
  107884. * The depth-of-field PostProcess id in the pipeline
  107885. */
  107886. LensDepthOfFieldEffect: string;
  107887. private _scene;
  107888. private _depthTexture;
  107889. private _grainTexture;
  107890. private _chromaticAberrationPostProcess;
  107891. private _highlightsPostProcess;
  107892. private _depthOfFieldPostProcess;
  107893. private _edgeBlur;
  107894. private _grainAmount;
  107895. private _chromaticAberration;
  107896. private _distortion;
  107897. private _highlightsGain;
  107898. private _highlightsThreshold;
  107899. private _dofDistance;
  107900. private _dofAperture;
  107901. private _dofDarken;
  107902. private _dofPentagon;
  107903. private _blurNoise;
  107904. /**
  107905. * @constructor
  107906. *
  107907. * Effect parameters are as follow:
  107908. * {
  107909. * chromatic_aberration: number; // from 0 to x (1 for realism)
  107910. * edge_blur: number; // from 0 to x (1 for realism)
  107911. * distortion: number; // from 0 to x (1 for realism)
  107912. * grain_amount: number; // from 0 to 1
  107913. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  107914. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  107915. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  107916. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  107917. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  107918. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107919. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107920. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107921. * }
  107922. * Note: if an effect parameter is unset, effect is disabled
  107923. *
  107924. * @param name The rendering pipeline name
  107925. * @param parameters - An object containing all parameters (see above)
  107926. * @param scene The scene linked to this pipeline
  107927. * @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)
  107928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107929. */
  107930. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107931. /**
  107932. * Sets the amount of blur at the edges
  107933. * @param amount blur amount
  107934. */
  107935. setEdgeBlur(amount: number): void;
  107936. /**
  107937. * Sets edge blur to 0
  107938. */
  107939. disableEdgeBlur(): void;
  107940. /**
  107941. * Sets the amout of grain
  107942. * @param amount Amount of grain
  107943. */
  107944. setGrainAmount(amount: number): void;
  107945. /**
  107946. * Set grain amount to 0
  107947. */
  107948. disableGrain(): void;
  107949. /**
  107950. * Sets the chromatic aberration amount
  107951. * @param amount amount of chromatic aberration
  107952. */
  107953. setChromaticAberration(amount: number): void;
  107954. /**
  107955. * Sets chromatic aberration amount to 0
  107956. */
  107957. disableChromaticAberration(): void;
  107958. /**
  107959. * Sets the EdgeDistortion amount
  107960. * @param amount amount of EdgeDistortion
  107961. */
  107962. setEdgeDistortion(amount: number): void;
  107963. /**
  107964. * Sets edge distortion to 0
  107965. */
  107966. disableEdgeDistortion(): void;
  107967. /**
  107968. * Sets the FocusDistance amount
  107969. * @param amount amount of FocusDistance
  107970. */
  107971. setFocusDistance(amount: number): void;
  107972. /**
  107973. * Disables depth of field
  107974. */
  107975. disableDepthOfField(): void;
  107976. /**
  107977. * Sets the Aperture amount
  107978. * @param amount amount of Aperture
  107979. */
  107980. setAperture(amount: number): void;
  107981. /**
  107982. * Sets the DarkenOutOfFocus amount
  107983. * @param amount amount of DarkenOutOfFocus
  107984. */
  107985. setDarkenOutOfFocus(amount: number): void;
  107986. /**
  107987. * Creates a pentagon bokeh effect
  107988. */
  107989. enablePentagonBokeh(): void;
  107990. /**
  107991. * Disables the pentagon bokeh effect
  107992. */
  107993. disablePentagonBokeh(): void;
  107994. /**
  107995. * Enables noise blur
  107996. */
  107997. enableNoiseBlur(): void;
  107998. /**
  107999. * Disables noise blur
  108000. */
  108001. disableNoiseBlur(): void;
  108002. /**
  108003. * Sets the HighlightsGain amount
  108004. * @param amount amount of HighlightsGain
  108005. */
  108006. setHighlightsGain(amount: number): void;
  108007. /**
  108008. * Sets the HighlightsThreshold amount
  108009. * @param amount amount of HighlightsThreshold
  108010. */
  108011. setHighlightsThreshold(amount: number): void;
  108012. /**
  108013. * Disables highlights
  108014. */
  108015. disableHighlights(): void;
  108016. /**
  108017. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108018. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108019. */
  108020. dispose(disableDepthRender?: boolean): void;
  108021. private _createChromaticAberrationPostProcess;
  108022. private _createHighlightsPostProcess;
  108023. private _createDepthOfFieldPostProcess;
  108024. private _createGrainTexture;
  108025. }
  108026. }
  108027. declare module BABYLON {
  108028. /** @hidden */
  108029. export var ssao2PixelShader: {
  108030. name: string;
  108031. shader: string;
  108032. };
  108033. }
  108034. declare module BABYLON {
  108035. /** @hidden */
  108036. export var ssaoCombinePixelShader: {
  108037. name: string;
  108038. shader: string;
  108039. };
  108040. }
  108041. declare module BABYLON {
  108042. /**
  108043. * Render pipeline to produce ssao effect
  108044. */
  108045. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108046. /**
  108047. * @ignore
  108048. * The PassPostProcess id in the pipeline that contains the original scene color
  108049. */
  108050. SSAOOriginalSceneColorEffect: string;
  108051. /**
  108052. * @ignore
  108053. * The SSAO PostProcess id in the pipeline
  108054. */
  108055. SSAORenderEffect: string;
  108056. /**
  108057. * @ignore
  108058. * The horizontal blur PostProcess id in the pipeline
  108059. */
  108060. SSAOBlurHRenderEffect: string;
  108061. /**
  108062. * @ignore
  108063. * The vertical blur PostProcess id in the pipeline
  108064. */
  108065. SSAOBlurVRenderEffect: string;
  108066. /**
  108067. * @ignore
  108068. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108069. */
  108070. SSAOCombineRenderEffect: string;
  108071. /**
  108072. * The output strength of the SSAO post-process. Default value is 1.0.
  108073. */
  108074. totalStrength: number;
  108075. /**
  108076. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  108077. */
  108078. maxZ: number;
  108079. /**
  108080. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  108081. */
  108082. minZAspect: number;
  108083. private _samples;
  108084. /**
  108085. * Number of samples used for the SSAO calculations. Default value is 8
  108086. */
  108087. samples: number;
  108088. private _textureSamples;
  108089. /**
  108090. * Number of samples to use for antialiasing
  108091. */
  108092. textureSamples: number;
  108093. /**
  108094. * Ratio object used for SSAO ratio and blur ratio
  108095. */
  108096. private _ratio;
  108097. /**
  108098. * Dynamically generated sphere sampler.
  108099. */
  108100. private _sampleSphere;
  108101. /**
  108102. * Blur filter offsets
  108103. */
  108104. private _samplerOffsets;
  108105. private _expensiveBlur;
  108106. /**
  108107. * If bilateral blur should be used
  108108. */
  108109. expensiveBlur: boolean;
  108110. /**
  108111. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  108112. */
  108113. radius: number;
  108114. /**
  108115. * The base color of the SSAO post-process
  108116. * The final result is "base + ssao" between [0, 1]
  108117. */
  108118. base: number;
  108119. /**
  108120. * Support test.
  108121. */
  108122. static readonly IsSupported: boolean;
  108123. private _scene;
  108124. private _depthTexture;
  108125. private _normalTexture;
  108126. private _randomTexture;
  108127. private _originalColorPostProcess;
  108128. private _ssaoPostProcess;
  108129. private _blurHPostProcess;
  108130. private _blurVPostProcess;
  108131. private _ssaoCombinePostProcess;
  108132. private _firstUpdate;
  108133. /**
  108134. * Gets active scene
  108135. */
  108136. readonly scene: Scene;
  108137. /**
  108138. * @constructor
  108139. * @param name The rendering pipeline name
  108140. * @param scene The scene linked to this pipeline
  108141. * @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 }
  108142. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108143. */
  108144. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  108145. /**
  108146. * Get the class name
  108147. * @returns "SSAO2RenderingPipeline"
  108148. */
  108149. getClassName(): string;
  108150. /**
  108151. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  108152. */
  108153. dispose(disableGeometryBufferRenderer?: boolean): void;
  108154. private _createBlurPostProcess;
  108155. /** @hidden */
  108156. _rebuild(): void;
  108157. private _bits;
  108158. private _radicalInverse_VdC;
  108159. private _hammersley;
  108160. private _hemisphereSample_uniform;
  108161. private _generateHemisphere;
  108162. private _createSSAOPostProcess;
  108163. private _createSSAOCombinePostProcess;
  108164. private _createRandomTexture;
  108165. /**
  108166. * Serialize the rendering pipeline (Used when exporting)
  108167. * @returns the serialized object
  108168. */
  108169. serialize(): any;
  108170. /**
  108171. * Parse the serialized pipeline
  108172. * @param source Source pipeline.
  108173. * @param scene The scene to load the pipeline to.
  108174. * @param rootUrl The URL of the serialized pipeline.
  108175. * @returns An instantiated pipeline from the serialized object.
  108176. */
  108177. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  108178. }
  108179. }
  108180. declare module BABYLON {
  108181. /** @hidden */
  108182. export var ssaoPixelShader: {
  108183. name: string;
  108184. shader: string;
  108185. };
  108186. }
  108187. declare module BABYLON {
  108188. /**
  108189. * Render pipeline to produce ssao effect
  108190. */
  108191. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  108192. /**
  108193. * @ignore
  108194. * The PassPostProcess id in the pipeline that contains the original scene color
  108195. */
  108196. SSAOOriginalSceneColorEffect: string;
  108197. /**
  108198. * @ignore
  108199. * The SSAO PostProcess id in the pipeline
  108200. */
  108201. SSAORenderEffect: string;
  108202. /**
  108203. * @ignore
  108204. * The horizontal blur PostProcess id in the pipeline
  108205. */
  108206. SSAOBlurHRenderEffect: string;
  108207. /**
  108208. * @ignore
  108209. * The vertical blur PostProcess id in the pipeline
  108210. */
  108211. SSAOBlurVRenderEffect: string;
  108212. /**
  108213. * @ignore
  108214. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108215. */
  108216. SSAOCombineRenderEffect: string;
  108217. /**
  108218. * The output strength of the SSAO post-process. Default value is 1.0.
  108219. */
  108220. totalStrength: number;
  108221. /**
  108222. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  108223. */
  108224. radius: number;
  108225. /**
  108226. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  108227. * Must not be equal to fallOff and superior to fallOff.
  108228. * Default value is 0.0075
  108229. */
  108230. area: number;
  108231. /**
  108232. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  108233. * Must not be equal to area and inferior to area.
  108234. * Default value is 0.000001
  108235. */
  108236. fallOff: number;
  108237. /**
  108238. * The base color of the SSAO post-process
  108239. * The final result is "base + ssao" between [0, 1]
  108240. */
  108241. base: number;
  108242. private _scene;
  108243. private _depthTexture;
  108244. private _randomTexture;
  108245. private _originalColorPostProcess;
  108246. private _ssaoPostProcess;
  108247. private _blurHPostProcess;
  108248. private _blurVPostProcess;
  108249. private _ssaoCombinePostProcess;
  108250. private _firstUpdate;
  108251. /**
  108252. * Gets active scene
  108253. */
  108254. readonly scene: Scene;
  108255. /**
  108256. * @constructor
  108257. * @param name - The rendering pipeline name
  108258. * @param scene - The scene linked to this pipeline
  108259. * @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 }
  108260. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  108261. */
  108262. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  108263. /**
  108264. * Get the class name
  108265. * @returns "SSAORenderingPipeline"
  108266. */
  108267. getClassName(): string;
  108268. /**
  108269. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  108270. */
  108271. dispose(disableDepthRender?: boolean): void;
  108272. private _createBlurPostProcess;
  108273. /** @hidden */
  108274. _rebuild(): void;
  108275. private _createSSAOPostProcess;
  108276. private _createSSAOCombinePostProcess;
  108277. private _createRandomTexture;
  108278. }
  108279. }
  108280. declare module BABYLON {
  108281. /** @hidden */
  108282. export var standardPixelShader: {
  108283. name: string;
  108284. shader: string;
  108285. };
  108286. }
  108287. declare module BABYLON {
  108288. /**
  108289. * Standard rendering pipeline
  108290. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108291. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  108292. */
  108293. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108294. /**
  108295. * Public members
  108296. */
  108297. /**
  108298. * Post-process which contains the original scene color before the pipeline applies all the effects
  108299. */
  108300. originalPostProcess: Nullable<PostProcess>;
  108301. /**
  108302. * Post-process used to down scale an image x4
  108303. */
  108304. downSampleX4PostProcess: Nullable<PostProcess>;
  108305. /**
  108306. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  108307. */
  108308. brightPassPostProcess: Nullable<PostProcess>;
  108309. /**
  108310. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  108311. */
  108312. blurHPostProcesses: PostProcess[];
  108313. /**
  108314. * Post-process array storing all the vertical blur post-processes used by the pipeline
  108315. */
  108316. blurVPostProcesses: PostProcess[];
  108317. /**
  108318. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  108319. */
  108320. textureAdderPostProcess: Nullable<PostProcess>;
  108321. /**
  108322. * Post-process used to create volumetric lighting effect
  108323. */
  108324. volumetricLightPostProcess: Nullable<PostProcess>;
  108325. /**
  108326. * Post-process used to smooth the previous volumetric light post-process on the X axis
  108327. */
  108328. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  108329. /**
  108330. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  108331. */
  108332. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  108333. /**
  108334. * Post-process used to merge the volumetric light effect and the real scene color
  108335. */
  108336. volumetricLightMergePostProces: Nullable<PostProcess>;
  108337. /**
  108338. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  108339. */
  108340. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  108341. /**
  108342. * Base post-process used to calculate the average luminance of the final image for HDR
  108343. */
  108344. luminancePostProcess: Nullable<PostProcess>;
  108345. /**
  108346. * Post-processes used to create down sample post-processes in order to get
  108347. * the average luminance of the final image for HDR
  108348. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  108349. */
  108350. luminanceDownSamplePostProcesses: PostProcess[];
  108351. /**
  108352. * Post-process used to create a HDR effect (light adaptation)
  108353. */
  108354. hdrPostProcess: Nullable<PostProcess>;
  108355. /**
  108356. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  108357. */
  108358. textureAdderFinalPostProcess: Nullable<PostProcess>;
  108359. /**
  108360. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  108361. */
  108362. lensFlareFinalPostProcess: Nullable<PostProcess>;
  108363. /**
  108364. * Post-process used to merge the final HDR post-process and the real scene color
  108365. */
  108366. hdrFinalPostProcess: Nullable<PostProcess>;
  108367. /**
  108368. * Post-process used to create a lens flare effect
  108369. */
  108370. lensFlarePostProcess: Nullable<PostProcess>;
  108371. /**
  108372. * Post-process that merges the result of the lens flare post-process and the real scene color
  108373. */
  108374. lensFlareComposePostProcess: Nullable<PostProcess>;
  108375. /**
  108376. * Post-process used to create a motion blur effect
  108377. */
  108378. motionBlurPostProcess: Nullable<PostProcess>;
  108379. /**
  108380. * Post-process used to create a depth of field effect
  108381. */
  108382. depthOfFieldPostProcess: Nullable<PostProcess>;
  108383. /**
  108384. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108385. */
  108386. fxaaPostProcess: Nullable<FxaaPostProcess>;
  108387. /**
  108388. * Represents the brightness threshold in order to configure the illuminated surfaces
  108389. */
  108390. brightThreshold: number;
  108391. /**
  108392. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  108393. */
  108394. blurWidth: number;
  108395. /**
  108396. * Sets if the blur for highlighted surfaces must be only horizontal
  108397. */
  108398. horizontalBlur: boolean;
  108399. /**
  108400. * Sets the overall exposure used by the pipeline
  108401. */
  108402. exposure: number;
  108403. /**
  108404. * Texture used typically to simulate "dirty" on camera lens
  108405. */
  108406. lensTexture: Nullable<Texture>;
  108407. /**
  108408. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  108409. */
  108410. volumetricLightCoefficient: number;
  108411. /**
  108412. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  108413. */
  108414. volumetricLightPower: number;
  108415. /**
  108416. * Used the set the blur intensity to smooth the volumetric lights
  108417. */
  108418. volumetricLightBlurScale: number;
  108419. /**
  108420. * Light (spot or directional) used to generate the volumetric lights rays
  108421. * The source light must have a shadow generate so the pipeline can get its
  108422. * depth map
  108423. */
  108424. sourceLight: Nullable<SpotLight | DirectionalLight>;
  108425. /**
  108426. * For eye adaptation, represents the minimum luminance the eye can see
  108427. */
  108428. hdrMinimumLuminance: number;
  108429. /**
  108430. * For eye adaptation, represents the decrease luminance speed
  108431. */
  108432. hdrDecreaseRate: number;
  108433. /**
  108434. * For eye adaptation, represents the increase luminance speed
  108435. */
  108436. hdrIncreaseRate: number;
  108437. /**
  108438. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  108439. */
  108440. lensColorTexture: Nullable<Texture>;
  108441. /**
  108442. * The overall strengh for the lens flare effect
  108443. */
  108444. lensFlareStrength: number;
  108445. /**
  108446. * Dispersion coefficient for lens flare ghosts
  108447. */
  108448. lensFlareGhostDispersal: number;
  108449. /**
  108450. * Main lens flare halo width
  108451. */
  108452. lensFlareHaloWidth: number;
  108453. /**
  108454. * Based on the lens distortion effect, defines how much the lens flare result
  108455. * is distorted
  108456. */
  108457. lensFlareDistortionStrength: number;
  108458. /**
  108459. * Lens star texture must be used to simulate rays on the flares and is available
  108460. * in the documentation
  108461. */
  108462. lensStarTexture: Nullable<Texture>;
  108463. /**
  108464. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  108465. * flare effect by taking account of the dirt texture
  108466. */
  108467. lensFlareDirtTexture: Nullable<Texture>;
  108468. /**
  108469. * Represents the focal length for the depth of field effect
  108470. */
  108471. depthOfFieldDistance: number;
  108472. /**
  108473. * Represents the blur intensity for the blurred part of the depth of field effect
  108474. */
  108475. depthOfFieldBlurWidth: number;
  108476. /**
  108477. * For motion blur, defines how much the image is blurred by the movement
  108478. */
  108479. motionStrength: number;
  108480. /**
  108481. * List of animations for the pipeline (IAnimatable implementation)
  108482. */
  108483. animations: Animation[];
  108484. /**
  108485. * Private members
  108486. */
  108487. private _scene;
  108488. private _currentDepthOfFieldSource;
  108489. private _basePostProcess;
  108490. private _hdrCurrentLuminance;
  108491. private _floatTextureType;
  108492. private _ratio;
  108493. private _bloomEnabled;
  108494. private _depthOfFieldEnabled;
  108495. private _vlsEnabled;
  108496. private _lensFlareEnabled;
  108497. private _hdrEnabled;
  108498. private _motionBlurEnabled;
  108499. private _fxaaEnabled;
  108500. private _motionBlurSamples;
  108501. private _volumetricLightStepsCount;
  108502. private _samples;
  108503. /**
  108504. * @ignore
  108505. * Specifies if the bloom pipeline is enabled
  108506. */
  108507. BloomEnabled: boolean;
  108508. /**
  108509. * @ignore
  108510. * Specifies if the depth of field pipeline is enabed
  108511. */
  108512. DepthOfFieldEnabled: boolean;
  108513. /**
  108514. * @ignore
  108515. * Specifies if the lens flare pipeline is enabed
  108516. */
  108517. LensFlareEnabled: boolean;
  108518. /**
  108519. * @ignore
  108520. * Specifies if the HDR pipeline is enabled
  108521. */
  108522. HDREnabled: boolean;
  108523. /**
  108524. * @ignore
  108525. * Specifies if the volumetric lights scattering effect is enabled
  108526. */
  108527. VLSEnabled: boolean;
  108528. /**
  108529. * @ignore
  108530. * Specifies if the motion blur effect is enabled
  108531. */
  108532. MotionBlurEnabled: boolean;
  108533. /**
  108534. * Specifies if anti-aliasing is enabled
  108535. */
  108536. fxaaEnabled: boolean;
  108537. /**
  108538. * Specifies the number of steps used to calculate the volumetric lights
  108539. * Typically in interval [50, 200]
  108540. */
  108541. volumetricLightStepsCount: number;
  108542. /**
  108543. * Specifies the number of samples used for the motion blur effect
  108544. * Typically in interval [16, 64]
  108545. */
  108546. motionBlurSamples: number;
  108547. /**
  108548. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108549. */
  108550. samples: number;
  108551. /**
  108552. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108553. * @constructor
  108554. * @param name The rendering pipeline name
  108555. * @param scene The scene linked to this pipeline
  108556. * @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)
  108557. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  108558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108559. */
  108560. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  108561. private _buildPipeline;
  108562. private _createDownSampleX4PostProcess;
  108563. private _createBrightPassPostProcess;
  108564. private _createBlurPostProcesses;
  108565. private _createTextureAdderPostProcess;
  108566. private _createVolumetricLightPostProcess;
  108567. private _createLuminancePostProcesses;
  108568. private _createHdrPostProcess;
  108569. private _createLensFlarePostProcess;
  108570. private _createDepthOfFieldPostProcess;
  108571. private _createMotionBlurPostProcess;
  108572. private _getDepthTexture;
  108573. private _disposePostProcesses;
  108574. /**
  108575. * Dispose of the pipeline and stop all post processes
  108576. */
  108577. dispose(): void;
  108578. /**
  108579. * Serialize the rendering pipeline (Used when exporting)
  108580. * @returns the serialized object
  108581. */
  108582. serialize(): any;
  108583. /**
  108584. * Parse the serialized pipeline
  108585. * @param source Source pipeline.
  108586. * @param scene The scene to load the pipeline to.
  108587. * @param rootUrl The URL of the serialized pipeline.
  108588. * @returns An instantiated pipeline from the serialized object.
  108589. */
  108590. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  108591. /**
  108592. * Luminance steps
  108593. */
  108594. static LuminanceSteps: number;
  108595. }
  108596. }
  108597. declare module BABYLON {
  108598. /**
  108599. * PostProcessRenderPipelineManager class
  108600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108601. */
  108602. export class PostProcessRenderPipelineManager {
  108603. private _renderPipelines;
  108604. /**
  108605. * Initializes a PostProcessRenderPipelineManager
  108606. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108607. */
  108608. constructor();
  108609. /**
  108610. * Gets the list of supported render pipelines
  108611. */
  108612. readonly supportedPipelines: PostProcessRenderPipeline[];
  108613. /**
  108614. * Adds a pipeline to the manager
  108615. * @param renderPipeline The pipeline to add
  108616. */
  108617. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  108618. /**
  108619. * Attaches a camera to the pipeline
  108620. * @param renderPipelineName The name of the pipeline to attach to
  108621. * @param cameras the camera to attach
  108622. * @param unique if the camera can be attached multiple times to the pipeline
  108623. */
  108624. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  108625. /**
  108626. * Detaches a camera from the pipeline
  108627. * @param renderPipelineName The name of the pipeline to detach from
  108628. * @param cameras the camera to detach
  108629. */
  108630. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  108631. /**
  108632. * Enables an effect by name on a pipeline
  108633. * @param renderPipelineName the name of the pipeline to enable the effect in
  108634. * @param renderEffectName the name of the effect to enable
  108635. * @param cameras the cameras that the effect should be enabled on
  108636. */
  108637. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108638. /**
  108639. * Disables an effect by name on a pipeline
  108640. * @param renderPipelineName the name of the pipeline to disable the effect in
  108641. * @param renderEffectName the name of the effect to disable
  108642. * @param cameras the cameras that the effect should be disabled on
  108643. */
  108644. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108645. /**
  108646. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  108647. */
  108648. update(): void;
  108649. /** @hidden */
  108650. _rebuild(): void;
  108651. /**
  108652. * Disposes of the manager and pipelines
  108653. */
  108654. dispose(): void;
  108655. }
  108656. }
  108657. declare module BABYLON {
  108658. interface Scene {
  108659. /** @hidden (Backing field) */
  108660. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108661. /**
  108662. * Gets the postprocess render pipeline manager
  108663. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108664. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108665. */
  108666. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108667. }
  108668. /**
  108669. * Defines the Render Pipeline scene component responsible to rendering pipelines
  108670. */
  108671. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  108672. /**
  108673. * The component name helpfull to identify the component in the list of scene components.
  108674. */
  108675. readonly name: string;
  108676. /**
  108677. * The scene the component belongs to.
  108678. */
  108679. scene: Scene;
  108680. /**
  108681. * Creates a new instance of the component for the given scene
  108682. * @param scene Defines the scene to register the component in
  108683. */
  108684. constructor(scene: Scene);
  108685. /**
  108686. * Registers the component in a given scene
  108687. */
  108688. register(): void;
  108689. /**
  108690. * Rebuilds the elements related to this component in case of
  108691. * context lost for instance.
  108692. */
  108693. rebuild(): void;
  108694. /**
  108695. * Disposes the component and the associated ressources
  108696. */
  108697. dispose(): void;
  108698. private _gatherRenderTargets;
  108699. }
  108700. }
  108701. declare module BABYLON {
  108702. /** @hidden */
  108703. export var tonemapPixelShader: {
  108704. name: string;
  108705. shader: string;
  108706. };
  108707. }
  108708. declare module BABYLON {
  108709. /** Defines operator used for tonemapping */
  108710. export enum TonemappingOperator {
  108711. /** Hable */
  108712. Hable = 0,
  108713. /** Reinhard */
  108714. Reinhard = 1,
  108715. /** HejiDawson */
  108716. HejiDawson = 2,
  108717. /** Photographic */
  108718. Photographic = 3
  108719. }
  108720. /**
  108721. * Defines a post process to apply tone mapping
  108722. */
  108723. export class TonemapPostProcess extends PostProcess {
  108724. private _operator;
  108725. /** Defines the required exposure adjustement */
  108726. exposureAdjustment: number;
  108727. /**
  108728. * Creates a new TonemapPostProcess
  108729. * @param name defines the name of the postprocess
  108730. * @param _operator defines the operator to use
  108731. * @param exposureAdjustment defines the required exposure adjustement
  108732. * @param camera defines the camera to use (can be null)
  108733. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  108734. * @param engine defines the hosting engine (can be ignore if camera is set)
  108735. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108736. */
  108737. constructor(name: string, _operator: TonemappingOperator,
  108738. /** Defines the required exposure adjustement */
  108739. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  108740. }
  108741. }
  108742. declare module BABYLON {
  108743. /** @hidden */
  108744. export var depthVertexShader: {
  108745. name: string;
  108746. shader: string;
  108747. };
  108748. }
  108749. declare module BABYLON {
  108750. /** @hidden */
  108751. export var volumetricLightScatteringPixelShader: {
  108752. name: string;
  108753. shader: string;
  108754. };
  108755. }
  108756. declare module BABYLON {
  108757. /** @hidden */
  108758. export var volumetricLightScatteringPassPixelShader: {
  108759. name: string;
  108760. shader: string;
  108761. };
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  108766. */
  108767. export class VolumetricLightScatteringPostProcess extends PostProcess {
  108768. private _volumetricLightScatteringPass;
  108769. private _volumetricLightScatteringRTT;
  108770. private _viewPort;
  108771. private _screenCoordinates;
  108772. private _cachedDefines;
  108773. /**
  108774. * If not undefined, the mesh position is computed from the attached node position
  108775. */
  108776. attachedNode: {
  108777. position: Vector3;
  108778. };
  108779. /**
  108780. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  108781. */
  108782. customMeshPosition: Vector3;
  108783. /**
  108784. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  108785. */
  108786. useCustomMeshPosition: boolean;
  108787. /**
  108788. * If the post-process should inverse the light scattering direction
  108789. */
  108790. invert: boolean;
  108791. /**
  108792. * The internal mesh used by the post-process
  108793. */
  108794. mesh: Mesh;
  108795. /**
  108796. * @hidden
  108797. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  108798. */
  108799. useDiffuseColor: boolean;
  108800. /**
  108801. * Array containing the excluded meshes not rendered in the internal pass
  108802. */
  108803. excludedMeshes: AbstractMesh[];
  108804. /**
  108805. * Controls the overall intensity of the post-process
  108806. */
  108807. exposure: number;
  108808. /**
  108809. * Dissipates each sample's contribution in range [0, 1]
  108810. */
  108811. decay: number;
  108812. /**
  108813. * Controls the overall intensity of each sample
  108814. */
  108815. weight: number;
  108816. /**
  108817. * Controls the density of each sample
  108818. */
  108819. density: number;
  108820. /**
  108821. * @constructor
  108822. * @param name The post-process name
  108823. * @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)
  108824. * @param camera The camera that the post-process will be attached to
  108825. * @param mesh The mesh used to create the light scattering
  108826. * @param samples The post-process quality, default 100
  108827. * @param samplingModeThe post-process filtering mode
  108828. * @param engine The babylon engine
  108829. * @param reusable If the post-process is reusable
  108830. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  108831. */
  108832. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  108833. /**
  108834. * Returns the string "VolumetricLightScatteringPostProcess"
  108835. * @returns "VolumetricLightScatteringPostProcess"
  108836. */
  108837. getClassName(): string;
  108838. private _isReady;
  108839. /**
  108840. * Sets the new light position for light scattering effect
  108841. * @param position The new custom light position
  108842. */
  108843. setCustomMeshPosition(position: Vector3): void;
  108844. /**
  108845. * Returns the light position for light scattering effect
  108846. * @return Vector3 The custom light position
  108847. */
  108848. getCustomMeshPosition(): Vector3;
  108849. /**
  108850. * Disposes the internal assets and detaches the post-process from the camera
  108851. */
  108852. dispose(camera: Camera): void;
  108853. /**
  108854. * Returns the render target texture used by the post-process
  108855. * @return the render target texture used by the post-process
  108856. */
  108857. getPass(): RenderTargetTexture;
  108858. private _meshExcluded;
  108859. private _createPass;
  108860. private _updateMeshScreenCoordinates;
  108861. /**
  108862. * Creates a default mesh for the Volumeric Light Scattering post-process
  108863. * @param name The mesh name
  108864. * @param scene The scene where to create the mesh
  108865. * @return the default mesh
  108866. */
  108867. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  108868. }
  108869. }
  108870. declare module BABYLON {
  108871. interface Scene {
  108872. /** @hidden (Backing field) */
  108873. _boundingBoxRenderer: BoundingBoxRenderer;
  108874. /** @hidden (Backing field) */
  108875. _forceShowBoundingBoxes: boolean;
  108876. /**
  108877. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  108878. */
  108879. forceShowBoundingBoxes: boolean;
  108880. /**
  108881. * Gets the bounding box renderer associated with the scene
  108882. * @returns a BoundingBoxRenderer
  108883. */
  108884. getBoundingBoxRenderer(): BoundingBoxRenderer;
  108885. }
  108886. interface AbstractMesh {
  108887. /** @hidden (Backing field) */
  108888. _showBoundingBox: boolean;
  108889. /**
  108890. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  108891. */
  108892. showBoundingBox: boolean;
  108893. }
  108894. /**
  108895. * Component responsible of rendering the bounding box of the meshes in a scene.
  108896. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  108897. */
  108898. export class BoundingBoxRenderer implements ISceneComponent {
  108899. /**
  108900. * The component name helpfull to identify the component in the list of scene components.
  108901. */
  108902. readonly name: string;
  108903. /**
  108904. * The scene the component belongs to.
  108905. */
  108906. scene: Scene;
  108907. /**
  108908. * Color of the bounding box lines placed in front of an object
  108909. */
  108910. frontColor: Color3;
  108911. /**
  108912. * Color of the bounding box lines placed behind an object
  108913. */
  108914. backColor: Color3;
  108915. /**
  108916. * Defines if the renderer should show the back lines or not
  108917. */
  108918. showBackLines: boolean;
  108919. /**
  108920. * @hidden
  108921. */
  108922. renderList: SmartArray<BoundingBox>;
  108923. private _colorShader;
  108924. private _vertexBuffers;
  108925. private _indexBuffer;
  108926. /**
  108927. * Instantiates a new bounding box renderer in a scene.
  108928. * @param scene the scene the renderer renders in
  108929. */
  108930. constructor(scene: Scene);
  108931. /**
  108932. * Registers the component in a given scene
  108933. */
  108934. register(): void;
  108935. private _evaluateSubMesh;
  108936. private _activeMesh;
  108937. private _prepareRessources;
  108938. private _createIndexBuffer;
  108939. /**
  108940. * Rebuilds the elements related to this component in case of
  108941. * context lost for instance.
  108942. */
  108943. rebuild(): void;
  108944. /**
  108945. * @hidden
  108946. */
  108947. reset(): void;
  108948. /**
  108949. * Render the bounding boxes of a specific rendering group
  108950. * @param renderingGroupId defines the rendering group to render
  108951. */
  108952. render(renderingGroupId: number): void;
  108953. /**
  108954. * In case of occlusion queries, we can render the occlusion bounding box through this method
  108955. * @param mesh Define the mesh to render the occlusion bounding box for
  108956. */
  108957. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  108958. /**
  108959. * Dispose and release the resources attached to this renderer.
  108960. */
  108961. dispose(): void;
  108962. }
  108963. }
  108964. declare module BABYLON {
  108965. /** @hidden */
  108966. export var depthPixelShader: {
  108967. name: string;
  108968. shader: string;
  108969. };
  108970. }
  108971. declare module BABYLON {
  108972. /**
  108973. * This represents a depth renderer in Babylon.
  108974. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108975. */
  108976. export class DepthRenderer {
  108977. private _scene;
  108978. private _depthMap;
  108979. private _effect;
  108980. private _cachedDefines;
  108981. private _camera;
  108982. /**
  108983. * Specifiess that the depth renderer will only be used within
  108984. * the camera it is created for.
  108985. * This can help forcing its rendering during the camera processing.
  108986. */
  108987. useOnlyInActiveCamera: boolean;
  108988. /** @hidden */
  108989. static _SceneComponentInitialization: (scene: Scene) => void;
  108990. /**
  108991. * Instantiates a depth renderer
  108992. * @param scene The scene the renderer belongs to
  108993. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108994. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108995. */
  108996. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108997. /**
  108998. * Creates the depth rendering effect and checks if the effect is ready.
  108999. * @param subMesh The submesh to be used to render the depth map of
  109000. * @param useInstances If multiple world instances should be used
  109001. * @returns if the depth renderer is ready to render the depth map
  109002. */
  109003. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109004. /**
  109005. * Gets the texture which the depth map will be written to.
  109006. * @returns The depth map texture
  109007. */
  109008. getDepthMap(): RenderTargetTexture;
  109009. /**
  109010. * Disposes of the depth renderer.
  109011. */
  109012. dispose(): void;
  109013. }
  109014. }
  109015. declare module BABYLON {
  109016. interface Scene {
  109017. /** @hidden (Backing field) */
  109018. _depthRenderer: {
  109019. [id: string]: DepthRenderer;
  109020. };
  109021. /**
  109022. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109023. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109024. * @returns the created depth renderer
  109025. */
  109026. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109027. /**
  109028. * Disables a depth renderer for a given camera
  109029. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109030. */
  109031. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109032. }
  109033. /**
  109034. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109035. * in several rendering techniques.
  109036. */
  109037. export class DepthRendererSceneComponent implements ISceneComponent {
  109038. /**
  109039. * The component name helpfull to identify the component in the list of scene components.
  109040. */
  109041. readonly name: string;
  109042. /**
  109043. * The scene the component belongs to.
  109044. */
  109045. scene: Scene;
  109046. /**
  109047. * Creates a new instance of the component for the given scene
  109048. * @param scene Defines the scene to register the component in
  109049. */
  109050. constructor(scene: Scene);
  109051. /**
  109052. * Registers the component in a given scene
  109053. */
  109054. register(): void;
  109055. /**
  109056. * Rebuilds the elements related to this component in case of
  109057. * context lost for instance.
  109058. */
  109059. rebuild(): void;
  109060. /**
  109061. * Disposes the component and the associated ressources
  109062. */
  109063. dispose(): void;
  109064. private _gatherRenderTargets;
  109065. private _gatherActiveCameraRenderTargets;
  109066. }
  109067. }
  109068. declare module BABYLON {
  109069. interface Scene {
  109070. /** @hidden (Backing field) */
  109071. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109072. /**
  109073. * Gets or Sets the current geometry buffer associated to the scene.
  109074. */
  109075. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109076. /**
  109077. * Enables a GeometryBufferRender and associates it with the scene
  109078. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109079. * @returns the GeometryBufferRenderer
  109080. */
  109081. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109082. /**
  109083. * Disables the GeometryBufferRender associated with the scene
  109084. */
  109085. disableGeometryBufferRenderer(): void;
  109086. }
  109087. /**
  109088. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109089. * in several rendering techniques.
  109090. */
  109091. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109092. /**
  109093. * The component name helpful to identify the component in the list of scene components.
  109094. */
  109095. readonly name: string;
  109096. /**
  109097. * The scene the component belongs to.
  109098. */
  109099. scene: Scene;
  109100. /**
  109101. * Creates a new instance of the component for the given scene
  109102. * @param scene Defines the scene to register the component in
  109103. */
  109104. constructor(scene: Scene);
  109105. /**
  109106. * Registers the component in a given scene
  109107. */
  109108. register(): void;
  109109. /**
  109110. * Rebuilds the elements related to this component in case of
  109111. * context lost for instance.
  109112. */
  109113. rebuild(): void;
  109114. /**
  109115. * Disposes the component and the associated ressources
  109116. */
  109117. dispose(): void;
  109118. private _gatherRenderTargets;
  109119. }
  109120. }
  109121. declare module BABYLON {
  109122. /** @hidden */
  109123. export var outlinePixelShader: {
  109124. name: string;
  109125. shader: string;
  109126. };
  109127. }
  109128. declare module BABYLON {
  109129. /** @hidden */
  109130. export var outlineVertexShader: {
  109131. name: string;
  109132. shader: string;
  109133. };
  109134. }
  109135. declare module BABYLON {
  109136. interface Scene {
  109137. /** @hidden */
  109138. _outlineRenderer: OutlineRenderer;
  109139. /**
  109140. * Gets the outline renderer associated with the scene
  109141. * @returns a OutlineRenderer
  109142. */
  109143. getOutlineRenderer(): OutlineRenderer;
  109144. }
  109145. interface AbstractMesh {
  109146. /** @hidden (Backing field) */
  109147. _renderOutline: boolean;
  109148. /**
  109149. * Gets or sets a boolean indicating if the outline must be rendered as well
  109150. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  109151. */
  109152. renderOutline: boolean;
  109153. /** @hidden (Backing field) */
  109154. _renderOverlay: boolean;
  109155. /**
  109156. * Gets or sets a boolean indicating if the overlay must be rendered as well
  109157. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  109158. */
  109159. renderOverlay: boolean;
  109160. }
  109161. /**
  109162. * This class is responsible to draw bothe outline/overlay of meshes.
  109163. * It should not be used directly but through the available method on mesh.
  109164. */
  109165. export class OutlineRenderer implements ISceneComponent {
  109166. /**
  109167. * The name of the component. Each component must have a unique name.
  109168. */
  109169. name: string;
  109170. /**
  109171. * The scene the component belongs to.
  109172. */
  109173. scene: Scene;
  109174. /**
  109175. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  109176. */
  109177. zOffset: number;
  109178. private _engine;
  109179. private _effect;
  109180. private _cachedDefines;
  109181. private _savedDepthWrite;
  109182. /**
  109183. * Instantiates a new outline renderer. (There could be only one per scene).
  109184. * @param scene Defines the scene it belongs to
  109185. */
  109186. constructor(scene: Scene);
  109187. /**
  109188. * Register the component to one instance of a scene.
  109189. */
  109190. register(): void;
  109191. /**
  109192. * Rebuilds the elements related to this component in case of
  109193. * context lost for instance.
  109194. */
  109195. rebuild(): void;
  109196. /**
  109197. * Disposes the component and the associated ressources.
  109198. */
  109199. dispose(): void;
  109200. /**
  109201. * Renders the outline in the canvas.
  109202. * @param subMesh Defines the sumesh to render
  109203. * @param batch Defines the batch of meshes in case of instances
  109204. * @param useOverlay Defines if the rendering is for the overlay or the outline
  109205. */
  109206. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  109207. /**
  109208. * Returns whether or not the outline renderer is ready for a given submesh.
  109209. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  109210. * @param subMesh Defines the submesh to check readyness for
  109211. * @param useInstances Defines wheter wee are trying to render instances or not
  109212. * @returns true if ready otherwise false
  109213. */
  109214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109215. private _beforeRenderingMesh;
  109216. private _afterRenderingMesh;
  109217. }
  109218. }
  109219. declare module BABYLON {
  109220. /**
  109221. * Defines the list of states available for a task inside a AssetsManager
  109222. */
  109223. export enum AssetTaskState {
  109224. /**
  109225. * Initialization
  109226. */
  109227. INIT = 0,
  109228. /**
  109229. * Running
  109230. */
  109231. RUNNING = 1,
  109232. /**
  109233. * Done
  109234. */
  109235. DONE = 2,
  109236. /**
  109237. * Error
  109238. */
  109239. ERROR = 3
  109240. }
  109241. /**
  109242. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  109243. */
  109244. export abstract class AbstractAssetTask {
  109245. /**
  109246. * Task name
  109247. */ name: string;
  109248. /**
  109249. * Callback called when the task is successful
  109250. */
  109251. onSuccess: (task: any) => void;
  109252. /**
  109253. * Callback called when the task is not successful
  109254. */
  109255. onError: (task: any, message?: string, exception?: any) => void;
  109256. /**
  109257. * Creates a new AssetsManager
  109258. * @param name defines the name of the task
  109259. */
  109260. constructor(
  109261. /**
  109262. * Task name
  109263. */ name: string);
  109264. private _isCompleted;
  109265. private _taskState;
  109266. private _errorObject;
  109267. /**
  109268. * Get if the task is completed
  109269. */
  109270. readonly isCompleted: boolean;
  109271. /**
  109272. * Gets the current state of the task
  109273. */
  109274. readonly taskState: AssetTaskState;
  109275. /**
  109276. * Gets the current error object (if task is in error)
  109277. */
  109278. readonly errorObject: {
  109279. message?: string;
  109280. exception?: any;
  109281. };
  109282. /**
  109283. * Internal only
  109284. * @hidden
  109285. */
  109286. _setErrorObject(message?: string, exception?: any): void;
  109287. /**
  109288. * Execute the current task
  109289. * @param scene defines the scene where you want your assets to be loaded
  109290. * @param onSuccess is a callback called when the task is successfully executed
  109291. * @param onError is a callback called if an error occurs
  109292. */
  109293. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109294. /**
  109295. * Execute the current task
  109296. * @param scene defines the scene where you want your assets to be loaded
  109297. * @param onSuccess is a callback called when the task is successfully executed
  109298. * @param onError is a callback called if an error occurs
  109299. */
  109300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109301. /**
  109302. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  109303. * This can be used with failed tasks that have the reason for failure fixed.
  109304. */
  109305. reset(): void;
  109306. private onErrorCallback;
  109307. private onDoneCallback;
  109308. }
  109309. /**
  109310. * Define the interface used by progress events raised during assets loading
  109311. */
  109312. export interface IAssetsProgressEvent {
  109313. /**
  109314. * Defines the number of remaining tasks to process
  109315. */
  109316. remainingCount: number;
  109317. /**
  109318. * Defines the total number of tasks
  109319. */
  109320. totalCount: number;
  109321. /**
  109322. * Defines the task that was just processed
  109323. */
  109324. task: AbstractAssetTask;
  109325. }
  109326. /**
  109327. * Class used to share progress information about assets loading
  109328. */
  109329. export class AssetsProgressEvent implements IAssetsProgressEvent {
  109330. /**
  109331. * Defines the number of remaining tasks to process
  109332. */
  109333. remainingCount: number;
  109334. /**
  109335. * Defines the total number of tasks
  109336. */
  109337. totalCount: number;
  109338. /**
  109339. * Defines the task that was just processed
  109340. */
  109341. task: AbstractAssetTask;
  109342. /**
  109343. * Creates a AssetsProgressEvent
  109344. * @param remainingCount defines the number of remaining tasks to process
  109345. * @param totalCount defines the total number of tasks
  109346. * @param task defines the task that was just processed
  109347. */
  109348. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  109349. }
  109350. /**
  109351. * Define a task used by AssetsManager to load meshes
  109352. */
  109353. export class MeshAssetTask extends AbstractAssetTask {
  109354. /**
  109355. * Defines the name of the task
  109356. */
  109357. name: string;
  109358. /**
  109359. * Defines the list of mesh's names you want to load
  109360. */
  109361. meshesNames: any;
  109362. /**
  109363. * Defines the root url to use as a base to load your meshes and associated resources
  109364. */
  109365. rootUrl: string;
  109366. /**
  109367. * Defines the filename of the scene to load from
  109368. */
  109369. sceneFilename: string;
  109370. /**
  109371. * Gets the list of loaded meshes
  109372. */
  109373. loadedMeshes: Array<AbstractMesh>;
  109374. /**
  109375. * Gets the list of loaded particle systems
  109376. */
  109377. loadedParticleSystems: Array<IParticleSystem>;
  109378. /**
  109379. * Gets the list of loaded skeletons
  109380. */
  109381. loadedSkeletons: Array<Skeleton>;
  109382. /**
  109383. * Gets the list of loaded animation groups
  109384. */
  109385. loadedAnimationGroups: Array<AnimationGroup>;
  109386. /**
  109387. * Callback called when the task is successful
  109388. */
  109389. onSuccess: (task: MeshAssetTask) => void;
  109390. /**
  109391. * Callback called when the task is successful
  109392. */
  109393. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  109394. /**
  109395. * Creates a new MeshAssetTask
  109396. * @param name defines the name of the task
  109397. * @param meshesNames defines the list of mesh's names you want to load
  109398. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  109399. * @param sceneFilename defines the filename of the scene to load from
  109400. */
  109401. constructor(
  109402. /**
  109403. * Defines the name of the task
  109404. */
  109405. name: string,
  109406. /**
  109407. * Defines the list of mesh's names you want to load
  109408. */
  109409. meshesNames: any,
  109410. /**
  109411. * Defines the root url to use as a base to load your meshes and associated resources
  109412. */
  109413. rootUrl: string,
  109414. /**
  109415. * Defines the filename of the scene to load from
  109416. */
  109417. sceneFilename: string);
  109418. /**
  109419. * Execute the current task
  109420. * @param scene defines the scene where you want your assets to be loaded
  109421. * @param onSuccess is a callback called when the task is successfully executed
  109422. * @param onError is a callback called if an error occurs
  109423. */
  109424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109425. }
  109426. /**
  109427. * Define a task used by AssetsManager to load text content
  109428. */
  109429. export class TextFileAssetTask extends AbstractAssetTask {
  109430. /**
  109431. * Defines the name of the task
  109432. */
  109433. name: string;
  109434. /**
  109435. * Defines the location of the file to load
  109436. */
  109437. url: string;
  109438. /**
  109439. * Gets the loaded text string
  109440. */
  109441. text: string;
  109442. /**
  109443. * Callback called when the task is successful
  109444. */
  109445. onSuccess: (task: TextFileAssetTask) => void;
  109446. /**
  109447. * Callback called when the task is successful
  109448. */
  109449. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  109450. /**
  109451. * Creates a new TextFileAssetTask object
  109452. * @param name defines the name of the task
  109453. * @param url defines the location of the file to load
  109454. */
  109455. constructor(
  109456. /**
  109457. * Defines the name of the task
  109458. */
  109459. name: string,
  109460. /**
  109461. * Defines the location of the file to load
  109462. */
  109463. url: string);
  109464. /**
  109465. * Execute the current task
  109466. * @param scene defines the scene where you want your assets to be loaded
  109467. * @param onSuccess is a callback called when the task is successfully executed
  109468. * @param onError is a callback called if an error occurs
  109469. */
  109470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109471. }
  109472. /**
  109473. * Define a task used by AssetsManager to load binary data
  109474. */
  109475. export class BinaryFileAssetTask extends AbstractAssetTask {
  109476. /**
  109477. * Defines the name of the task
  109478. */
  109479. name: string;
  109480. /**
  109481. * Defines the location of the file to load
  109482. */
  109483. url: string;
  109484. /**
  109485. * Gets the lodaded data (as an array buffer)
  109486. */
  109487. data: ArrayBuffer;
  109488. /**
  109489. * Callback called when the task is successful
  109490. */
  109491. onSuccess: (task: BinaryFileAssetTask) => void;
  109492. /**
  109493. * Callback called when the task is successful
  109494. */
  109495. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  109496. /**
  109497. * Creates a new BinaryFileAssetTask object
  109498. * @param name defines the name of the new task
  109499. * @param url defines the location of the file to load
  109500. */
  109501. constructor(
  109502. /**
  109503. * Defines the name of the task
  109504. */
  109505. name: string,
  109506. /**
  109507. * Defines the location of the file to load
  109508. */
  109509. url: string);
  109510. /**
  109511. * Execute the current task
  109512. * @param scene defines the scene where you want your assets to be loaded
  109513. * @param onSuccess is a callback called when the task is successfully executed
  109514. * @param onError is a callback called if an error occurs
  109515. */
  109516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109517. }
  109518. /**
  109519. * Define a task used by AssetsManager to load images
  109520. */
  109521. export class ImageAssetTask extends AbstractAssetTask {
  109522. /**
  109523. * Defines the name of the task
  109524. */
  109525. name: string;
  109526. /**
  109527. * Defines the location of the image to load
  109528. */
  109529. url: string;
  109530. /**
  109531. * Gets the loaded images
  109532. */
  109533. image: HTMLImageElement;
  109534. /**
  109535. * Callback called when the task is successful
  109536. */
  109537. onSuccess: (task: ImageAssetTask) => void;
  109538. /**
  109539. * Callback called when the task is successful
  109540. */
  109541. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  109542. /**
  109543. * Creates a new ImageAssetTask
  109544. * @param name defines the name of the task
  109545. * @param url defines the location of the image to load
  109546. */
  109547. constructor(
  109548. /**
  109549. * Defines the name of the task
  109550. */
  109551. name: string,
  109552. /**
  109553. * Defines the location of the image to load
  109554. */
  109555. url: string);
  109556. /**
  109557. * Execute the current task
  109558. * @param scene defines the scene where you want your assets to be loaded
  109559. * @param onSuccess is a callback called when the task is successfully executed
  109560. * @param onError is a callback called if an error occurs
  109561. */
  109562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109563. }
  109564. /**
  109565. * Defines the interface used by texture loading tasks
  109566. */
  109567. export interface ITextureAssetTask<TEX extends BaseTexture> {
  109568. /**
  109569. * Gets the loaded texture
  109570. */
  109571. texture: TEX;
  109572. }
  109573. /**
  109574. * Define a task used by AssetsManager to load 2D textures
  109575. */
  109576. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  109577. /**
  109578. * Defines the name of the task
  109579. */
  109580. name: string;
  109581. /**
  109582. * Defines the location of the file to load
  109583. */
  109584. url: string;
  109585. /**
  109586. * Defines if mipmap should not be generated (default is false)
  109587. */
  109588. noMipmap?: boolean | undefined;
  109589. /**
  109590. * Defines if texture must be inverted on Y axis (default is false)
  109591. */
  109592. invertY?: boolean | undefined;
  109593. /**
  109594. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109595. */
  109596. samplingMode: number;
  109597. /**
  109598. * Gets the loaded texture
  109599. */
  109600. texture: Texture;
  109601. /**
  109602. * Callback called when the task is successful
  109603. */
  109604. onSuccess: (task: TextureAssetTask) => void;
  109605. /**
  109606. * Callback called when the task is successful
  109607. */
  109608. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  109609. /**
  109610. * Creates a new TextureAssetTask object
  109611. * @param name defines the name of the task
  109612. * @param url defines the location of the file to load
  109613. * @param noMipmap defines if mipmap should not be generated (default is false)
  109614. * @param invertY defines if texture must be inverted on Y axis (default is false)
  109615. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109616. */
  109617. constructor(
  109618. /**
  109619. * Defines the name of the task
  109620. */
  109621. name: string,
  109622. /**
  109623. * Defines the location of the file to load
  109624. */
  109625. url: string,
  109626. /**
  109627. * Defines if mipmap should not be generated (default is false)
  109628. */
  109629. noMipmap?: boolean | undefined,
  109630. /**
  109631. * Defines if texture must be inverted on Y axis (default is false)
  109632. */
  109633. invertY?: boolean | undefined,
  109634. /**
  109635. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109636. */
  109637. samplingMode?: number);
  109638. /**
  109639. * Execute the current task
  109640. * @param scene defines the scene where you want your assets to be loaded
  109641. * @param onSuccess is a callback called when the task is successfully executed
  109642. * @param onError is a callback called if an error occurs
  109643. */
  109644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109645. }
  109646. /**
  109647. * Define a task used by AssetsManager to load cube textures
  109648. */
  109649. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  109650. /**
  109651. * Defines the name of the task
  109652. */
  109653. name: string;
  109654. /**
  109655. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109656. */
  109657. url: string;
  109658. /**
  109659. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109660. */
  109661. extensions?: string[] | undefined;
  109662. /**
  109663. * Defines if mipmaps should not be generated (default is false)
  109664. */
  109665. noMipmap?: boolean | undefined;
  109666. /**
  109667. * Defines the explicit list of files (undefined by default)
  109668. */
  109669. files?: string[] | undefined;
  109670. /**
  109671. * Gets the loaded texture
  109672. */
  109673. texture: CubeTexture;
  109674. /**
  109675. * Callback called when the task is successful
  109676. */
  109677. onSuccess: (task: CubeTextureAssetTask) => void;
  109678. /**
  109679. * Callback called when the task is successful
  109680. */
  109681. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  109682. /**
  109683. * Creates a new CubeTextureAssetTask
  109684. * @param name defines the name of the task
  109685. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109686. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109687. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109688. * @param files defines the explicit list of files (undefined by default)
  109689. */
  109690. constructor(
  109691. /**
  109692. * Defines the name of the task
  109693. */
  109694. name: string,
  109695. /**
  109696. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109697. */
  109698. url: string,
  109699. /**
  109700. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109701. */
  109702. extensions?: string[] | undefined,
  109703. /**
  109704. * Defines if mipmaps should not be generated (default is false)
  109705. */
  109706. noMipmap?: boolean | undefined,
  109707. /**
  109708. * Defines the explicit list of files (undefined by default)
  109709. */
  109710. files?: string[] | undefined);
  109711. /**
  109712. * Execute the current task
  109713. * @param scene defines the scene where you want your assets to be loaded
  109714. * @param onSuccess is a callback called when the task is successfully executed
  109715. * @param onError is a callback called if an error occurs
  109716. */
  109717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109718. }
  109719. /**
  109720. * Define a task used by AssetsManager to load HDR cube textures
  109721. */
  109722. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  109723. /**
  109724. * Defines the name of the task
  109725. */
  109726. name: string;
  109727. /**
  109728. * Defines the location of the file to load
  109729. */
  109730. url: string;
  109731. /**
  109732. * Defines the desired size (the more it increases the longer the generation will be)
  109733. */
  109734. size: number;
  109735. /**
  109736. * Defines if mipmaps should not be generated (default is false)
  109737. */
  109738. noMipmap: boolean;
  109739. /**
  109740. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109741. */
  109742. generateHarmonics: boolean;
  109743. /**
  109744. * 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)
  109745. */
  109746. gammaSpace: boolean;
  109747. /**
  109748. * Internal Use Only
  109749. */
  109750. reserved: boolean;
  109751. /**
  109752. * Gets the loaded texture
  109753. */
  109754. texture: HDRCubeTexture;
  109755. /**
  109756. * Callback called when the task is successful
  109757. */
  109758. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  109759. /**
  109760. * Callback called when the task is successful
  109761. */
  109762. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  109763. /**
  109764. * Creates a new HDRCubeTextureAssetTask object
  109765. * @param name defines the name of the task
  109766. * @param url defines the location of the file to load
  109767. * @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.
  109768. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109769. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109770. * @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)
  109771. * @param reserved Internal use only
  109772. */
  109773. constructor(
  109774. /**
  109775. * Defines the name of the task
  109776. */
  109777. name: string,
  109778. /**
  109779. * Defines the location of the file to load
  109780. */
  109781. url: string,
  109782. /**
  109783. * Defines the desired size (the more it increases the longer the generation will be)
  109784. */
  109785. size: number,
  109786. /**
  109787. * Defines if mipmaps should not be generated (default is false)
  109788. */
  109789. noMipmap?: boolean,
  109790. /**
  109791. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109792. */
  109793. generateHarmonics?: boolean,
  109794. /**
  109795. * 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)
  109796. */
  109797. gammaSpace?: boolean,
  109798. /**
  109799. * Internal Use Only
  109800. */
  109801. reserved?: boolean);
  109802. /**
  109803. * Execute the current task
  109804. * @param scene defines the scene where you want your assets to be loaded
  109805. * @param onSuccess is a callback called when the task is successfully executed
  109806. * @param onError is a callback called if an error occurs
  109807. */
  109808. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109809. }
  109810. /**
  109811. * This class can be used to easily import assets into a scene
  109812. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  109813. */
  109814. export class AssetsManager {
  109815. private _scene;
  109816. private _isLoading;
  109817. protected _tasks: AbstractAssetTask[];
  109818. protected _waitingTasksCount: number;
  109819. protected _totalTasksCount: number;
  109820. /**
  109821. * Callback called when all tasks are processed
  109822. */
  109823. onFinish: (tasks: AbstractAssetTask[]) => void;
  109824. /**
  109825. * Callback called when a task is successful
  109826. */
  109827. onTaskSuccess: (task: AbstractAssetTask) => void;
  109828. /**
  109829. * Callback called when a task had an error
  109830. */
  109831. onTaskError: (task: AbstractAssetTask) => void;
  109832. /**
  109833. * Callback called when a task is done (whatever the result is)
  109834. */
  109835. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  109836. /**
  109837. * Observable called when all tasks are processed
  109838. */
  109839. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  109840. /**
  109841. * Observable called when a task had an error
  109842. */
  109843. onTaskErrorObservable: Observable<AbstractAssetTask>;
  109844. /**
  109845. * Observable called when a task is successful
  109846. */
  109847. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  109848. /**
  109849. * Observable called when a task is done (whatever the result is)
  109850. */
  109851. onProgressObservable: Observable<IAssetsProgressEvent>;
  109852. /**
  109853. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  109854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109855. */
  109856. useDefaultLoadingScreen: boolean;
  109857. /**
  109858. * Creates a new AssetsManager
  109859. * @param scene defines the scene to work on
  109860. */
  109861. constructor(scene: Scene);
  109862. /**
  109863. * Add a MeshAssetTask to the list of active tasks
  109864. * @param taskName defines the name of the new task
  109865. * @param meshesNames defines the name of meshes to load
  109866. * @param rootUrl defines the root url to use to locate files
  109867. * @param sceneFilename defines the filename of the scene file
  109868. * @returns a new MeshAssetTask object
  109869. */
  109870. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  109871. /**
  109872. * Add a TextFileAssetTask to the list of active tasks
  109873. * @param taskName defines the name of the new task
  109874. * @param url defines the url of the file to load
  109875. * @returns a new TextFileAssetTask object
  109876. */
  109877. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  109878. /**
  109879. * Add a BinaryFileAssetTask to the list of active tasks
  109880. * @param taskName defines the name of the new task
  109881. * @param url defines the url of the file to load
  109882. * @returns a new BinaryFileAssetTask object
  109883. */
  109884. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  109885. /**
  109886. * Add a ImageAssetTask to the list of active tasks
  109887. * @param taskName defines the name of the new task
  109888. * @param url defines the url of the file to load
  109889. * @returns a new ImageAssetTask object
  109890. */
  109891. addImageTask(taskName: string, url: string): ImageAssetTask;
  109892. /**
  109893. * Add a TextureAssetTask to the list of active tasks
  109894. * @param taskName defines the name of the new task
  109895. * @param url defines the url of the file to load
  109896. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109897. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  109898. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109899. * @returns a new TextureAssetTask object
  109900. */
  109901. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  109902. /**
  109903. * Add a CubeTextureAssetTask to the list of active tasks
  109904. * @param taskName defines the name of the new task
  109905. * @param url defines the url of the file to load
  109906. * @param extensions defines the extension to use to load the cube map (can be null)
  109907. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109908. * @param files defines the list of files to load (can be null)
  109909. * @returns a new CubeTextureAssetTask object
  109910. */
  109911. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  109912. /**
  109913. *
  109914. * Add a HDRCubeTextureAssetTask to the list of active tasks
  109915. * @param taskName defines the name of the new task
  109916. * @param url defines the url of the file to load
  109917. * @param size defines the size you want for the cubemap (can be null)
  109918. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109919. * @param generateHarmonics defines if you want to automatically generate (true by default)
  109920. * @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)
  109921. * @param reserved Internal use only
  109922. * @returns a new HDRCubeTextureAssetTask object
  109923. */
  109924. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  109925. /**
  109926. * Remove a task from the assets manager.
  109927. * @param task the task to remove
  109928. */
  109929. removeTask(task: AbstractAssetTask): void;
  109930. private _decreaseWaitingTasksCount;
  109931. private _runTask;
  109932. /**
  109933. * Reset the AssetsManager and remove all tasks
  109934. * @return the current instance of the AssetsManager
  109935. */
  109936. reset(): AssetsManager;
  109937. /**
  109938. * Start the loading process
  109939. * @return the current instance of the AssetsManager
  109940. */
  109941. load(): AssetsManager;
  109942. }
  109943. }
  109944. declare module BABYLON {
  109945. /**
  109946. * Wrapper class for promise with external resolve and reject.
  109947. */
  109948. export class Deferred<T> {
  109949. /**
  109950. * The promise associated with this deferred object.
  109951. */
  109952. readonly promise: Promise<T>;
  109953. private _resolve;
  109954. private _reject;
  109955. /**
  109956. * The resolve method of the promise associated with this deferred object.
  109957. */
  109958. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  109959. /**
  109960. * The reject method of the promise associated with this deferred object.
  109961. */
  109962. readonly reject: (reason?: any) => void;
  109963. /**
  109964. * Constructor for this deferred object.
  109965. */
  109966. constructor();
  109967. }
  109968. }
  109969. declare module BABYLON {
  109970. /**
  109971. * Class used to help managing file picking and drag'n'drop
  109972. */
  109973. export class FilesInput {
  109974. /**
  109975. * List of files ready to be loaded
  109976. */
  109977. static readonly FilesToLoad: {
  109978. [key: string]: File;
  109979. };
  109980. /**
  109981. * Callback called when a file is processed
  109982. */
  109983. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109984. private _engine;
  109985. private _currentScene;
  109986. private _sceneLoadedCallback;
  109987. private _progressCallback;
  109988. private _additionalRenderLoopLogicCallback;
  109989. private _textureLoadingCallback;
  109990. private _startingProcessingFilesCallback;
  109991. private _onReloadCallback;
  109992. private _errorCallback;
  109993. private _elementToMonitor;
  109994. private _sceneFileToLoad;
  109995. private _filesToLoad;
  109996. /**
  109997. * Creates a new FilesInput
  109998. * @param engine defines the rendering engine
  109999. * @param scene defines the hosting scene
  110000. * @param sceneLoadedCallback callback called when scene is loaded
  110001. * @param progressCallback callback called to track progress
  110002. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110003. * @param textureLoadingCallback callback called when a texture is loading
  110004. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110005. * @param onReloadCallback callback called when a reload is requested
  110006. * @param errorCallback callback call if an error occurs
  110007. */
  110008. 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);
  110009. private _dragEnterHandler;
  110010. private _dragOverHandler;
  110011. private _dropHandler;
  110012. /**
  110013. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110014. * @param elementToMonitor defines the DOM element to track
  110015. */
  110016. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110017. /**
  110018. * Release all associated resources
  110019. */
  110020. dispose(): void;
  110021. private renderFunction;
  110022. private drag;
  110023. private drop;
  110024. private _traverseFolder;
  110025. private _processFiles;
  110026. /**
  110027. * Load files from a drop event
  110028. * @param event defines the drop event to use as source
  110029. */
  110030. loadFiles(event: any): void;
  110031. private _processReload;
  110032. /**
  110033. * Reload the current scene from the loaded files
  110034. */
  110035. reload(): void;
  110036. }
  110037. }
  110038. declare module BABYLON {
  110039. /**
  110040. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110042. */
  110043. export class SceneOptimization {
  110044. /**
  110045. * Defines the priority of this optimization (0 by default which means first in the list)
  110046. */
  110047. priority: number;
  110048. /**
  110049. * Gets a string describing the action executed by the current optimization
  110050. * @returns description string
  110051. */
  110052. getDescription(): string;
  110053. /**
  110054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110055. * @param scene defines the current scene where to apply this optimization
  110056. * @param optimizer defines the current optimizer
  110057. * @returns true if everything that can be done was applied
  110058. */
  110059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110060. /**
  110061. * Creates the SceneOptimization object
  110062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110063. * @param desc defines the description associated with the optimization
  110064. */
  110065. constructor(
  110066. /**
  110067. * Defines the priority of this optimization (0 by default which means first in the list)
  110068. */
  110069. priority?: number);
  110070. }
  110071. /**
  110072. * Defines an optimization used to reduce the size of render target textures
  110073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110074. */
  110075. export class TextureOptimization extends SceneOptimization {
  110076. /**
  110077. * Defines the priority of this optimization (0 by default which means first in the list)
  110078. */
  110079. priority: number;
  110080. /**
  110081. * 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
  110082. */
  110083. maximumSize: number;
  110084. /**
  110085. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110086. */
  110087. step: number;
  110088. /**
  110089. * Gets a string describing the action executed by the current optimization
  110090. * @returns description string
  110091. */
  110092. getDescription(): string;
  110093. /**
  110094. * Creates the TextureOptimization object
  110095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110096. * @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
  110097. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110098. */
  110099. constructor(
  110100. /**
  110101. * Defines the priority of this optimization (0 by default which means first in the list)
  110102. */
  110103. priority?: number,
  110104. /**
  110105. * 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
  110106. */
  110107. maximumSize?: number,
  110108. /**
  110109. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110110. */
  110111. step?: number);
  110112. /**
  110113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110114. * @param scene defines the current scene where to apply this optimization
  110115. * @param optimizer defines the current optimizer
  110116. * @returns true if everything that can be done was applied
  110117. */
  110118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110119. }
  110120. /**
  110121. * Defines an optimization used to increase or decrease the rendering resolution
  110122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110123. */
  110124. export class HardwareScalingOptimization extends SceneOptimization {
  110125. /**
  110126. * Defines the priority of this optimization (0 by default which means first in the list)
  110127. */
  110128. priority: number;
  110129. /**
  110130. * Defines the maximum scale to use (2 by default)
  110131. */
  110132. maximumScale: number;
  110133. /**
  110134. * Defines the step to use between two passes (0.5 by default)
  110135. */
  110136. step: number;
  110137. private _currentScale;
  110138. private _directionOffset;
  110139. /**
  110140. * Gets a string describing the action executed by the current optimization
  110141. * @return description string
  110142. */
  110143. getDescription(): string;
  110144. /**
  110145. * Creates the HardwareScalingOptimization object
  110146. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110147. * @param maximumScale defines the maximum scale to use (2 by default)
  110148. * @param step defines the step to use between two passes (0.5 by default)
  110149. */
  110150. constructor(
  110151. /**
  110152. * Defines the priority of this optimization (0 by default which means first in the list)
  110153. */
  110154. priority?: number,
  110155. /**
  110156. * Defines the maximum scale to use (2 by default)
  110157. */
  110158. maximumScale?: number,
  110159. /**
  110160. * Defines the step to use between two passes (0.5 by default)
  110161. */
  110162. step?: number);
  110163. /**
  110164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110165. * @param scene defines the current scene where to apply this optimization
  110166. * @param optimizer defines the current optimizer
  110167. * @returns true if everything that can be done was applied
  110168. */
  110169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110170. }
  110171. /**
  110172. * Defines an optimization used to remove shadows
  110173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110174. */
  110175. export class ShadowsOptimization extends SceneOptimization {
  110176. /**
  110177. * Gets a string describing the action executed by the current optimization
  110178. * @return description string
  110179. */
  110180. getDescription(): string;
  110181. /**
  110182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110183. * @param scene defines the current scene where to apply this optimization
  110184. * @param optimizer defines the current optimizer
  110185. * @returns true if everything that can be done was applied
  110186. */
  110187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110188. }
  110189. /**
  110190. * Defines an optimization used to turn post-processes off
  110191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110192. */
  110193. export class PostProcessesOptimization extends SceneOptimization {
  110194. /**
  110195. * Gets a string describing the action executed by the current optimization
  110196. * @return description string
  110197. */
  110198. getDescription(): string;
  110199. /**
  110200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110201. * @param scene defines the current scene where to apply this optimization
  110202. * @param optimizer defines the current optimizer
  110203. * @returns true if everything that can be done was applied
  110204. */
  110205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110206. }
  110207. /**
  110208. * Defines an optimization used to turn lens flares off
  110209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110210. */
  110211. export class LensFlaresOptimization extends SceneOptimization {
  110212. /**
  110213. * Gets a string describing the action executed by the current optimization
  110214. * @return description string
  110215. */
  110216. getDescription(): string;
  110217. /**
  110218. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110219. * @param scene defines the current scene where to apply this optimization
  110220. * @param optimizer defines the current optimizer
  110221. * @returns true if everything that can be done was applied
  110222. */
  110223. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110224. }
  110225. /**
  110226. * Defines an optimization based on user defined callback.
  110227. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110228. */
  110229. export class CustomOptimization extends SceneOptimization {
  110230. /**
  110231. * Callback called to apply the custom optimization.
  110232. */
  110233. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  110234. /**
  110235. * Callback called to get custom description
  110236. */
  110237. onGetDescription: () => string;
  110238. /**
  110239. * Gets a string describing the action executed by the current optimization
  110240. * @returns description string
  110241. */
  110242. getDescription(): string;
  110243. /**
  110244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110245. * @param scene defines the current scene where to apply this optimization
  110246. * @param optimizer defines the current optimizer
  110247. * @returns true if everything that can be done was applied
  110248. */
  110249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110250. }
  110251. /**
  110252. * Defines an optimization used to turn particles off
  110253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110254. */
  110255. export class ParticlesOptimization extends SceneOptimization {
  110256. /**
  110257. * Gets a string describing the action executed by the current optimization
  110258. * @return description string
  110259. */
  110260. getDescription(): string;
  110261. /**
  110262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110263. * @param scene defines the current scene where to apply this optimization
  110264. * @param optimizer defines the current optimizer
  110265. * @returns true if everything that can be done was applied
  110266. */
  110267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110268. }
  110269. /**
  110270. * Defines an optimization used to turn render targets off
  110271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110272. */
  110273. export class RenderTargetsOptimization extends SceneOptimization {
  110274. /**
  110275. * Gets a string describing the action executed by the current optimization
  110276. * @return description string
  110277. */
  110278. getDescription(): string;
  110279. /**
  110280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110281. * @param scene defines the current scene where to apply this optimization
  110282. * @param optimizer defines the current optimizer
  110283. * @returns true if everything that can be done was applied
  110284. */
  110285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110286. }
  110287. /**
  110288. * Defines an optimization used to merge meshes with compatible materials
  110289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110290. */
  110291. export class MergeMeshesOptimization extends SceneOptimization {
  110292. private static _UpdateSelectionTree;
  110293. /**
  110294. * Gets or sets a boolean which defines if optimization octree has to be updated
  110295. */
  110296. /**
  110297. * Gets or sets a boolean which defines if optimization octree has to be updated
  110298. */
  110299. static UpdateSelectionTree: boolean;
  110300. /**
  110301. * Gets a string describing the action executed by the current optimization
  110302. * @return description string
  110303. */
  110304. getDescription(): string;
  110305. private _canBeMerged;
  110306. /**
  110307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110308. * @param scene defines the current scene where to apply this optimization
  110309. * @param optimizer defines the current optimizer
  110310. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  110311. * @returns true if everything that can be done was applied
  110312. */
  110313. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  110314. }
  110315. /**
  110316. * Defines a list of options used by SceneOptimizer
  110317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110318. */
  110319. export class SceneOptimizerOptions {
  110320. /**
  110321. * Defines the target frame rate to reach (60 by default)
  110322. */
  110323. targetFrameRate: number;
  110324. /**
  110325. * Defines the interval between two checkes (2000ms by default)
  110326. */
  110327. trackerDuration: number;
  110328. /**
  110329. * Gets the list of optimizations to apply
  110330. */
  110331. optimizations: SceneOptimization[];
  110332. /**
  110333. * Creates a new list of options used by SceneOptimizer
  110334. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  110335. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  110336. */
  110337. constructor(
  110338. /**
  110339. * Defines the target frame rate to reach (60 by default)
  110340. */
  110341. targetFrameRate?: number,
  110342. /**
  110343. * Defines the interval between two checkes (2000ms by default)
  110344. */
  110345. trackerDuration?: number);
  110346. /**
  110347. * Add a new optimization
  110348. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  110349. * @returns the current SceneOptimizerOptions
  110350. */
  110351. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  110352. /**
  110353. * Add a new custom optimization
  110354. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  110355. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  110356. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110357. * @returns the current SceneOptimizerOptions
  110358. */
  110359. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  110360. /**
  110361. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  110362. * @param targetFrameRate defines the target frame rate (60 by default)
  110363. * @returns a SceneOptimizerOptions object
  110364. */
  110365. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110366. /**
  110367. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  110368. * @param targetFrameRate defines the target frame rate (60 by default)
  110369. * @returns a SceneOptimizerOptions object
  110370. */
  110371. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110372. /**
  110373. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  110374. * @param targetFrameRate defines the target frame rate (60 by default)
  110375. * @returns a SceneOptimizerOptions object
  110376. */
  110377. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110378. }
  110379. /**
  110380. * Class used to run optimizations in order to reach a target frame rate
  110381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110382. */
  110383. export class SceneOptimizer implements IDisposable {
  110384. private _isRunning;
  110385. private _options;
  110386. private _scene;
  110387. private _currentPriorityLevel;
  110388. private _targetFrameRate;
  110389. private _trackerDuration;
  110390. private _currentFrameRate;
  110391. private _sceneDisposeObserver;
  110392. private _improvementMode;
  110393. /**
  110394. * Defines an observable called when the optimizer reaches the target frame rate
  110395. */
  110396. onSuccessObservable: Observable<SceneOptimizer>;
  110397. /**
  110398. * Defines an observable called when the optimizer enables an optimization
  110399. */
  110400. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  110401. /**
  110402. * Defines an observable called when the optimizer is not able to reach the target frame rate
  110403. */
  110404. onFailureObservable: Observable<SceneOptimizer>;
  110405. /**
  110406. * Gets a boolean indicating if the optimizer is in improvement mode
  110407. */
  110408. readonly isInImprovementMode: boolean;
  110409. /**
  110410. * Gets the current priority level (0 at start)
  110411. */
  110412. readonly currentPriorityLevel: number;
  110413. /**
  110414. * Gets the current frame rate checked by the SceneOptimizer
  110415. */
  110416. readonly currentFrameRate: number;
  110417. /**
  110418. * Gets or sets the current target frame rate (60 by default)
  110419. */
  110420. /**
  110421. * Gets or sets the current target frame rate (60 by default)
  110422. */
  110423. targetFrameRate: number;
  110424. /**
  110425. * Gets or sets the current interval between two checks (every 2000ms by default)
  110426. */
  110427. /**
  110428. * Gets or sets the current interval between two checks (every 2000ms by default)
  110429. */
  110430. trackerDuration: number;
  110431. /**
  110432. * Gets the list of active optimizations
  110433. */
  110434. readonly optimizations: SceneOptimization[];
  110435. /**
  110436. * Creates a new SceneOptimizer
  110437. * @param scene defines the scene to work on
  110438. * @param options defines the options to use with the SceneOptimizer
  110439. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  110440. * @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)
  110441. */
  110442. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  110443. /**
  110444. * Stops the current optimizer
  110445. */
  110446. stop(): void;
  110447. /**
  110448. * Reset the optimizer to initial step (current priority level = 0)
  110449. */
  110450. reset(): void;
  110451. /**
  110452. * Start the optimizer. By default it will try to reach a specific framerate
  110453. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  110454. */
  110455. start(): void;
  110456. private _checkCurrentState;
  110457. /**
  110458. * Release all resources
  110459. */
  110460. dispose(): void;
  110461. /**
  110462. * Helper function to create a SceneOptimizer with one single line of code
  110463. * @param scene defines the scene to work on
  110464. * @param options defines the options to use with the SceneOptimizer
  110465. * @param onSuccess defines a callback to call on success
  110466. * @param onFailure defines a callback to call on failure
  110467. * @returns the new SceneOptimizer object
  110468. */
  110469. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  110470. }
  110471. }
  110472. declare module BABYLON {
  110473. /**
  110474. * Class used to serialize a scene into a string
  110475. */
  110476. export class SceneSerializer {
  110477. /**
  110478. * Clear cache used by a previous serialization
  110479. */
  110480. static ClearCache(): void;
  110481. /**
  110482. * Serialize a scene into a JSON compatible object
  110483. * @param scene defines the scene to serialize
  110484. * @returns a JSON compatible object
  110485. */
  110486. static Serialize(scene: Scene): any;
  110487. /**
  110488. * Serialize a mesh into a JSON compatible object
  110489. * @param toSerialize defines the mesh to serialize
  110490. * @param withParents defines if parents must be serialized as well
  110491. * @param withChildren defines if children must be serialized as well
  110492. * @returns a JSON compatible object
  110493. */
  110494. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  110495. }
  110496. }
  110497. declare module BABYLON {
  110498. /**
  110499. * This represents the different options avilable for the video capture.
  110500. */
  110501. export interface VideoRecorderOptions {
  110502. /** Defines the mime type of the video */
  110503. mimeType: string;
  110504. /** Defines the video the video should be recorded at */
  110505. fps: number;
  110506. /** Defines the chunk size for the recording data */
  110507. recordChunckSize: number;
  110508. }
  110509. /**
  110510. * This can helps recording videos from BabylonJS.
  110511. * This is based on the available WebRTC functionalities of the browser.
  110512. *
  110513. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  110514. */
  110515. export class VideoRecorder {
  110516. private static readonly _defaultOptions;
  110517. /**
  110518. * Returns wehther or not the VideoRecorder is available in your browser.
  110519. * @param engine Defines the Babylon Engine to check the support for
  110520. * @returns true if supported otherwise false
  110521. */
  110522. static IsSupported(engine: Engine): boolean;
  110523. private readonly _options;
  110524. private _canvas;
  110525. private _mediaRecorder;
  110526. private _recordedChunks;
  110527. private _fileName;
  110528. private _resolve;
  110529. private _reject;
  110530. /**
  110531. * True wether a recording is already in progress.
  110532. */
  110533. readonly isRecording: boolean;
  110534. /**
  110535. * Create a new VideoCapture object which can help converting what you see in Babylon to
  110536. * a video file.
  110537. * @param engine Defines the BabylonJS Engine you wish to record
  110538. * @param options Defines options that can be used to customized the capture
  110539. */
  110540. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  110541. /**
  110542. * Stops the current recording before the default capture timeout passed in the startRecording
  110543. * functions.
  110544. */
  110545. stopRecording(): void;
  110546. /**
  110547. * Starts recording the canvas for a max duration specified in parameters.
  110548. * @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.
  110549. * @param maxDuration Defines the maximum recording time in seconds.
  110550. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  110551. * @return a promise callback at the end of the recording with the video data in Blob.
  110552. */
  110553. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  110554. /**
  110555. * Releases internal resources used during the recording.
  110556. */
  110557. dispose(): void;
  110558. private _handleDataAvailable;
  110559. private _handleError;
  110560. private _handleStop;
  110561. }
  110562. }
  110563. declare module BABYLON {
  110564. /**
  110565. * Helper class to push actions to a pool of workers.
  110566. */
  110567. export class WorkerPool implements IDisposable {
  110568. private _workerInfos;
  110569. private _pendingActions;
  110570. /**
  110571. * Constructor
  110572. * @param workers Array of workers to use for actions
  110573. */
  110574. constructor(workers: Array<Worker>);
  110575. /**
  110576. * Terminates all workers and clears any pending actions.
  110577. */
  110578. dispose(): void;
  110579. /**
  110580. * Pushes an action to the worker pool. If all the workers are active, the action will be
  110581. * pended until a worker has completed its action.
  110582. * @param action The action to perform. Call onComplete when the action is complete.
  110583. */
  110584. push(action: (worker: Worker, onComplete: () => void) => void): void;
  110585. private _execute;
  110586. }
  110587. }
  110588. declare module BABYLON {
  110589. /**
  110590. * Class containing a set of static utilities functions for screenshots
  110591. */
  110592. export class ScreenshotTools {
  110593. /**
  110594. * Captures a screenshot of the current rendering
  110595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110596. * @param engine defines the rendering engine
  110597. * @param camera defines the source camera
  110598. * @param size This parameter can be set to a single number or to an object with the
  110599. * following (optional) properties: precision, width, height. If a single number is passed,
  110600. * it will be used for both width and height. If an object is passed, the screenshot size
  110601. * will be derived from the parameters. The precision property is a multiplier allowing
  110602. * rendering at a higher or lower resolution
  110603. * @param successCallback defines the callback receives a single parameter which contains the
  110604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110605. * src parameter of an <img> to display it
  110606. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110607. * Check your browser for supported MIME types
  110608. */
  110609. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  110610. /**
  110611. * Generates an image screenshot from the specified camera.
  110612. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110613. * @param engine The engine to use for rendering
  110614. * @param camera The camera to use for rendering
  110615. * @param size This parameter can be set to a single number or to an object with the
  110616. * following (optional) properties: precision, width, height. If a single number is passed,
  110617. * it will be used for both width and height. If an object is passed, the screenshot size
  110618. * will be derived from the parameters. The precision property is a multiplier allowing
  110619. * rendering at a higher or lower resolution
  110620. * @param successCallback The callback receives a single parameter which contains the
  110621. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110622. * src parameter of an <img> to display it
  110623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110624. * Check your browser for supported MIME types
  110625. * @param samples Texture samples (default: 1)
  110626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110627. * @param fileName A name for for the downloaded file.
  110628. */
  110629. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /**
  110634. * A cursor which tracks a point on a path
  110635. */
  110636. export class PathCursor {
  110637. private path;
  110638. /**
  110639. * Stores path cursor callbacks for when an onchange event is triggered
  110640. */
  110641. private _onchange;
  110642. /**
  110643. * The value of the path cursor
  110644. */
  110645. value: number;
  110646. /**
  110647. * The animation array of the path cursor
  110648. */
  110649. animations: Animation[];
  110650. /**
  110651. * Initializes the path cursor
  110652. * @param path The path to track
  110653. */
  110654. constructor(path: Path2);
  110655. /**
  110656. * Gets the cursor point on the path
  110657. * @returns A point on the path cursor at the cursor location
  110658. */
  110659. getPoint(): Vector3;
  110660. /**
  110661. * Moves the cursor ahead by the step amount
  110662. * @param step The amount to move the cursor forward
  110663. * @returns This path cursor
  110664. */
  110665. moveAhead(step?: number): PathCursor;
  110666. /**
  110667. * Moves the cursor behind by the step amount
  110668. * @param step The amount to move the cursor back
  110669. * @returns This path cursor
  110670. */
  110671. moveBack(step?: number): PathCursor;
  110672. /**
  110673. * Moves the cursor by the step amount
  110674. * If the step amount is greater than one, an exception is thrown
  110675. * @param step The amount to move the cursor
  110676. * @returns This path cursor
  110677. */
  110678. move(step: number): PathCursor;
  110679. /**
  110680. * Ensures that the value is limited between zero and one
  110681. * @returns This path cursor
  110682. */
  110683. private ensureLimits;
  110684. /**
  110685. * Runs onchange callbacks on change (used by the animation engine)
  110686. * @returns This path cursor
  110687. */
  110688. private raiseOnChange;
  110689. /**
  110690. * Executes a function on change
  110691. * @param f A path cursor onchange callback
  110692. * @returns This path cursor
  110693. */
  110694. onchange(f: (cursor: PathCursor) => void): PathCursor;
  110695. }
  110696. }
  110697. declare module BABYLON {
  110698. /** @hidden */
  110699. export var blurPixelShader: {
  110700. name: string;
  110701. shader: string;
  110702. };
  110703. }
  110704. declare module BABYLON {
  110705. /** @hidden */
  110706. export var bones300Declaration: {
  110707. name: string;
  110708. shader: string;
  110709. };
  110710. }
  110711. declare module BABYLON {
  110712. /** @hidden */
  110713. export var instances300Declaration: {
  110714. name: string;
  110715. shader: string;
  110716. };
  110717. }
  110718. declare module BABYLON {
  110719. /** @hidden */
  110720. export var pointCloudVertexDeclaration: {
  110721. name: string;
  110722. shader: string;
  110723. };
  110724. }
  110725. // Mixins
  110726. interface Window {
  110727. mozIndexedDB: IDBFactory;
  110728. webkitIndexedDB: IDBFactory;
  110729. msIndexedDB: IDBFactory;
  110730. webkitURL: typeof URL;
  110731. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  110732. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  110733. WebGLRenderingContext: WebGLRenderingContext;
  110734. MSGesture: MSGesture;
  110735. CANNON: any;
  110736. AudioContext: AudioContext;
  110737. webkitAudioContext: AudioContext;
  110738. PointerEvent: any;
  110739. Math: Math;
  110740. Uint8Array: Uint8ArrayConstructor;
  110741. Float32Array: Float32ArrayConstructor;
  110742. mozURL: typeof URL;
  110743. msURL: typeof URL;
  110744. VRFrameData: any; // WebVR, from specs 1.1
  110745. DracoDecoderModule: any;
  110746. setImmediate(handler: (...args: any[]) => void): number;
  110747. }
  110748. interface Document {
  110749. mozCancelFullScreen(): void;
  110750. msCancelFullScreen(): void;
  110751. webkitCancelFullScreen(): void;
  110752. requestPointerLock(): void;
  110753. exitPointerLock(): void;
  110754. mozFullScreen: boolean;
  110755. msIsFullScreen: boolean;
  110756. readonly webkitIsFullScreen: boolean;
  110757. readonly pointerLockElement: Element;
  110758. mozPointerLockElement: HTMLElement;
  110759. msPointerLockElement: HTMLElement;
  110760. webkitPointerLockElement: HTMLElement;
  110761. }
  110762. interface HTMLCanvasElement {
  110763. requestPointerLock(): void;
  110764. msRequestPointerLock?(): void;
  110765. mozRequestPointerLock?(): void;
  110766. webkitRequestPointerLock?(): void;
  110767. /** Track wether a record is in progress */
  110768. isRecording: boolean;
  110769. /** Capture Stream method defined by some browsers */
  110770. captureStream(fps?: number): MediaStream;
  110771. }
  110772. interface CanvasRenderingContext2D {
  110773. msImageSmoothingEnabled: boolean;
  110774. }
  110775. interface MouseEvent {
  110776. mozMovementX: number;
  110777. mozMovementY: number;
  110778. webkitMovementX: number;
  110779. webkitMovementY: number;
  110780. msMovementX: number;
  110781. msMovementY: number;
  110782. }
  110783. interface Navigator {
  110784. mozGetVRDevices: (any: any) => any;
  110785. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110786. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110787. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110788. webkitGetGamepads(): Gamepad[];
  110789. msGetGamepads(): Gamepad[];
  110790. webkitGamepads(): Gamepad[];
  110791. }
  110792. interface HTMLVideoElement {
  110793. mozSrcObject: any;
  110794. }
  110795. interface Math {
  110796. fround(x: number): number;
  110797. imul(a: number, b: number): number;
  110798. }
  110799. interface WebGLProgram {
  110800. context?: WebGLRenderingContext;
  110801. vertexShader?: WebGLShader;
  110802. fragmentShader?: WebGLShader;
  110803. isParallelCompiled: boolean;
  110804. onCompiled?: () => void;
  110805. }
  110806. interface WebGLRenderingContext {
  110807. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  110808. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  110809. vertexAttribDivisor(index: number, divisor: number): void;
  110810. createVertexArray(): any;
  110811. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  110812. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  110813. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  110814. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  110815. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  110816. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  110817. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  110818. // Queries
  110819. createQuery(): WebGLQuery;
  110820. deleteQuery(query: WebGLQuery): void;
  110821. beginQuery(target: number, query: WebGLQuery): void;
  110822. endQuery(target: number): void;
  110823. getQueryParameter(query: WebGLQuery, pname: number): any;
  110824. getQuery(target: number, pname: number): any;
  110825. MAX_SAMPLES: number;
  110826. RGBA8: number;
  110827. READ_FRAMEBUFFER: number;
  110828. DRAW_FRAMEBUFFER: number;
  110829. UNIFORM_BUFFER: number;
  110830. HALF_FLOAT_OES: number;
  110831. RGBA16F: number;
  110832. RGBA32F: number;
  110833. R32F: number;
  110834. RG32F: number;
  110835. RGB32F: number;
  110836. R16F: number;
  110837. RG16F: number;
  110838. RGB16F: number;
  110839. RED: number;
  110840. RG: number;
  110841. R8: number;
  110842. RG8: number;
  110843. UNSIGNED_INT_24_8: number;
  110844. DEPTH24_STENCIL8: number;
  110845. /* Multiple Render Targets */
  110846. drawBuffers(buffers: number[]): void;
  110847. readBuffer(src: number): void;
  110848. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  110849. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  110850. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  110851. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  110852. // Occlusion Query
  110853. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  110854. ANY_SAMPLES_PASSED: number;
  110855. QUERY_RESULT_AVAILABLE: number;
  110856. QUERY_RESULT: number;
  110857. }
  110858. interface WebGLBuffer {
  110859. references: number;
  110860. capacity: number;
  110861. is32Bits: boolean;
  110862. }
  110863. interface WebGLProgram {
  110864. transformFeedback?: WebGLTransformFeedback | null;
  110865. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  110866. }
  110867. interface EXT_disjoint_timer_query {
  110868. QUERY_COUNTER_BITS_EXT: number;
  110869. TIME_ELAPSED_EXT: number;
  110870. TIMESTAMP_EXT: number;
  110871. GPU_DISJOINT_EXT: number;
  110872. QUERY_RESULT_EXT: number;
  110873. QUERY_RESULT_AVAILABLE_EXT: number;
  110874. queryCounterEXT(query: WebGLQuery, target: number): void;
  110875. createQueryEXT(): WebGLQuery;
  110876. beginQueryEXT(target: number, query: WebGLQuery): void;
  110877. endQueryEXT(target: number): void;
  110878. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  110879. deleteQueryEXT(query: WebGLQuery): void;
  110880. }
  110881. interface WebGLUniformLocation {
  110882. _currentState: any;
  110883. }
  110884. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  110885. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  110886. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  110887. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110888. interface WebGLRenderingContext {
  110889. readonly RASTERIZER_DISCARD: number;
  110890. readonly DEPTH_COMPONENT24: number;
  110891. readonly TEXTURE_3D: number;
  110892. readonly TEXTURE_2D_ARRAY: number;
  110893. readonly TEXTURE_COMPARE_FUNC: number;
  110894. readonly TEXTURE_COMPARE_MODE: number;
  110895. readonly COMPARE_REF_TO_TEXTURE: number;
  110896. readonly TEXTURE_WRAP_R: number;
  110897. readonly HALF_FLOAT: number;
  110898. readonly RGB8: number;
  110899. readonly RED_INTEGER: number;
  110900. readonly RG_INTEGER: number;
  110901. readonly RGB_INTEGER: number;
  110902. readonly RGBA_INTEGER: number;
  110903. readonly R8_SNORM: number;
  110904. readonly RG8_SNORM: number;
  110905. readonly RGB8_SNORM: number;
  110906. readonly RGBA8_SNORM: number;
  110907. readonly R8I: number;
  110908. readonly RG8I: number;
  110909. readonly RGB8I: number;
  110910. readonly RGBA8I: number;
  110911. readonly R8UI: number;
  110912. readonly RG8UI: number;
  110913. readonly RGB8UI: number;
  110914. readonly RGBA8UI: number;
  110915. readonly R16I: number;
  110916. readonly RG16I: number;
  110917. readonly RGB16I: number;
  110918. readonly RGBA16I: number;
  110919. readonly R16UI: number;
  110920. readonly RG16UI: number;
  110921. readonly RGB16UI: number;
  110922. readonly RGBA16UI: number;
  110923. readonly R32I: number;
  110924. readonly RG32I: number;
  110925. readonly RGB32I: number;
  110926. readonly RGBA32I: number;
  110927. readonly R32UI: number;
  110928. readonly RG32UI: number;
  110929. readonly RGB32UI: number;
  110930. readonly RGBA32UI: number;
  110931. readonly RGB10_A2UI: number;
  110932. readonly R11F_G11F_B10F: number;
  110933. readonly RGB9_E5: number;
  110934. readonly RGB10_A2: number;
  110935. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  110936. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  110937. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  110938. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  110939. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  110940. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110941. 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;
  110942. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110943. readonly TRANSFORM_FEEDBACK: number;
  110944. readonly INTERLEAVED_ATTRIBS: number;
  110945. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110946. createTransformFeedback(): WebGLTransformFeedback;
  110947. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110948. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110949. beginTransformFeedback(primitiveMode: number): void;
  110950. endTransformFeedback(): void;
  110951. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  110952. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110953. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110954. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110955. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  110956. }
  110957. interface ImageBitmap {
  110958. readonly width: number;
  110959. readonly height: number;
  110960. close(): void;
  110961. }
  110962. interface WebGLQuery extends WebGLObject {
  110963. }
  110964. declare var WebGLQuery: {
  110965. prototype: WebGLQuery;
  110966. new(): WebGLQuery;
  110967. };
  110968. interface WebGLSampler extends WebGLObject {
  110969. }
  110970. declare var WebGLSampler: {
  110971. prototype: WebGLSampler;
  110972. new(): WebGLSampler;
  110973. };
  110974. interface WebGLSync extends WebGLObject {
  110975. }
  110976. declare var WebGLSync: {
  110977. prototype: WebGLSync;
  110978. new(): WebGLSync;
  110979. };
  110980. interface WebGLTransformFeedback extends WebGLObject {
  110981. }
  110982. declare var WebGLTransformFeedback: {
  110983. prototype: WebGLTransformFeedback;
  110984. new(): WebGLTransformFeedback;
  110985. };
  110986. interface WebGLVertexArrayObject extends WebGLObject {
  110987. }
  110988. declare var WebGLVertexArrayObject: {
  110989. prototype: WebGLVertexArrayObject;
  110990. new(): WebGLVertexArrayObject;
  110991. };
  110992. // Type definitions for WebVR API
  110993. // Project: https://w3c.github.io/webvr/
  110994. // Definitions by: six a <https://github.com/lostfictions>
  110995. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110996. interface VRDisplay extends EventTarget {
  110997. /**
  110998. * Dictionary of capabilities describing the VRDisplay.
  110999. */
  111000. readonly capabilities: VRDisplayCapabilities;
  111001. /**
  111002. * z-depth defining the far plane of the eye view frustum
  111003. * enables mapping of values in the render target depth
  111004. * attachment to scene coordinates. Initially set to 10000.0.
  111005. */
  111006. depthFar: number;
  111007. /**
  111008. * z-depth defining the near plane of the eye view frustum
  111009. * enables mapping of values in the render target depth
  111010. * attachment to scene coordinates. Initially set to 0.01.
  111011. */
  111012. depthNear: number;
  111013. /**
  111014. * An identifier for this distinct VRDisplay. Used as an
  111015. * association point in the Gamepad API.
  111016. */
  111017. readonly displayId: number;
  111018. /**
  111019. * A display name, a user-readable name identifying it.
  111020. */
  111021. readonly displayName: string;
  111022. readonly isConnected: boolean;
  111023. readonly isPresenting: boolean;
  111024. /**
  111025. * If this VRDisplay supports room-scale experiences, the optional
  111026. * stage attribute contains details on the room-scale parameters.
  111027. */
  111028. readonly stageParameters: VRStageParameters | null;
  111029. /**
  111030. * Passing the value returned by `requestAnimationFrame` to
  111031. * `cancelAnimationFrame` will unregister the callback.
  111032. * @param handle Define the hanle of the request to cancel
  111033. */
  111034. cancelAnimationFrame(handle: number): void;
  111035. /**
  111036. * Stops presenting to the VRDisplay.
  111037. * @returns a promise to know when it stopped
  111038. */
  111039. exitPresent(): Promise<void>;
  111040. /**
  111041. * Return the current VREyeParameters for the given eye.
  111042. * @param whichEye Define the eye we want the parameter for
  111043. * @returns the eye parameters
  111044. */
  111045. getEyeParameters(whichEye: string): VREyeParameters;
  111046. /**
  111047. * Populates the passed VRFrameData with the information required to render
  111048. * the current frame.
  111049. * @param frameData Define the data structure to populate
  111050. * @returns true if ok otherwise false
  111051. */
  111052. getFrameData(frameData: VRFrameData): boolean;
  111053. /**
  111054. * Get the layers currently being presented.
  111055. * @returns the list of VR layers
  111056. */
  111057. getLayers(): VRLayer[];
  111058. /**
  111059. * Return a VRPose containing the future predicted pose of the VRDisplay
  111060. * when the current frame will be presented. The value returned will not
  111061. * change until JavaScript has returned control to the browser.
  111062. *
  111063. * The VRPose will contain the position, orientation, velocity,
  111064. * and acceleration of each of these properties.
  111065. * @returns the pose object
  111066. */
  111067. getPose(): VRPose;
  111068. /**
  111069. * Return the current instantaneous pose of the VRDisplay, with no
  111070. * prediction applied.
  111071. * @returns the current instantaneous pose
  111072. */
  111073. getImmediatePose(): VRPose;
  111074. /**
  111075. * The callback passed to `requestAnimationFrame` will be called
  111076. * any time a new frame should be rendered. When the VRDisplay is
  111077. * presenting the callback will be called at the native refresh
  111078. * rate of the HMD. When not presenting this function acts
  111079. * identically to how window.requestAnimationFrame acts. Content should
  111080. * make no assumptions of frame rate or vsync behavior as the HMD runs
  111081. * asynchronously from other displays and at differing refresh rates.
  111082. * @param callback Define the eaction to run next frame
  111083. * @returns the request handle it
  111084. */
  111085. requestAnimationFrame(callback: FrameRequestCallback): number;
  111086. /**
  111087. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  111088. * Repeat calls while already presenting will update the VRLayers being displayed.
  111089. * @param layers Define the list of layer to present
  111090. * @returns a promise to know when the request has been fulfilled
  111091. */
  111092. requestPresent(layers: VRLayer[]): Promise<void>;
  111093. /**
  111094. * Reset the pose for this display, treating its current position and
  111095. * orientation as the "origin/zero" values. VRPose.position,
  111096. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  111097. * updated when calling resetPose(). This should be called in only
  111098. * sitting-space experiences.
  111099. */
  111100. resetPose(): void;
  111101. /**
  111102. * The VRLayer provided to the VRDisplay will be captured and presented
  111103. * in the HMD. Calling this function has the same effect on the source
  111104. * canvas as any other operation that uses its source image, and canvases
  111105. * created without preserveDrawingBuffer set to true will be cleared.
  111106. * @param pose Define the pose to submit
  111107. */
  111108. submitFrame(pose?: VRPose): void;
  111109. }
  111110. declare var VRDisplay: {
  111111. prototype: VRDisplay;
  111112. new(): VRDisplay;
  111113. };
  111114. interface VRLayer {
  111115. leftBounds?: number[] | Float32Array | null;
  111116. rightBounds?: number[] | Float32Array | null;
  111117. source?: HTMLCanvasElement | null;
  111118. }
  111119. interface VRDisplayCapabilities {
  111120. readonly canPresent: boolean;
  111121. readonly hasExternalDisplay: boolean;
  111122. readonly hasOrientation: boolean;
  111123. readonly hasPosition: boolean;
  111124. readonly maxLayers: number;
  111125. }
  111126. interface VREyeParameters {
  111127. /** @deprecated */
  111128. readonly fieldOfView: VRFieldOfView;
  111129. readonly offset: Float32Array;
  111130. readonly renderHeight: number;
  111131. readonly renderWidth: number;
  111132. }
  111133. interface VRFieldOfView {
  111134. readonly downDegrees: number;
  111135. readonly leftDegrees: number;
  111136. readonly rightDegrees: number;
  111137. readonly upDegrees: number;
  111138. }
  111139. interface VRFrameData {
  111140. readonly leftProjectionMatrix: Float32Array;
  111141. readonly leftViewMatrix: Float32Array;
  111142. readonly pose: VRPose;
  111143. readonly rightProjectionMatrix: Float32Array;
  111144. readonly rightViewMatrix: Float32Array;
  111145. readonly timestamp: number;
  111146. }
  111147. interface VRPose {
  111148. readonly angularAcceleration: Float32Array | null;
  111149. readonly angularVelocity: Float32Array | null;
  111150. readonly linearAcceleration: Float32Array | null;
  111151. readonly linearVelocity: Float32Array | null;
  111152. readonly orientation: Float32Array | null;
  111153. readonly position: Float32Array | null;
  111154. readonly timestamp: number;
  111155. }
  111156. interface VRStageParameters {
  111157. sittingToStandingTransform?: Float32Array;
  111158. sizeX?: number;
  111159. sizeY?: number;
  111160. }
  111161. interface Navigator {
  111162. getVRDisplays(): Promise<VRDisplay[]>;
  111163. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  111164. }
  111165. interface Window {
  111166. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  111167. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  111168. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  111169. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111170. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111171. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  111172. }
  111173. interface Gamepad {
  111174. readonly displayId: number;
  111175. }
  111176. interface XRDevice {
  111177. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  111178. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  111179. }
  111180. interface XRSession {
  111181. getInputSources(): Array<any>;
  111182. baseLayer: XRWebGLLayer;
  111183. requestFrameOfReference(type: string): Promise<void>;
  111184. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  111185. end(): Promise<void>;
  111186. requestAnimationFrame: Function;
  111187. addEventListener: Function;
  111188. }
  111189. interface XRSessionCreationOptions {
  111190. outputContext?: WebGLRenderingContext | null;
  111191. immersive?: boolean;
  111192. environmentIntegration?: boolean;
  111193. }
  111194. interface XRLayer {
  111195. getViewport: Function;
  111196. framebufferWidth: number;
  111197. framebufferHeight: number;
  111198. }
  111199. interface XRView {
  111200. projectionMatrix: Float32Array;
  111201. }
  111202. interface XRFrame {
  111203. getDevicePose: Function;
  111204. getInputPose: Function;
  111205. views: Array<XRView>;
  111206. baseLayer: XRLayer;
  111207. }
  111208. interface XRFrameOfReference {
  111209. }
  111210. interface XRWebGLLayer extends XRLayer {
  111211. framebuffer: WebGLFramebuffer;
  111212. }
  111213. declare var XRWebGLLayer: {
  111214. prototype: XRWebGLLayer;
  111215. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  111216. };